my ($x, $y) = @{$z->cartesian};
my $ex = exp($x);
my $ex_1 = 1 / $ex;
- return ($ex + $ex_1)/2 if $real;
+ return cplx(0.5 * ($ex + $ex_1), 0) if $real;
return (ref $z)->make(cos($y) * ($ex + $ex_1)/2,
sin($y) * ($ex - $ex_1)/2);
}
my ($x, $y) = @{$z->cartesian};
my $ex = exp($x);
my $ex_1 = 1 / $ex;
- return ($ex - $ex_1)/2 if $real;
+ return cplx(0.5 * ($ex - $ex_1), 0) if $real;
return (ref $z)->make(cos($y) * ($ex - $ex_1)/2,
sin($y) * ($ex + $ex_1)/2);
}
(root(z, n))[k] = r**(1/n) * exp(i * (t + 2*k*pi)/n)
-The I<spaceship> comparison operator is also defined. In order to
-ensure its restriction to real numbers is conform to what you would
-expect, the comparison is run on the real part of the complex number
-first, and imaginary parts are compared only when the real parts
-match.
+The I<spaceship> comparison operator, E<lt>=E<gt>, is also defined. In
+order to ensure its restriction to real numbers is conform to what you
+would expect, the comparison is run on the real part of the complex
+number first, and imaginary parts are compared only when the real
+parts match.
=head1 CREATION
|'z - ~z':'2*i*Im(z)'
|'z * ~z':'abs(z) * abs(z)'
-{ (2,3); [3,2]; (-3,2); (0,2); 3; 1.2; -3; (-3, 0); (-2, -1); [2,1] }
+{ (2,3); [3,2]; (-3,2); (0,2); 3; 1.2; (-3, 0); (-2, -1); [2,1] }
|'(root(z, 4))[1] ** 4':'z'
|'(root(z, 5))[3] ** 5':'z'