.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Math::Cephes::Complex 3pm" .TH Math::Cephes::Complex 3pm "2021-06-22" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" .Vb 1 \& Math::Cephes::Complex \- Perl interface to the cephes complex number routines .Ve .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& use Math::Cephes::Complex qw(cmplx); \& my $z1 = cmplx(2,3); # $z1 = 2 + 3 i \& my $z2 = cmplx(3,4); # $z2 = 3 + 4 i \& my $z3 = $z1\->radd($z2); # $z3 = $z1 + $z2 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is a layer on top of the basic routines in the cephes math library to handle complex numbers. A complex number is created via any of the following syntaxes: .PP .Vb 3 \& my $f = Math::Cephes::Complex\->new(3, 2); # $f = 3 + 2 i \& my $g = new Math::Cephes::Complex(5, 3); # $g = 5 + 3 i \& my $h = cmplx(7, 5); # $h = 7 + 5 i .Ve .PP the last one being available by importing \fIcmplx\fR. If no arguments are specified, as in .PP .Vb 1 \& my $h = cmplx(); .Ve .PP then the defaults \f(CW$z\fR = 0 + 0 i are assumed. The real and imaginary part of a complex number are represented respectively by .PP .Vb 1 \& $f\->{r}; $f\->{i}; .Ve .PP or, as methods, .PP .Vb 1 \& $f\->r; $f\->i; .Ve .PP and can be set according to .PP .Vb 1 \& $f\->{r} = 4; $f\->{i} = 9; .Ve .PP or, again, as methods, .PP .Vb 1 \& $f\->r(4); $f\->i(9); .Ve .PP The complex number can be printed out as .PP .Vb 1 \& print $f\->as_string; .Ve .PP A summary of the usage is as follows. .IP "\fIcsin\fR: Complex circular sine" 4 .IX Item "csin: Complex circular sine" .Vb 1 \& SYNOPSIS: \& \& # void csin(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->csin; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& If \& z = x + iy, \& \& then \& \& w = sin x cosh y + i cos x sinh y. .Ve .IP "\fIccos\fR: Complex circular cosine" 4 .IX Item "ccos: Complex circular cosine" .Vb 1 \& SYNOPSIS: \& \& # void ccos(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->ccos; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& If \& z = x + iy, \& \& then \& \& w = cos x cosh y \- i sin x sinh y. .Ve .IP "\fIctan\fR: Complex circular tangent" 4 .IX Item "ctan: Complex circular tangent" .Vb 1 \& SYNOPSIS: \& \& # void ctan(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->ctan; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& If \& z = x + iy, \& \& then \& \& sin 2x + i sinh 2y \& w = \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-. \& cos 2x + cosh 2y \& \& On the real axis the denominator is zero at odd multiples \& of PI/2. The denominator is evaluated by its Taylor \& series near these points. .Ve .IP "\fIccot\fR: Complex circular cotangent" 4 .IX Item "ccot: Complex circular cotangent" .Vb 1 \& SYNOPSIS: \& \& # void ccot(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->ccot; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& If \& z = x + iy, \& \& then \& \& sin 2x \- i sinh 2y \& w = \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-. \& cosh 2y \- cos 2x \& \& On the real axis, the denominator has zeros at even \& multiples of PI/2. Near these points it is evaluated \& by a Taylor series. .Ve .IP "\fIcasin\fR: Complex circular arc sine" 4 .IX Item "casin: Complex circular arc sine" .Vb 1 \& SYNOPSIS: \& \& # void casin(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->casin; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& Inverse complex sine: \& \& 2 \& w = \-i clog( iz + csqrt( 1 \- z ) ). .Ve .IP "\fIcacos\fR: Complex circular arc cosine" 4 .IX Item "cacos: Complex circular arc cosine" .Vb 1 \& SYNOPSIS: \& \& # void cacos(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->cacos; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& w = arccos z = PI/2 \- arcsin z. .Ve .IP "\fIcatan\fR: Complex circular arc tangent" 4 .IX Item "catan: Complex circular arc tangent" .Vb 1 \& SYNOPSIS: \& \& # void catan(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->catan; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& If \& z = x + iy, \& \& then \& 1 ( 2x ) \& Re w = \- arctan(\-\-\-\-\-\-\-\-\-\-\-) + k PI \& 2 ( 2 2) \& (1 \- x \- y ) \& \& ( 2 2) \& 1 (x + (y+1) ) \& Im w = \- log(\-\-\-\-\-\-\-\-\-\-\-\-) \& 4 ( 2 2) \& (x + (y\-1) ) \& \& Where k is an arbitrary integer. .Ve .IP "\fIcsinh\fR: Complex hyperbolic sine" 4 .IX Item "csinh: Complex hyperbolic sine" .Vb 1 \& SYNOPSIS: \& \& # void csinh(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->csinh; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& \& DESCRIPTION: \& \& csinh z = (cexp(z) \- cexp(\-z))/2 \& = sinh x * cos y + i cosh x * sin y . .Ve .IP "\fIcasinh\fR: Complex inverse hyperbolic sine" 4 .IX Item "casinh: Complex inverse hyperbolic sine" .Vb 1 \& SYNOPSIS: \& \& # void casinh(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->casinh; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& casinh z = \-i casin iz . .Ve .IP "\fIccosh\fR: Complex hyperbolic cosine" 4 .IX Item "ccosh: Complex hyperbolic cosine" .Vb 1 \& SYNOPSIS: \& \& # void ccosh(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->ccosh; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& ccosh(z) = cosh x cos y + i sinh x sin y . .Ve .IP "\fIcacosh\fR: Complex inverse hyperbolic cosine" 4 .IX Item "cacosh: Complex inverse hyperbolic cosine" .Vb 1 \& SYNOPSIS: \& \& # void cacosh(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->cacosh; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& acosh z = i acos z . .Ve .IP "\fIctanh\fR: Complex hyperbolic tangent" 4 .IX Item "ctanh: Complex hyperbolic tangent" .Vb 1 \& SYNOPSIS: \& \& # void ctanh(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->ctanh; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& tanh z = (sinh 2x + i sin 2y) / (cosh 2x + cos 2y) . .Ve .IP "\fIcatanh\fR: Complex inverse hyperbolic tangent" 4 .IX Item "catanh: Complex inverse hyperbolic tangent" .Vb 1 \& SYNOPSIS: \& \& # void catanh(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->catanh; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& Inverse tanh, equal to \-i catan (iz); .Ve .IP "\fIcpow\fR: Complex power function" 4 .IX Item "cpow: Complex power function" .Vb 1 \& SYNOPSIS: \& \& # void cpow(); \& # cmplx a, z, w; \& \& $a = cmplx(5, 6); # $z = 5 + 6 i \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $a\->cpow($z); \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& Raises complex A to the complex Zth power. \& Definition is per AMS55 # 4.2.8, \& analytically equivalent to cpow(a,z) = cexp(z clog(a)). .Ve .IP "\fIcmplx\fR: Complex number arithmetic" 4 .IX Item "cmplx: Complex number arithmetic" .Vb 1 \& SYNOPSIS: \& \& # typedef struct { \& # double r; real part \& # double i; imaginary part \& # }cmplx; \& \& # cmplx *a, *b, *c; \& \& $a = cmplx(3, 5); # $a = 3 + 5 i \& $b = cmplx(2, 3); # $b = 2 + 3 i \& \& $c = $a\->cadd( $b ); # c = a + b \& $c = $a\->csub( $b ); # c = a \- b \& $c = $a\->cmul( $b ); # c = a * b \& $c = $a\->cdiv( $b ); # c = a / b \& $c = $a\->cneg; # c = \-a \& $c = $a\->cmov; # c = a \& \& print $c\->{r}, \*(Aq \*(Aq, $c\->{i}; # prints real and imaginary parts of $c \& print $c\->as_string; # prints $c as Re($c) + i Im($c) \& \& \& DESCRIPTION: \& \& Addition: \& c.r = b.r + a.r \& c.i = b.i + a.i \& \& Subtraction: \& c.r = b.r \- a.r \& c.i = b.i \- a.i \& \& Multiplication: \& c.r = b.r * a.r \- b.i * a.i \& c.i = b.r * a.i + b.i * a.r \& \& Division: \& d = a.r * a.r + a.i * a.i \& c.r = (b.r * a.r + b.i * a.i)/d \& c.i = (b.i * a.r \- b.r * a.i)/d .Ve .IP "\fIcabs\fR: Complex absolute value" 4 .IX Item "cabs: Complex absolute value" .Vb 1 \& SYNOPSIS: \& \& # double a, cabs(); \& # cmplx z; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $a = cabs( $z ); \& \& DESCRIPTION: \& \& If z = x + iy \& \& then \& \& a = sqrt( x**2 + y**2 ). \& \& Overflow and underflow are avoided by testing the magnitudes \& of x and y before squaring. If either is outside half of \& the floating point full scale range, both are rescaled. .Ve .IP "\fIcsqrt\fR: Complex square root" 4 .IX Item "csqrt: Complex square root" .Vb 1 \& SYNOPSIS: \& \& # void csqrt(); \& # cmplx z, w; \& \& $z = cmplx(2, 3); # $z = 2 + 3 i \& $w = $z\->csqrt; \& print $w\->{r}, \*(Aq \*(Aq, $w\->{i}; # prints real and imaginary parts of $w \& print $w\->as_string; # prints $w as Re($w) + i Im($w) \& \& DESCRIPTION: \& \& If z = x + iy, r = |z|, then \& \& 1/2 \& Im w = [ (r \- x)/2 ] , \& \& Re w = y / 2 Im w. \& \& Note that \-w is also a square root of z. The root chosen \& is always in the upper half plane. \& \& Because of the potential for cancellation error in r \- x, \& the result is sharpened by doing a Heron iteration \& (see sqrt.c) in complex arithmetic. .Ve .SH "BUGS" .IX Header "BUGS" .Vb 1 \& Please report any to Randy Kobes .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" For the basic interface to the cephes complex number routines, see Math::Cephes. See also Math::Complex for a more extensive interface to complex number routines. .SH "COPYRIGHT" .IX Header "COPYRIGHT" The C code for the Cephes Math Library is Copyright 1984, 1987, 1989, 2002 by Stephen L. Moshier, and is available at http://www.netlib.org/cephes/. Direct inquiries to 30 Frost Street, Cambridge, \s-1MA 02140.\s0 .PP The perl interface is copyright 2000, 2002 by Randy Kobes. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.