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