return cplx(0, CORE::atan2(CORE::sqrt(1 - $re*$re), $re))
if CORE::abs($re) < 1;
}
- my $s = &sqrt($z*$z - 1);
- my $t = $z + $s;
- $t = 1/(2*$s) if $t == 0 || $t && &abs(cosh(&log($t)) - $z) > $eps;
- return &log($t);
+ my $t = &sqrt($z * $z - 1) + $z;
+ # Try MacLaurin if looking bad.
+ $t = 1/(2 * $z) - 1/(8 * $z**3) + 1/(16 * $z**5) - 5/(128 * $z**7)
+ if $t == 0;
+ my $u = &log($t);
+ $u->Im(-$u->Im) if $im == 0;
+ return $re < 0 ? -$u : $u;
}
#
my $t = $z + CORE::sqrt($z*$z + 1);
return CORE::log($t) if $t;
}
- my $s = &sqrt($z*$z + 1);
- my $t = $z + $s;
- # Try Taylor series if looking bad.
- $t = 1/(2*$s) if $t == 0 || $t && &abs(sinh(&log($t)) - $z) > $eps;
+ my $t = &sqrt($z * $z + 1) + $z;
+ # Try MacLaurin if looking bad.
+ $t = 1/(2 * $z) - 1/(8 * $z**3) + 1/(16 * $z**5) - 5/(128 * $z**7)
+ if $t == 0;
return &log($t);
}
if ($format{polar_pretty_print}) {
my ($a, $b);
- for $a (2, 3, 4, 6, 8, 12, 16, 24, 30, 32, 36, 48, 60, 64, 72) {
+ for $a (2..9) {
$b = $t * $a / pi;
if (int($b) == $b) {
$b = $b < 0 ? "-" : "" if CORE::abs($b) == 1;
print "j = $j\n"; # Prints "j = -0.5+0.866025403784439i"
The polar style attempts to emphasize arguments like I<k*pi/n>
-(where I<n> is a positive integer and I<k> an integer within [-9,+9]),
+(where I<n> is a positive integer and I<k> an integer within [-9, +9]),
this is called I<polar pretty-printing>.
=head2 CHANGED IN PERL 5.6
( 2,-3):( 1.96863792579310, -0.96465850440760)
&acosh
-(-2.0,0):( -1.31695789692482, 3.14159265358979)
+(-2.0,0):( 1.31695789692482, 3.14159265358979)
(-1.0,0):( 0, 3.14159265358979)
(-0.5,0):( 0, 2.09439510239320)
( 0.0,0):( 0, 1.57079632679490)
&acosh
( 2, 3):( 1.98338702991654, 1.00014354247380)
-(-2, 3):( -1.98338702991653, -2.14144911111600)
-(-2,-3):( -1.98338702991653, 2.14144911111600)
+(-2, 3):( 1.98338702991653, 2.14144911111600)
+(-2,-3):( 1.98338702991653, -2.14144911111600)
( 2,-3):( 1.98338702991654, -1.00014354247380)
&atanh
&asech
(-2.0,0):( 0 , 2.09439510239320)
(-1.0,0):( 0 , 3.14159265358979)
-(-0.5,0):( -1.31695789692482, 3.14159265358979)
+(-0.5,0):( 1.31695789692482, 3.14159265358979)
( 0.5,0):( 1.31695789692482, 0 )
( 1.0,0):( 0 , 0 )
( 2.0,0):( 0 , 1.04719755119660)
&asech
( 2, 3):( 0.23133469857397, -1.42041072246703)
-(-2, 3):( -0.23133469857397, 1.72118193112276)
-(-2,-3):( -0.23133469857397, -1.72118193112276)
+(-2, 3):( 0.23133469857397, -1.72118193112276)
+(-2,-3):( 0.23133469857397, 1.72118193112276)
( 2,-3):( 0.23133469857397, 1.42041072246703)
&acsch