Arithmetic/Complex: Difference between revisions

→‎{{header|Perl}}: Add complex conjugate.
(→‎{{header|Ruby}}: Add complex conjugate. Use Complex::I, 1.quo a.)
(→‎{{header|Perl}}: Add complex conjugate.)
Line 1,728:
=={{header|Perl}}==
The <code>Math::Complex</code> module implements complex arithmetic.
<lang perl>myuse $a = 1 + 1*iMath::Complex;
my $a = 1 + 1*i;
my $b = 3.14159 + 1.25*i;
 
print "$_\n" foreach $a + $b, $a * $b, 1 / $a, -$a;</lang>
$a + $b, # addition
$a * $b, # multiplication
-$a, # negation
1 / $a, # multiplicative inverse
~$a; # complex conjugate</lang>
 
=={{header|Perl 6}}==
Anonymous user