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