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