logo


math
Class complex

java.lang.Object
  extended by math.complex
Direct Known Subclasses:
ConstantEvaluation

public class complex
extends java.lang.Object

Implementation of complex numbers

This is a reasonably well featured complex number implementation. Several complex versions of transcendental functions are also implemented here. Created by Michael Rule on Mon Jul 05 2004.


Field Summary
static float e
static complex E
static complex I
 float imag
static complex PHI
static float pi
static complex PI
 float real
static float two_pi
 
Constructor Summary
complex()
          initializes zero as a complex number
complex(complex n)
          Initializes a new complex number as complex number n
complex(float Real)
          initializes a duoble as a complex number
complex(float Real, float Imag)
          Initializes a new complex number with real part Real and imagenary part Imag
complex(java.lang.String data)
          attempts to parse a new complex number from a string
 
Method Summary
static complex abs(complex num)
static complex acos(complex num)
          the inverse cosine of a complex number
static complex acosh(complex num)
static complex acot(complex num)
static complex acoth(complex num)
static complex acsc(complex num)
static complex acsch(complex num)
static float arg(complex num)
          this returns the angle made between the +real axis and the line drawn from the complex number real,imag to the origin
static complex asec(complex num)
static complex asech(complex num)
static complex asin(complex num)
          the arcsin of a complex number
static complex asinh(complex num)
static complex atan(complex num)
          the arctangent of a complex number
static complex atanh(complex num)
static complex conj(complex num)
static complex cos(complex num)
          this returns the cosine of a complex number, also complex
static complex cosh(complex num)
static float cosh(float n)
          the hyperbolic cos of a float
static complex cot(complex num)
          This returns the cotangent of a complex number, also complex
static complex coth(complex num)
static complex csc(complex num)
          This returns the cosecant of a complex number, also complex
static complex csch(complex num)
 complex devidedBy(complex n)
          This devides two complex numbers and returns a complex quotient
static complex eToThe(complex num)
          This takes e to the complex power
static complex factorial(complex num)
          this computes n! in complex terms..
static complex fromPolar(float r, float theta)
static complex integer(complex num)
          grabs the integer part of the real an imagenary parts
static complex ln(complex num)
          This takes the natural log of a complex number
 complex log(complex base)
          This returns the log of given complex base of the complex number
 complex log(float base)
          This returns a log of given real base of the complex number
 complex minus(complex n)
          This subtracts two complex numbers and returns a complex difference
static float mod(complex num)
          this returns the complex modulus, the distance between complex number real,imag and the origin
static complex oneOver(complex num)
          this takes the recipricol of a complex number
 complex over(complex n)
          another name for devidedBy
static complex parseComplex(java.lang.String data)
          attempts to parse a complex number from a string
 complex plus(complex n)
          This adds two complex numbers and returns a comples sum
 complex rotate(float degrees)
static complex round(complex num)
 float rSquared()
          This returns the i value squared plus the r value squared, a very common calculation
 complex scale(float scalar)
          This multiplies the complex number by a scalar
static complex sec(complex num)
          This returns the secant of a complex number, also complex
static complex sech(complex num)
 void setComplex(float Real, float Imag)
          this will reset both parts of the complex number at once
static complex sign(complex num)
static int sign(float n)
static int sign2(float n)
static complex sin(complex num)
          This returns sine of a complex number, also complex
static complex sinh(complex num)
static float sinh(float n)
          the hyperbolic sin of a float
static complex sqrt(complex num)
          This finds the first square root of the complex number
 complex squared()
          This squares a complex number (faster than this.toThe(2))
static complex tan(complex num)
          This returns the tangent of a complex number, also complex
static complex tanh(complex num)
static float tanh(float n)
          the hyperbolic tan of a float
 complex times(complex n)
          This multiplies two complex numbers and returns a complex product
 complex timesI()
          This multiplis the complex number by +i
 java.lang.String toString()
          creates a string representation of the complex number
 complex toThe(complex n)
          This takes one complex number to a complex power and returns a complex
 complex toThe(float n)
          This takes the complex base to the given real power (a+bi)^#
static complex zeta(complex z)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

e

public static float e

pi

public static float pi

two_pi

public static float two_pi

I

public static complex I

E

public static complex E

PI

public static complex PI

PHI

public static complex PHI

real

public float real

imag

public float imag
Constructor Detail

complex

public complex(float Real,
               float Imag)
Initializes a new complex number with real part Real and imagenary part Imag

Parameters:
Real -
Imag -

complex

public complex(complex n)
Initializes a new complex number as complex number n

Parameters:
n -

complex

public complex(float Real)
initializes a duoble as a complex number

Parameters:
Real -

complex

public complex()
initializes zero as a complex number


complex

public complex(java.lang.String data)
attempts to parse a new complex number from a string

Parameters:
data -
Method Detail

fromPolar

public static complex fromPolar(float r,
                                float theta)
Parameters:
r -
theta -
Returns:

sign

public static int sign(float n)
Parameters:
n -
Returns:

sign2

public static int sign2(float n)
Parameters:
n -
Returns:

sqrt

public static complex sqrt(complex num)
This finds the first square root of the complex number

Parameters:
num -
Returns:

oneOver

public static complex oneOver(complex num)
this takes the recipricol of a complex number

Parameters:
num -
Returns:

sin

public static complex sin(complex num)
This returns sine of a complex number, also complex

Parameters:
num -
Returns:

cos

public static complex cos(complex num)
this returns the cosine of a complex number, also complex

Parameters:
num -
Returns:

tan

public static complex tan(complex num)
This returns the tangent of a complex number, also complex

Parameters:
num -
Returns:

csc

public static complex csc(complex num)
This returns the cosecant of a complex number, also complex

Parameters:
num -
Returns:

sec

public static complex sec(complex num)
This returns the secant of a complex number, also complex

Parameters:
num -
Returns:

cot

public static complex cot(complex num)
This returns the cotangent of a complex number, also complex

Parameters:
num -
Returns:

atan

public static complex atan(complex num)
the arctangent of a complex number

Parameters:
num -
Returns:

asin

public static complex asin(complex num)
the arcsin of a complex number

Parameters:
num -
Returns:

acos

public static complex acos(complex num)
the inverse cosine of a complex number

Parameters:
num -
Returns:

acsc

public static complex acsc(complex num)
Parameters:
num -
Returns:

asec

public static complex asec(complex num)
Parameters:
num -
Returns:

acot

public static complex acot(complex num)
Parameters:
num -
Returns:

sinh

public static complex sinh(complex num)
Parameters:
num -
Returns:

cosh

public static complex cosh(complex num)
Parameters:
num -
Returns:

tanh

public static complex tanh(complex num)
Parameters:
num -
Returns:

csch

public static complex csch(complex num)
Parameters:
num -
Returns:

sech

public static complex sech(complex num)
Parameters:
num -
Returns:

coth

public static complex coth(complex num)
Parameters:
num -
Returns:

asinh

public static complex asinh(complex num)
Parameters:
num -
Returns:

acosh

public static complex acosh(complex num)
Parameters:
num -
Returns:

atanh

public static complex atanh(complex num)
Parameters:
num -
Returns:

acsch

public static complex acsch(complex num)
Parameters:
num -
Returns:

asech

public static complex asech(complex num)
Parameters:
num -
Returns:

acoth

public static complex acoth(complex num)
Parameters:
num -
Returns:

conj

public static complex conj(complex num)
Parameters:
num -
Returns:

sign

public static complex sign(complex num)
Parameters:
num -
Returns:

abs

public static complex abs(complex num)
Parameters:
num -
Returns:

round

public static complex round(complex num)
Parameters:
num -
Returns:

rotate

public complex rotate(float degrees)
Parameters:
degrees -
Returns:

integer

public static complex integer(complex num)
grabs the integer part of the real an imagenary parts

Parameters:
num -
Returns:

sinh

public static float sinh(float n)
the hyperbolic sin of a float

Parameters:
n -
Returns:

cosh

public static float cosh(float n)
the hyperbolic cos of a float

Parameters:
n -
Returns:

tanh

public static float tanh(float n)
the hyperbolic tan of a float

Parameters:
n -
Returns:

eToThe

public static complex eToThe(complex num)
This takes e to the complex power

Parameters:
num -
Returns:

ln

public static complex ln(complex num)
This takes the natural log of a complex number

Parameters:
num -
Returns:

factorial

public static complex factorial(complex num)
this computes n! in complex terms.. crazy

Parameters:
num -
Returns:

parseComplex

public static complex parseComplex(java.lang.String data)
attempts to parse a complex number from a string

Parameters:
data -
Returns:

toString

public java.lang.String toString()
creates a string representation of the complex number

Overrides:
toString in class java.lang.Object
Returns:

setComplex

public void setComplex(float Real,
                       float Imag)
this will reset both parts of the complex number at once

Parameters:
Real -
Imag -

mod

public static float mod(complex num)
this returns the complex modulus, the distance between complex number real,imag and the origin

Parameters:
num -
Returns:

arg

public static float arg(complex num)
this returns the angle made between the +real axis and the line drawn from the complex number real,imag to the origin

Parameters:
num -
Returns:

rSquared

public float rSquared()
This returns the i value squared plus the r value squared, a very common calculation

Returns:

scale

public complex scale(float scalar)
This multiplies the complex number by a scalar

Parameters:
scalar -
Returns:

devidedBy

public complex devidedBy(complex n)
This devides two complex numbers and returns a complex quotient

Parameters:
n -
Returns:

over

public complex over(complex n)
another name for devidedBy

Parameters:
n -
Returns:

times

public complex times(complex n)
This multiplies two complex numbers and returns a complex product

Parameters:
n -
Returns:

minus

public complex minus(complex n)
This subtracts two complex numbers and returns a complex difference

Parameters:
n -
Returns:

plus

public complex plus(complex n)
This adds two complex numbers and returns a comples sum

Parameters:
n -
Returns:

toThe

public complex toThe(complex n)
This takes one complex number to a complex power and returns a complex

Parameters:
n -
Returns:

toThe

public complex toThe(float n)
This takes the complex base to the given real power (a+bi)^#

Parameters:
n -
Returns:

squared

public complex squared()
This squares a complex number (faster than this.toThe(2))

Returns:

log

public complex log(float base)
This returns a log of given real base of the complex number

Parameters:
base -
Returns:

log

public complex log(complex base)
This returns the log of given complex base of the complex number

Parameters:
base -
Returns:

timesI

public complex timesI()
This multiplis the complex number by +i

Returns:

zeta

public static complex zeta(complex z)
Parameters:
z -
Returns: