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