Commit | Line | Data |
89d0527d |
1 | #!./perl |
2 | |
fb73857a |
3 | # $RCSfile: complex.t,v $ |
89d0527d |
4 | # |
5aabfad6 |
5 | # Regression tests for the Math::Complex pacakge |
b42d0ec9 |
6 | # -- Raphael Manfredi since Sep 1996 |
7 | # -- Jarkko Hietaniemi since Mar 1997 |
8 | # -- Daniel S. Lewart since Sep 1997 |
5aabfad6 |
9 | |
89d0527d |
10 | BEGIN { |
11 | chdir 't' if -d 't'; |
93430cb4 |
12 | unshift @INC, '../lib'; |
89d0527d |
13 | } |
5aabfad6 |
14 | |
89d0527d |
15 | use Math::Complex; |
16 | |
2820d885 |
17 | my $VERSION = sprintf("%s", q$Id: complex.t,v 1.9 1998/11/01 00:00:00 dsl Exp $ =~ /(\d+\.d+)/); |
b42d0ec9 |
18 | |
fb73857a |
19 | my ($args, $op, $target, $test, $test_set, $try, $val, $zvalue, @set, @val); |
20 | |
89d0527d |
21 | $test = 0; |
22 | $| = 1; |
fb73857a |
23 | my @script = ( |
24 | 'my ($res, $s0,$s1,$s2,$s3,$s4,$s5,$s6,$s7,$s8,$s9,$s10, $z0,$z1,$z2);' . |
25 | "\n\n" |
26 | ); |
b42d0ec9 |
27 | my $eps = 1e-13; |
89d0527d |
28 | |
d09ae4e6 |
29 | if ($^O eq 'unicos') { # For some reason root() produces very inaccurate |
30 | $eps = 1e-11; # results in Cray UNICOS, and occasionally also |
31 | } # cos(), sin(), cosh(), sinh(). The division |
32 | # of doubles is the current suspect. |
33 | |
89d0527d |
34 | while (<DATA>) { |
0c721ce2 |
35 | s/^\s+//; |
36 | next if $_ eq '' || /^\#/; |
37 | chomp; |
38 | $test_set = 0; # Assume not a test over a set of values |
0e505df1 |
39 | if (/^&(.+)/) { |
89d0527d |
40 | $op = $1; |
41 | next; |
42 | } |
0e505df1 |
43 | elsif (/^\{(.+)\}/) { |
89d0527d |
44 | set($1, \@set, \@val); |
45 | next; |
46 | } |
47 | elsif (s/^\|//) { |
0c721ce2 |
48 | $test_set = 1; # Requests we loop over the set... |
89d0527d |
49 | } |
50 | my @args = split(/:/); |
0c721ce2 |
51 | if ($test_set == 1) { |
89d0527d |
52 | my $i; |
53 | for ($i = 0; $i < @set; $i++) { |
0c721ce2 |
54 | # complex number |
55 | $target = $set[$i]; |
56 | # textual value as found in set definition |
57 | $zvalue = $val[$i]; |
89d0527d |
58 | test($zvalue, $target, @args); |
59 | } |
60 | } else { |
61 | test($op, undef, @args); |
62 | } |
63 | } |
64 | |
b42d0ec9 |
65 | # |
66 | |
67 | sub test_mutators { |
68 | my $op; |
69 | |
70 | $test++; |
71 | push(@script, <<'EOT'); |
72 | { |
73 | my $z = cplx( 1, 1); |
74 | $z->Re(2); |
75 | $z->Im(3); |
16357284 |
76 | print "# $test Re(z) = ",$z->Re(), " Im(z) = ", $z->Im(), " z = $z\n"; |
b42d0ec9 |
77 | print 'not ' unless Re($z) == 2 and Im($z) == 3; |
78 | EOT |
79 | push(@script, qq(print "ok $test\\n"}\n)); |
80 | |
81 | $test++; |
82 | push(@script, <<'EOT'); |
83 | { |
84 | my $z = cplx( 1, 1); |
85 | $z->abs(3 * sqrt(2)); |
16357284 |
86 | print "# $test Re(z) = ",$z->Re(), " Im(z) = ", $z->Im(), " z = $z\n"; |
b42d0ec9 |
87 | print 'not ' unless (abs($z) - 3 * sqrt(2)) < $eps and |
88 | (arg($z) - pi / 4 ) < $eps and |
89 | (Re($z) - 3 ) < $eps and |
90 | (Im($z) - 3 ) < $eps; |
91 | EOT |
92 | push(@script, qq(print "ok $test\\n"}\n)); |
93 | |
94 | $test++; |
95 | push(@script, <<'EOT'); |
96 | { |
97 | my $z = cplx( 1, 1); |
98 | $z->arg(-3 / 4 * pi); |
16357284 |
99 | print "# $test Re(z) = ",$z->Re(), " Im(z) = ", $z->Im(), " z = $z\n"; |
b42d0ec9 |
100 | print 'not ' unless (arg($z) + 3 / 4 * pi) < $eps and |
101 | (abs($z) - sqrt(2) ) < $eps and |
102 | (Re($z) + 1 ) < $eps and |
103 | (Im($z) + 1 ) < $eps; |
104 | EOT |
105 | push(@script, qq(print "ok $test\\n"}\n)); |
106 | } |
107 | |
108 | test_mutators(); |
109 | |
110 | my $constants = ' |
111 | my $i = cplx(0, 1); |
112 | my $pi = cplx(pi, 0); |
113 | my $pii = cplx(0, pi); |
114 | my $pip2 = cplx(pi/2, 0); |
115 | my $zero = cplx(0, 0); |
116 | '; |
117 | |
118 | push(@script, $constants); |
119 | |
120 | |
5cd24f17 |
121 | # test the divbyzeros |
122 | |
0e505df1 |
123 | sub test_dbz { |
124 | for my $op (@_) { |
125 | $test++; |
b42d0ec9 |
126 | push(@script, <<EOT); |
16357284 |
127 | eval '$op'; |
128 | (\$bad) = (\$@ =~ /(.+)/); |
129 | print "# $test op = $op divbyzero? \$bad...\n"; |
130 | print 'not ' unless (\$@ =~ /Division by zero/); |
b42d0ec9 |
131 | EOT |
132 | push(@script, qq(print "ok $test\\n";\n)); |
0e505df1 |
133 | } |
134 | } |
135 | |
8c03c583 |
136 | # test the logofzeros |
137 | |
138 | sub test_loz { |
139 | for my $op (@_) { |
140 | $test++; |
b42d0ec9 |
141 | push(@script, <<EOT); |
16357284 |
142 | eval '$op'; |
143 | (\$bad) = (\$@ =~ /(.+)/); |
144 | print "# $test op = $op logofzero? \$bad...\n"; |
145 | print 'not ' unless (\$@ =~ /Logarithm of zero/); |
b42d0ec9 |
146 | EOT |
147 | push(@script, qq(print "ok $test\\n";\n)); |
8c03c583 |
148 | } |
149 | } |
150 | |
5cd24f17 |
151 | test_dbz( |
152 | 'i/0', |
b42d0ec9 |
153 | 'acot(0)', |
154 | 'acot(+$i)', |
155 | # 'acoth(-1)', # Log of zero. |
156 | 'acoth(0)', |
157 | 'acoth(+1)', |
5cd24f17 |
158 | 'acsc(0)', |
5cd24f17 |
159 | 'acsch(0)', |
b42d0ec9 |
160 | 'asec(0)', |
161 | 'asech(0)', |
162 | 'atan(-$i)', |
163 | 'atan($i)', |
164 | # 'atanh(-1)', # Log of zero. |
165 | 'atanh(+1)', |
166 | 'cot(0)', |
167 | 'coth(0)', |
168 | 'csc(0)', |
169 | 'tan($pip2)', |
170 | 'csch(0)', |
171 | 'tan($pip2)', |
8c03c583 |
172 | ); |
173 | |
174 | test_loz( |
fb73857a |
175 | 'log($zero)', |
b42d0ec9 |
176 | 'acot(-$i)', |
8c03c583 |
177 | 'atanh(-1)', |
178 | 'acoth(-1)', |
5cd24f17 |
179 | ); |
180 | |
0e505df1 |
181 | # test the bad roots |
182 | |
183 | sub test_broot { |
5cd24f17 |
184 | for my $op (@_) { |
185 | $test++; |
b42d0ec9 |
186 | push(@script, <<EOT); |
16357284 |
187 | eval 'root(2, $op)'; |
188 | (\$bad) = (\$@ =~ /(.+)/); |
189 | print "# $test op = $op badroot? \$bad...\n"; |
190 | print 'not ' unless (\$@ =~ /root must be/); |
b42d0ec9 |
191 | EOT |
192 | push(@script, qq(print "ok $test\\n";\n)); |
5cd24f17 |
193 | } |
194 | } |
195 | |
0e505df1 |
196 | test_broot(qw(-3 -2.1 0 0.99)); |
197 | |
16357284 |
198 | sub test_display_format { |
199 | push @script, <<EOS; |
200 | my \$j = (root(1,3))[1]; |
201 | |
202 | \$j->display_format('polar'); |
203 | EOS |
204 | |
205 | $test++; |
206 | push @script, <<EOS; |
207 | print "# display_format polar?\n"; |
208 | print "not " unless \$j->display_format eq 'polar'; |
209 | print "ok $test\n"; |
210 | EOS |
211 | |
212 | $test++; |
213 | push @script, <<EOS; |
214 | print "# j = \$j\n"; |
215 | print "not " unless "\$j" eq "[1,2pi/3]"; |
216 | print "ok $test\n"; |
217 | |
218 | my %display_format; |
219 | |
220 | %display_format = \$j->display_format; |
221 | EOS |
222 | |
223 | $test++; |
224 | push @script, <<EOS; |
225 | print "# display_format{style} polar?\n"; |
226 | print "not " unless \$display_format{style} eq 'polar'; |
227 | print "ok $test\n"; |
228 | EOS |
229 | |
230 | $test++; |
231 | push @script, <<EOS; |
232 | print "# keys %display_format == 2?\n"; |
233 | print "not " unless keys %display_format == 2; |
234 | print "ok $test\n"; |
235 | |
236 | \$j->display_format('style' => 'cartesian', 'format' => '%.5f'); |
237 | EOS |
238 | |
239 | $test++; |
240 | push @script, <<EOS; |
241 | print "# j = \$j\n"; |
242 | print "not " unless "\$j" eq "-0.50000+0.86603i"; |
243 | print "ok $test\n"; |
244 | |
245 | %display_format = \$j->display_format; |
246 | EOS |
247 | |
248 | $test++; |
249 | push @script, <<EOS; |
250 | print "# display_format{format} %.5f?\n"; |
251 | print "not " unless \$display_format{format} eq '%.5f'; |
252 | print "ok $test\n"; |
253 | EOS |
254 | |
255 | $test++; |
256 | push @script, <<EOS; |
257 | print "# keys %display_format == 3?\n"; |
258 | print "not " unless keys %display_format == 3; |
259 | print "ok $test\n"; |
260 | |
261 | \$j->display_format('format' => undef); |
262 | EOS |
263 | |
264 | $test++; |
265 | push @script, <<EOS; |
09319b96 |
266 | my \$dj = "\$j"; \$dj =~ s/(\\d{14})\\d+i/\$1i/; |
267 | print "# j = \$dj (truncated for display)\n"; |
268 | print "not " unless \$dj eq "-0.5+0.86602540378443i"; |
16357284 |
269 | print "ok $test\n"; |
270 | |
271 | \$j->display_format('style' => 'polar', 'polar_pretty_print' => 0); |
272 | EOS |
273 | |
274 | $test++; |
275 | push @script, <<EOS; |
09319b96 |
276 | my \$dj = "\$j"; \$dj =~ s/(\\d{12})\\d+\]/\$1]/; |
277 | print "# j = \$dj (truncated for display)\n"; |
278 | print "not " unless \$dj eq "[1,2.094395102393]"; |
16357284 |
279 | print "ok $test\n"; |
280 | |
281 | \$j->display_format('style' => 'cartesian', 'format' => '(%.5g)'); |
282 | EOS |
283 | $test++; |
284 | push @script, <<EOS; |
285 | print "# j = \$j\n"; |
286 | print "not " unless "\$j" eq "(-0.5)+(0.86603)i"; |
287 | print "ok $test\n"; |
288 | EOS |
289 | } |
290 | |
291 | test_display_format(); |
292 | |
89d0527d |
293 | print "1..$test\n"; |
fe82cf6e |
294 | eval join '', @script; |
89d0527d |
295 | die $@ if $@; |
296 | |
0e505df1 |
297 | sub abop { |
298 | my ($op) = @_; |
299 | |
300 | push(@script, qq(print "# $op=\n";)); |
301 | } |
302 | |
89d0527d |
303 | sub test { |
304 | my ($op, $z, @args) = @_; |
0e505df1 |
305 | my ($baop) = 0; |
89d0527d |
306 | $test++; |
307 | my $i; |
0e505df1 |
308 | $baop = 1 if ($op =~ s/;=$//); |
89d0527d |
309 | for ($i = 0; $i < @args; $i++) { |
310 | $val = value($args[$i]); |
fe82cf6e |
311 | push @script, "\$z$i = $val;\n"; |
89d0527d |
312 | } |
313 | if (defined $z) { |
314 | $args = "'$op'"; # Really the value |
0c721ce2 |
315 | $try = "abs(\$z0 - \$z1) <= $eps ? \$z1 : \$z0"; |
fe82cf6e |
316 | push @script, "\$res = $try; "; |
317 | push @script, "check($test, $args[0], \$res, \$z$#args, $args);\n"; |
89d0527d |
318 | } else { |
319 | my ($try, $args); |
320 | if (@args == 2) { |
321 | $try = "$op \$z0"; |
322 | $args = "'$args[0]'"; |
323 | } else { |
324 | $try = ($op =~ /^\w/) ? "$op(\$z0, \$z1)" : "\$z0 $op \$z1"; |
325 | $args = "'$args[0]', '$args[1]'"; |
326 | } |
fe82cf6e |
327 | push @script, "\$res = $try; "; |
328 | push @script, "check($test, '$try', \$res, \$z$#args, $args);\n"; |
0e505df1 |
329 | if (@args > 2 and $baop) { # binary assignment ops |
330 | $test++; |
331 | # check the op= works |
332 | push @script, <<EOB; |
333 | { |
fb73857a |
334 | my \$za = cplx(ref \$z0 ? \@{\$z0->cartesian} : (\$z0, 0)); |
0e505df1 |
335 | |
336 | my (\$z1r, \$z1i) = ref \$z1 ? \@{\$z1->cartesian} : (\$z1, 0); |
337 | |
fb73857a |
338 | my \$zb = cplx(\$z1r, \$z1i); |
0e505df1 |
339 | |
340 | \$za $op= \$zb; |
341 | my (\$zbr, \$zbi) = \@{\$zb->cartesian}; |
342 | |
343 | check($test, '\$z0 $op= \$z1', \$za, \$z$#args, $args); |
344 | EOB |
345 | $test++; |
346 | # check that the rhs has not changed |
347 | push @script, qq(print "not " unless (\$zbr == \$z1r and \$zbi == \$z1i);); |
b42d0ec9 |
348 | push @script, qq(print "ok $test\\n";\n); |
0e505df1 |
349 | push @script, "}\n"; |
350 | } |
89d0527d |
351 | } |
352 | } |
353 | |
354 | sub set { |
355 | my ($set, $setref, $valref) = @_; |
356 | @{$setref} = (); |
357 | @{$valref} = (); |
358 | my @set = split(/;\s*/, $set); |
359 | my @res; |
360 | my $i; |
361 | for ($i = 0; $i < @set; $i++) { |
362 | push(@{$valref}, $set[$i]); |
363 | my $val = value($set[$i]); |
fe82cf6e |
364 | push @script, "\$s$i = $val;\n"; |
365 | push @{$setref}, "\$s$i"; |
89d0527d |
366 | } |
367 | } |
368 | |
369 | sub value { |
370 | local ($_) = @_; |
371 | if (/^\s*\((.*),(.*)\)/) { |
372 | return "cplx($1,$2)"; |
373 | } |
b42d0ec9 |
374 | elsif (/^\s*([\-\+]?(?:\d+(\.\d+)?|\.\d+)(?:[e[\-\+]\d+])?)/) { |
375 | return "cplx($1,0)"; |
376 | } |
89d0527d |
377 | elsif (/^\s*\[(.*),(.*)\]/) { |
378 | return "cplxe($1,$2)"; |
379 | } |
380 | elsif (/^\s*'(.*)'/) { |
381 | my $ex = $1; |
382 | $ex =~ s/\bz\b/$target/g; |
383 | $ex =~ s/\br\b/abs($target)/g; |
384 | $ex =~ s/\bt\b/arg($target)/g; |
385 | $ex =~ s/\ba\b/Re($target)/g; |
386 | $ex =~ s/\bb\b/Im($target)/g; |
387 | return $ex; |
388 | } |
389 | elsif (/^\s*"(.*)"/) { |
390 | return "\"$1\""; |
391 | } |
392 | return $_; |
393 | } |
394 | |
395 | sub check { |
396 | my ($test, $try, $got, $expected, @z) = @_; |
0c721ce2 |
397 | |
16357284 |
398 | print "# @_\n"; |
0c721ce2 |
399 | |
400 | if ("$got" eq "$expected" |
401 | || |
402 | ($expected =~ /^-?\d/ && $got == $expected) |
403 | || |
404 | (abs($got - $expected) < $eps) |
405 | ) { |
89d0527d |
406 | print "ok $test\n"; |
407 | } else { |
408 | print "not ok $test\n"; |
409 | my $args = (@z == 1) ? "z = $z[0]" : "z0 = $z[0], z1 = $z[1]"; |
410 | print "# '$try' expected: '$expected' got: '$got' for $args\n"; |
411 | } |
412 | } |
fb73857a |
413 | |
414 | sub addsq { |
415 | my ($z1, $z2) = @_; |
416 | return ($z1 + i*$z2) * ($z1 - i*$z2); |
417 | } |
418 | |
419 | sub subsq { |
420 | my ($z1, $z2) = @_; |
421 | return ($z1 + $z2) * ($z1 - $z2); |
422 | } |
423 | |
89d0527d |
424 | __END__ |
0e505df1 |
425 | &+;= |
89d0527d |
426 | (3,4):(3,4):(6,8) |
427 | (-3,4):(3,-4):(0,0) |
428 | (3,4):-3:(0,4) |
429 | 1:(4,2):(5,2) |
430 | [2,0]:[2,pi]:(0,0) |
431 | |
432 | &++ |
433 | (2,1):(3,1) |
434 | |
0e505df1 |
435 | &-;= |
89d0527d |
436 | (2,3):(-2,-3) |
437 | [2,pi/2]:[2,-(pi)/2] |
438 | 2:[2,0]:(0,0) |
439 | [3,0]:2:(1,0) |
440 | 3:(4,5):(-1,-5) |
441 | (4,5):3:(1,5) |
0e505df1 |
442 | (2,1):(3,5):(-1,-4) |
89d0527d |
443 | |
444 | &-- |
445 | (1,2):(0,2) |
446 | [2,pi]:[3,pi] |
447 | |
0e505df1 |
448 | &*;= |
89d0527d |
449 | (0,1):(0,1):(-1,0) |
450 | (4,5):(1,0):(4,5) |
451 | [2,2*pi/3]:(1,0):[2,2*pi/3] |
452 | 2:(0,1):(0,2) |
453 | (0,1):3:(0,3) |
454 | (0,1):(4,1):(-1,4) |
455 | (2,1):(4,-1):(9,2) |
456 | |
0e505df1 |
457 | &/;= |
89d0527d |
458 | (3,4):(3,4):(1,0) |
459 | (4,-5):1:(4,-5) |
460 | 1:(0,1):(0,-1) |
461 | (0,6):(0,2):(3,0) |
462 | (9,2):(4,-1):(2,1) |
463 | [4,pi]:[2,pi/2]:[2,pi/2] |
464 | [2,pi/2]:[4,pi]:[0.5,-(pi)/2] |
465 | |
0e505df1 |
466 | &**;= |
467 | (2,0):(3,0):(8,0) |
468 | (3,0):(2,0):(9,0) |
469 | (2,3):(4,0):(-119,-120) |
ace5de91 |
470 | (0,0):(1,0):(0,0) |
471 | (0,0):(2,3):(0,0) |
472 | (1,0):(0,0):(1,0) |
473 | (1,0):(1,0):(1,0) |
474 | (1,0):(2,3):(1,0) |
475 | (2,3):(0,0):(1,0) |
476 | (2,3):(1,0):(2,3) |
2820d885 |
477 | (0,0):(0,0):(1,0) |
0e505df1 |
478 | |
0c721ce2 |
479 | &Re |
480 | (3,4):3 |
481 | (-3,4):-3 |
482 | [1,pi/2]:0 |
483 | |
484 | &Im |
485 | (3,4):4 |
486 | (3,-4):-4 |
487 | [1,pi/2]:1 |
488 | |
89d0527d |
489 | &abs |
490 | (3,4):5 |
491 | (-3,4):5 |
492 | |
0c721ce2 |
493 | &arg |
494 | [2,0]:0 |
495 | [-2,0]:pi |
496 | |
89d0527d |
497 | &~ |
498 | (4,5):(4,-5) |
499 | (-3,4):(-3,-4) |
500 | [2,pi/2]:[2,-(pi)/2] |
501 | |
502 | &< |
503 | (3,4):(1,2):0 |
504 | (3,4):(3,2):0 |
505 | (3,4):(3,8):1 |
506 | (4,4):(5,129):1 |
507 | |
508 | &== |
509 | (3,4):(4,5):0 |
510 | (3,4):(3,5):0 |
511 | (3,4):(2,4):0 |
512 | (3,4):(3,4):1 |
513 | |
514 | &sqrt |
0c721ce2 |
515 | -9:(0,3) |
89d0527d |
516 | (-100,0):(0,10) |
517 | (16,-30):(5,-3) |
518 | |
519 | &stringify_cartesian |
520 | (-100,0):"-100" |
521 | (0,1):"i" |
522 | (4,-3):"4-3i" |
523 | (4,0):"4" |
524 | (-4,0):"-4" |
525 | (-2,4):"-2+4i" |
526 | (-2,-1):"-2-i" |
527 | |
528 | &stringify_polar |
529 | [-1, 0]:"[1,pi]" |
530 | [1, pi/3]:"[1,pi/3]" |
531 | [6, -2*pi/3]:"[6,-2pi/3]" |
532 | [0.5, -9*pi/11]:"[0.5,-9pi/11]" |
533 | |
534 | { (4,3); [3,2]; (-3,4); (0,2); [2,1] } |
535 | |
536 | |'z + ~z':'2*Re(z)' |
537 | |'z - ~z':'2*i*Im(z)' |
538 | |'z * ~z':'abs(z) * abs(z)' |
539 | |
8c03c583 |
540 | { (0.5, 0); (-0.5, 0); (2,3); [3,2]; (-3,2); (0,2); 3; 1.2; (-3, 0); (-2, -1); [2,1] } |
89d0527d |
541 | |
0c721ce2 |
542 | |'(root(z, 4))[1] ** 4':'z' |
543 | |'(root(z, 5))[3] ** 5':'z' |
544 | |'(root(z, 8))[7] ** 8':'z' |
89d0527d |
545 | |'abs(z)':'r' |
0c721ce2 |
546 | |'acot(z)':'acotan(z)' |
547 | |'acsc(z)':'acosec(z)' |
fb73857a |
548 | |'acsc(z)':'asin(1 / z)' |
549 | |'asec(z)':'acos(1 / z)' |
89d0527d |
550 | |'cbrt(z)':'cbrt(r) * exp(i * t/3)' |
89d0527d |
551 | |'cos(acos(z))':'z' |
fb73857a |
552 | |'addsq(cos(z), sin(z))':1 |
89d0527d |
553 | |'cos(z)':'cosh(i*z)' |
fb73857a |
554 | |'subsq(cosh(z), sinh(z))':1 |
0c721ce2 |
555 | |'cot(acot(z))':'z' |
556 | |'cot(z)':'1 / tan(z)' |
557 | |'cot(z)':'cotan(z)' |
558 | |'csc(acsc(z))':'z' |
559 | |'csc(z)':'1 / sin(z)' |
560 | |'csc(z)':'cosec(z)' |
89d0527d |
561 | |'exp(log(z))':'z' |
0c721ce2 |
562 | |'exp(z)':'exp(a) * exp(i * b)' |
563 | |'ln(z)':'log(z)' |
564 | |'log(exp(z))':'z' |
565 | |'log(z)':'log(r) + i*t' |
89d0527d |
566 | |'log10(z)':'log(z) / log(10)' |
89d0527d |
567 | |'logn(z, 2)':'log(z) / log(2)' |
0c721ce2 |
568 | |'logn(z, 3)':'log(z) / log(3)' |
569 | |'sec(asec(z))':'z' |
570 | |'sec(z)':'1 / cos(z)' |
571 | |'sin(asin(z))':'z' |
572 | |'sin(i * z)':'i * sinh(z)' |
573 | |'sqrt(z) * sqrt(z)':'z' |
574 | |'sqrt(z)':'sqrt(r) * exp(i * t/2)' |
575 | |'tan(atan(z))':'z' |
576 | |'z**z':'exp(z * log(z))' |
89d0527d |
577 | |
0c721ce2 |
578 | { (1,1); [1,0.5]; (-2, -1); 2; -3; (-1,0.5); (0,0.5); 0.5; (2, 0); (-1, -2) } |
89d0527d |
579 | |
89d0527d |
580 | |'cosh(acosh(z))':'z' |
0c721ce2 |
581 | |'coth(acoth(z))':'z' |
582 | |'coth(z)':'1 / tanh(z)' |
583 | |'coth(z)':'cotanh(z)' |
584 | |'csch(acsch(z))':'z' |
585 | |'csch(z)':'1 / sinh(z)' |
586 | |'csch(z)':'cosech(z)' |
587 | |'sech(asech(z))':'z' |
588 | |'sech(z)':'1 / cosh(z)' |
589 | |'sinh(asinh(z))':'z' |
89d0527d |
590 | |'tanh(atanh(z))':'z' |
89d0527d |
591 | |
0c721ce2 |
592 | { (0.2,-0.4); [1,0.5]; -1.2; (-1,0.5); 0.5; (1.1, 0) } |
89d0527d |
593 | |
89d0527d |
594 | |'acos(cos(z)) ** 2':'z * z' |
89d0527d |
595 | |'acosh(cosh(z)) ** 2':'z * z' |
0c721ce2 |
596 | |'acoth(z)':'acotanh(z)' |
597 | |'acoth(z)':'atanh(1 / z)' |
598 | |'acsch(z)':'acosech(z)' |
599 | |'acsch(z)':'asinh(1 / z)' |
600 | |'asech(z)':'acosh(1 / z)' |
601 | |'asin(sin(z))':'z' |
602 | |'asinh(sinh(z))':'z' |
603 | |'atan(tan(z))':'z' |
89d0527d |
604 | |'atanh(tanh(z))':'z' |
605 | |
fb73857a |
606 | &log |
607 | (-2.0,0):( 0.69314718055995, 3.14159265358979) |
608 | (-1.0,0):( 0 , 3.14159265358979) |
609 | (-0.5,0):( -0.69314718055995, 3.14159265358979) |
610 | ( 0.5,0):( -0.69314718055995, 0 ) |
611 | ( 1.0,0):( 0 , 0 ) |
612 | ( 2.0,0):( 0.69314718055995, 0 ) |
613 | |
614 | &log |
615 | ( 2, 3):( 1.28247467873077, 0.98279372324733) |
616 | (-2, 3):( 1.28247467873077, 2.15879893034246) |
617 | (-2,-3):( 1.28247467873077, -2.15879893034246) |
618 | ( 2,-3):( 1.28247467873077, -0.98279372324733) |
619 | |
0c721ce2 |
620 | &sin |
8c03c583 |
621 | (-2.0,0):( -0.90929742682568, 0 ) |
622 | (-1.0,0):( -0.84147098480790, 0 ) |
623 | (-0.5,0):( -0.47942553860420, 0 ) |
624 | ( 0.0,0):( 0 , 0 ) |
625 | ( 0.5,0):( 0.47942553860420, 0 ) |
626 | ( 1.0,0):( 0.84147098480790, 0 ) |
627 | ( 2.0,0):( 0.90929742682568, 0 ) |
628 | |
629 | &sin |
0c721ce2 |
630 | ( 2, 3):( 9.15449914691143, -4.16890695996656) |
631 | (-2, 3):( -9.15449914691143, -4.16890695996656) |
632 | (-2,-3):( -9.15449914691143, 4.16890695996656) |
633 | ( 2,-3):( 9.15449914691143, 4.16890695996656) |
634 | |
635 | &cos |
8c03c583 |
636 | (-2.0,0):( -0.41614683654714, 0 ) |
637 | (-1.0,0):( 0.54030230586814, 0 ) |
638 | (-0.5,0):( 0.87758256189037, 0 ) |
639 | ( 0.0,0):( 1 , 0 ) |
640 | ( 0.5,0):( 0.87758256189037, 0 ) |
641 | ( 1.0,0):( 0.54030230586814, 0 ) |
642 | ( 2.0,0):( -0.41614683654714, 0 ) |
643 | |
644 | &cos |
0c721ce2 |
645 | ( 2, 3):( -4.18962569096881, -9.10922789375534) |
646 | (-2, 3):( -4.18962569096881, 9.10922789375534) |
647 | (-2,-3):( -4.18962569096881, -9.10922789375534) |
648 | ( 2,-3):( -4.18962569096881, 9.10922789375534) |
649 | |
650 | &tan |
8c03c583 |
651 | (-2.0,0):( 2.18503986326152, 0 ) |
652 | (-1.0,0):( -1.55740772465490, 0 ) |
653 | (-0.5,0):( -0.54630248984379, 0 ) |
654 | ( 0.0,0):( 0 , 0 ) |
655 | ( 0.5,0):( 0.54630248984379, 0 ) |
656 | ( 1.0,0):( 1.55740772465490, 0 ) |
657 | ( 2.0,0):( -2.18503986326152, 0 ) |
658 | |
659 | &tan |
0c721ce2 |
660 | ( 2, 3):( -0.00376402564150, 1.00323862735361) |
661 | (-2, 3):( 0.00376402564150, 1.00323862735361) |
662 | (-2,-3):( 0.00376402564150, -1.00323862735361) |
663 | ( 2,-3):( -0.00376402564150, -1.00323862735361) |
664 | |
665 | &sec |
8c03c583 |
666 | (-2.0,0):( -2.40299796172238, 0 ) |
667 | (-1.0,0):( 1.85081571768093, 0 ) |
668 | (-0.5,0):( 1.13949392732455, 0 ) |
669 | ( 0.0,0):( 1 , 0 ) |
670 | ( 0.5,0):( 1.13949392732455, 0 ) |
671 | ( 1.0,0):( 1.85081571768093, 0 ) |
672 | ( 2.0,0):( -2.40299796172238, 0 ) |
673 | |
674 | &sec |
0c721ce2 |
675 | ( 2, 3):( -0.04167496441114, 0.09061113719624) |
676 | (-2, 3):( -0.04167496441114, -0.09061113719624) |
677 | (-2,-3):( -0.04167496441114, 0.09061113719624) |
678 | ( 2,-3):( -0.04167496441114, -0.09061113719624) |
679 | |
680 | &csc |
8c03c583 |
681 | (-2.0,0):( -1.09975017029462, 0 ) |
682 | (-1.0,0):( -1.18839510577812, 0 ) |
683 | (-0.5,0):( -2.08582964293349, 0 ) |
684 | ( 0.5,0):( 2.08582964293349, 0 ) |
685 | ( 1.0,0):( 1.18839510577812, 0 ) |
686 | ( 2.0,0):( 1.09975017029462, 0 ) |
687 | |
688 | &csc |
0c721ce2 |
689 | ( 2, 3):( 0.09047320975321, 0.04120098628857) |
690 | (-2, 3):( -0.09047320975321, 0.04120098628857) |
691 | (-2,-3):( -0.09047320975321, -0.04120098628857) |
692 | ( 2,-3):( 0.09047320975321, -0.04120098628857) |
693 | |
694 | &cot |
8c03c583 |
695 | (-2.0,0):( 0.45765755436029, 0 ) |
696 | (-1.0,0):( -0.64209261593433, 0 ) |
697 | (-0.5,0):( -1.83048772171245, 0 ) |
698 | ( 0.5,0):( 1.83048772171245, 0 ) |
699 | ( 1.0,0):( 0.64209261593433, 0 ) |
700 | ( 2.0,0):( -0.45765755436029, 0 ) |
701 | |
702 | &cot |
0c721ce2 |
703 | ( 2, 3):( -0.00373971037634, -0.99675779656936) |
704 | (-2, 3):( 0.00373971037634, -0.99675779656936) |
705 | (-2,-3):( 0.00373971037634, 0.99675779656936) |
706 | ( 2,-3):( -0.00373971037634, 0.99675779656936) |
707 | |
708 | &asin |
8c03c583 |
709 | (-2.0,0):( -1.57079632679490, 1.31695789692482) |
710 | (-1.0,0):( -1.57079632679490, 0 ) |
711 | (-0.5,0):( -0.52359877559830, 0 ) |
712 | ( 0.0,0):( 0 , 0 ) |
713 | ( 0.5,0):( 0.52359877559830, 0 ) |
714 | ( 1.0,0):( 1.57079632679490, 0 ) |
715 | ( 2.0,0):( 1.57079632679490, -1.31695789692482) |
716 | |
717 | &asin |
0c721ce2 |
718 | ( 2, 3):( 0.57065278432110, 1.98338702991654) |
719 | (-2, 3):( -0.57065278432110, 1.98338702991654) |
720 | (-2,-3):( -0.57065278432110, -1.98338702991654) |
721 | ( 2,-3):( 0.57065278432110, -1.98338702991654) |
722 | |
723 | &acos |
8c03c583 |
724 | (-2.0,0):( 3.14159265358979, -1.31695789692482) |
725 | (-1.0,0):( 3.14159265358979, 0 ) |
726 | (-0.5,0):( 2.09439510239320, 0 ) |
727 | ( 0.0,0):( 1.57079632679490, 0 ) |
728 | ( 0.5,0):( 1.04719755119660, 0 ) |
729 | ( 1.0,0):( 0 , 0 ) |
730 | ( 2.0,0):( 0 , 1.31695789692482) |
731 | |
732 | &acos |
0c721ce2 |
733 | ( 2, 3):( 1.00014354247380, -1.98338702991654) |
734 | (-2, 3):( 2.14144911111600, -1.98338702991654) |
735 | (-2,-3):( 2.14144911111600, 1.98338702991654) |
736 | ( 2,-3):( 1.00014354247380, 1.98338702991654) |
737 | |
738 | &atan |
8c03c583 |
739 | (-2.0,0):( -1.10714871779409, 0 ) |
740 | (-1.0,0):( -0.78539816339745, 0 ) |
741 | (-0.5,0):( -0.46364760900081, 0 ) |
742 | ( 0.0,0):( 0 , 0 ) |
743 | ( 0.5,0):( 0.46364760900081, 0 ) |
744 | ( 1.0,0):( 0.78539816339745, 0 ) |
745 | ( 2.0,0):( 1.10714871779409, 0 ) |
746 | |
747 | &atan |
0c721ce2 |
748 | ( 2, 3):( 1.40992104959658, 0.22907268296854) |
749 | (-2, 3):( -1.40992104959658, 0.22907268296854) |
750 | (-2,-3):( -1.40992104959658, -0.22907268296854) |
751 | ( 2,-3):( 1.40992104959658, -0.22907268296854) |
752 | |
753 | &asec |
8c03c583 |
754 | (-2.0,0):( 2.09439510239320, 0 ) |
755 | (-1.0,0):( 3.14159265358979, 0 ) |
756 | (-0.5,0):( 3.14159265358979, -1.31695789692482) |
757 | ( 0.5,0):( 0 , 1.31695789692482) |
758 | ( 1.0,0):( 0 , 0 ) |
759 | ( 2.0,0):( 1.04719755119660, 0 ) |
760 | |
761 | &asec |
0c721ce2 |
762 | ( 2, 3):( 1.42041072246703, 0.23133469857397) |
763 | (-2, 3):( 1.72118193112276, 0.23133469857397) |
764 | (-2,-3):( 1.72118193112276, -0.23133469857397) |
765 | ( 2,-3):( 1.42041072246703, -0.23133469857397) |
766 | |
767 | &acsc |
8c03c583 |
768 | (-2.0,0):( -0.52359877559830, 0 ) |
769 | (-1.0,0):( -1.57079632679490, 0 ) |
770 | (-0.5,0):( -1.57079632679490, 1.31695789692482) |
771 | ( 0.5,0):( 1.57079632679490, -1.31695789692482) |
772 | ( 1.0,0):( 1.57079632679490, 0 ) |
773 | ( 2.0,0):( 0.52359877559830, 0 ) |
774 | |
775 | &acsc |
0c721ce2 |
776 | ( 2, 3):( 0.15038560432786, -0.23133469857397) |
777 | (-2, 3):( -0.15038560432786, -0.23133469857397) |
778 | (-2,-3):( -0.15038560432786, 0.23133469857397) |
779 | ( 2,-3):( 0.15038560432786, 0.23133469857397) |
780 | |
781 | &acot |
8c03c583 |
782 | (-2.0,0):( -0.46364760900081, 0 ) |
783 | (-1.0,0):( -0.78539816339745, 0 ) |
784 | (-0.5,0):( -1.10714871779409, 0 ) |
785 | ( 0.5,0):( 1.10714871779409, 0 ) |
786 | ( 1.0,0):( 0.78539816339745, 0 ) |
787 | ( 2.0,0):( 0.46364760900081, 0 ) |
788 | |
789 | &acot |
0c721ce2 |
790 | ( 2, 3):( 0.16087527719832, -0.22907268296854) |
791 | (-2, 3):( -0.16087527719832, -0.22907268296854) |
792 | (-2,-3):( -0.16087527719832, 0.22907268296854) |
793 | ( 2,-3):( 0.16087527719832, 0.22907268296854) |
794 | |
795 | &sinh |
8c03c583 |
796 | (-2.0,0):( -3.62686040784702, 0 ) |
797 | (-1.0,0):( -1.17520119364380, 0 ) |
798 | (-0.5,0):( -0.52109530549375, 0 ) |
799 | ( 0.0,0):( 0 , 0 ) |
800 | ( 0.5,0):( 0.52109530549375, 0 ) |
801 | ( 1.0,0):( 1.17520119364380, 0 ) |
802 | ( 2.0,0):( 3.62686040784702, 0 ) |
803 | |
804 | &sinh |
0c721ce2 |
805 | ( 2, 3):( -3.59056458998578, 0.53092108624852) |
806 | (-2, 3):( 3.59056458998578, 0.53092108624852) |
807 | (-2,-3):( 3.59056458998578, -0.53092108624852) |
808 | ( 2,-3):( -3.59056458998578, -0.53092108624852) |
809 | |
810 | &cosh |
8c03c583 |
811 | (-2.0,0):( 3.76219569108363, 0 ) |
812 | (-1.0,0):( 1.54308063481524, 0 ) |
813 | (-0.5,0):( 1.12762596520638, 0 ) |
814 | ( 0.0,0):( 1 , 0 ) |
815 | ( 0.5,0):( 1.12762596520638, 0 ) |
816 | ( 1.0,0):( 1.54308063481524, 0 ) |
817 | ( 2.0,0):( 3.76219569108363, 0 ) |
818 | |
819 | &cosh |
0c721ce2 |
820 | ( 2, 3):( -3.72454550491532, 0.51182256998738) |
821 | (-2, 3):( -3.72454550491532, -0.51182256998738) |
822 | (-2,-3):( -3.72454550491532, 0.51182256998738) |
823 | ( 2,-3):( -3.72454550491532, -0.51182256998738) |
824 | |
825 | &tanh |
8c03c583 |
826 | (-2.0,0):( -0.96402758007582, 0 ) |
827 | (-1.0,0):( -0.76159415595576, 0 ) |
828 | (-0.5,0):( -0.46211715726001, 0 ) |
829 | ( 0.0,0):( 0 , 0 ) |
830 | ( 0.5,0):( 0.46211715726001, 0 ) |
831 | ( 1.0,0):( 0.76159415595576, 0 ) |
832 | ( 2.0,0):( 0.96402758007582, 0 ) |
833 | |
834 | &tanh |
0c721ce2 |
835 | ( 2, 3):( 0.96538587902213, -0.00988437503832) |
836 | (-2, 3):( -0.96538587902213, -0.00988437503832) |
837 | (-2,-3):( -0.96538587902213, 0.00988437503832) |
838 | ( 2,-3):( 0.96538587902213, 0.00988437503832) |
839 | |
840 | &sech |
8c03c583 |
841 | (-2.0,0):( 0.26580222883408, 0 ) |
842 | (-1.0,0):( 0.64805427366389, 0 ) |
843 | (-0.5,0):( 0.88681888397007, 0 ) |
844 | ( 0.0,0):( 1 , 0 ) |
845 | ( 0.5,0):( 0.88681888397007, 0 ) |
846 | ( 1.0,0):( 0.64805427366389, 0 ) |
847 | ( 2.0,0):( 0.26580222883408, 0 ) |
848 | |
849 | &sech |
0c721ce2 |
850 | ( 2, 3):( -0.26351297515839, -0.03621163655877) |
851 | (-2, 3):( -0.26351297515839, 0.03621163655877) |
852 | (-2,-3):( -0.26351297515839, -0.03621163655877) |
853 | ( 2,-3):( -0.26351297515839, 0.03621163655877) |
854 | |
855 | &csch |
8c03c583 |
856 | (-2.0,0):( -0.27572056477178, 0 ) |
857 | (-1.0,0):( -0.85091812823932, 0 ) |
858 | (-0.5,0):( -1.91903475133494, 0 ) |
859 | ( 0.5,0):( 1.91903475133494, 0 ) |
860 | ( 1.0,0):( 0.85091812823932, 0 ) |
861 | ( 2.0,0):( 0.27572056477178, 0 ) |
862 | |
863 | &csch |
0c721ce2 |
864 | ( 2, 3):( -0.27254866146294, -0.04030057885689) |
865 | (-2, 3):( 0.27254866146294, -0.04030057885689) |
866 | (-2,-3):( 0.27254866146294, 0.04030057885689) |
867 | ( 2,-3):( -0.27254866146294, 0.04030057885689) |
868 | |
869 | &coth |
8c03c583 |
870 | (-2.0,0):( -1.03731472072755, 0 ) |
871 | (-1.0,0):( -1.31303528549933, 0 ) |
872 | (-0.5,0):( -2.16395341373865, 0 ) |
873 | ( 0.5,0):( 2.16395341373865, 0 ) |
874 | ( 1.0,0):( 1.31303528549933, 0 ) |
875 | ( 2.0,0):( 1.03731472072755, 0 ) |
876 | |
877 | &coth |
0c721ce2 |
878 | ( 2, 3):( 1.03574663776500, 0.01060478347034) |
879 | (-2, 3):( -1.03574663776500, 0.01060478347034) |
880 | (-2,-3):( -1.03574663776500, -0.01060478347034) |
881 | ( 2,-3):( 1.03574663776500, -0.01060478347034) |
882 | |
883 | &asinh |
8c03c583 |
884 | (-2.0,0):( -1.44363547517881, 0 ) |
885 | (-1.0,0):( -0.88137358701954, 0 ) |
886 | (-0.5,0):( -0.48121182505960, 0 ) |
887 | ( 0.0,0):( 0 , 0 ) |
888 | ( 0.5,0):( 0.48121182505960, 0 ) |
889 | ( 1.0,0):( 0.88137358701954, 0 ) |
890 | ( 2.0,0):( 1.44363547517881, 0 ) |
891 | |
892 | &asinh |
0c721ce2 |
893 | ( 2, 3):( 1.96863792579310, 0.96465850440760) |
894 | (-2, 3):( -1.96863792579310, 0.96465850440761) |
895 | (-2,-3):( -1.96863792579310, -0.96465850440761) |
896 | ( 2,-3):( 1.96863792579310, -0.96465850440760) |
897 | |
898 | &acosh |
8c03c583 |
899 | (-2.0,0):( -1.31695789692482, 3.14159265358979) |
900 | (-1.0,0):( 0, 3.14159265358979) |
901 | (-0.5,0):( 0, 2.09439510239320) |
902 | ( 0.0,0):( 0, 1.57079632679490) |
903 | ( 0.5,0):( 0, 1.04719755119660) |
904 | ( 1.0,0):( 0 , 0 ) |
905 | ( 2.0,0):( 1.31695789692482, 0 ) |
906 | |
907 | &acosh |
0c721ce2 |
908 | ( 2, 3):( 1.98338702991654, 1.00014354247380) |
909 | (-2, 3):( -1.98338702991653, -2.14144911111600) |
910 | (-2,-3):( -1.98338702991653, 2.14144911111600) |
911 | ( 2,-3):( 1.98338702991654, -1.00014354247380) |
912 | |
913 | &atanh |
8c03c583 |
914 | (-2.0,0):( -0.54930614433405, 1.57079632679490) |
915 | (-0.5,0):( -0.54930614433405, 0 ) |
916 | ( 0.0,0):( 0 , 0 ) |
917 | ( 0.5,0):( 0.54930614433405, 0 ) |
918 | ( 2.0,0):( 0.54930614433405, 1.57079632679490) |
919 | |
920 | &atanh |
0c721ce2 |
921 | ( 2, 3):( 0.14694666622553, 1.33897252229449) |
922 | (-2, 3):( -0.14694666622553, 1.33897252229449) |
923 | (-2,-3):( -0.14694666622553, -1.33897252229449) |
924 | ( 2,-3):( 0.14694666622553, -1.33897252229449) |
925 | |
926 | &asech |
8c03c583 |
927 | (-2.0,0):( 0 , 2.09439510239320) |
928 | (-1.0,0):( 0 , 3.14159265358979) |
929 | (-0.5,0):( -1.31695789692482, 3.14159265358979) |
930 | ( 0.5,0):( 1.31695789692482, 0 ) |
931 | ( 1.0,0):( 0 , 0 ) |
932 | ( 2.0,0):( 0 , 1.04719755119660) |
933 | |
934 | &asech |
0c721ce2 |
935 | ( 2, 3):( 0.23133469857397, -1.42041072246703) |
936 | (-2, 3):( -0.23133469857397, 1.72118193112276) |
937 | (-2,-3):( -0.23133469857397, -1.72118193112276) |
938 | ( 2,-3):( 0.23133469857397, 1.42041072246703) |
939 | |
940 | &acsch |
8c03c583 |
941 | (-2.0,0):( -0.48121182505960, 0 ) |
942 | (-1.0,0):( -0.88137358701954, 0 ) |
943 | (-0.5,0):( -1.44363547517881, 0 ) |
944 | ( 0.5,0):( 1.44363547517881, 0 ) |
945 | ( 1.0,0):( 0.88137358701954, 0 ) |
946 | ( 2.0,0):( 0.48121182505960, 0 ) |
947 | |
948 | &acsch |
0c721ce2 |
949 | ( 2, 3):( 0.15735549884499, -0.22996290237721) |
950 | (-2, 3):( -0.15735549884499, -0.22996290237721) |
951 | (-2,-3):( -0.15735549884499, 0.22996290237721) |
952 | ( 2,-3):( 0.15735549884499, 0.22996290237721) |
953 | |
954 | &acoth |
8c03c583 |
955 | (-2.0,0):( -0.54930614433405, 0 ) |
956 | (-0.5,0):( -0.54930614433405, 1.57079632679490) |
957 | ( 0.5,0):( 0.54930614433405, 1.57079632679490) |
958 | ( 2.0,0):( 0.54930614433405, 0 ) |
959 | |
960 | &acoth |
0c721ce2 |
961 | ( 2, 3):( 0.14694666622553, -0.23182380450040) |
962 | (-2, 3):( -0.14694666622553, -0.23182380450040) |
963 | (-2,-3):( -0.14694666622553, 0.23182380450040) |
964 | ( 2,-3):( 0.14694666622553, 0.23182380450040) |
965 | |
966 | # eof |