Basic Complex Number Manipulation

DESCRIPTION:

Returns the real parts, the imaginary parts, the moduli, the arguments, or the conjugates of a vector of complex numbers. These functions are generic.

USAGE:

Re(z)
Im(z)
Mod(z)
Arg(z)
Conj(z)

REQUIRED ARGUMENTS:

z
numeric or complex. Missing values ( NAs) are allowed.

VALUE:

vector of real parts ( Re), imaginary parts ( Im), moduli ( Mod), arguments ( Arg) or complex conjugates ( Conj) of z. The value of Arg satisfies --pi < Arg(z) <= pi. All of these return objects of mode "numeric" except Conj which returns a complex object.

DETAILS:

Missing values in the input create missing values in the output.

SEE ALSO:

, .

EXAMPLES:

rpart <- seq(-.5, 1, length=100); ipart <- seq(-1, 1, length=100)
cmat <- outer(rpart, ipart*1i, "+") # matrix of complex numbers
# first set up a blank coordinate system for the plot
plot(0:1, 0:1, type="n", axes=F, xlab="", ylab="")
# now make subplots within that region
sp <- subplot(x=c(0, .85), y=c(0, 1),
   image(rpart, ipart, tan.M <- Mod(tan(cmat)), xlab="Real part", 
   ylab="Imaginary part", main="Tangent Function"))
    # make two additions to this plot
subplot(pars=sp,
   contour(add=T, rpart, ipart, Arg(tan(cmat)), v=-2:3, labex=0))
subplot(pars=sp,
   text(c(-.2, .25, .45, .4, -.25), c(-.5, -.4, -.03, .55, .5), -2:2))
# add legend and title
image.legend(tan.M, x=c(.92, 1), y=c(.25, .75), horiz=F)
title(sub="Shades for Modulus, Lines for Argument")