This Java Script calculator raises a complex number to a complex power. To operate the calculator, enter the real and imaginary parts of the base number and the exponent. Press the Compute button to obtain the solution. On invalid entries, a popup window will display an error message.
Return to Contents
The Java Script source code for this program can be viewed by using the View|Source command of your web browser.
You may use or modify this source code in any way you find useful, provided that you agree that the author has no warranty, obligations or liability. You must determine the suitability of this source code for your use.
Return to Contents
A complex number is defined as:
z = a + j·b
where a and b are real numbers and j2 = -1. For the imaginary number j, we can verify that jj is a real number. To show this, recall Euler's formula:
ej·θ = cos(θ) + j·sin(θ)where e is the base of natural logarithms. Now let θ = π/2. Since
cos(π/2) = 0 andwe get
sin(π/2) = 1
j = ejπ/2Then, using some algebra
jj = (ej·π/2)j = ej·j·π/2 = e-π/2,which is equal to 0.20787957635 and is a real number.
A derivation
We can use Euler's formula to raise a real number to a complex power. Any real number r can be written as eln r - so the complex power of a real number is:
rj·z = (eln r)j·z
= e(j·z·ln r)
= cos(z·ln r) + j·sin(z·ln r)
To raise a complex number x = a + j·b to the complex power y = c + j·d
we can now do the following:
xy = (a + j·b)c + j·dUsing Euler's formula, let
a + j·b = ρ·ej·θwhere,
________
ρ = √(a2 + b2)
θ = arctan( b/a ) assure θ is in the correct quadrant
By substitution, we get
xy = (ρ·ej·θ)c·(ρ·ej·θ)j·dExpanding, we get
= ρc·ej·c·θ·ρj·d·ej·j·d·θ
= ρc·e-d·θ·ej·c·θ·ρj·d
= ρc·e-d·θ·[cos(c·θ) + j·sin(c·θ)]·[cos(d·ln ρ) + j·sin(d·ln ρ)]
= ρc·e-d·θ·{[cos(c·θ)·cos(d·ln ρ) - sin(c·θ)·sin(d·ln ρ)] +
j·[cos(c·θ)·sin(d·ln ρ) + sin(c·θ)·cos(d·ln ρ)]}
= ρc·e-d·θ·[cos(c·θ + d·ln ρ) + j·sin(c·θ + d·ln ρ)]
To summarize, given
Thenx = a + j·b y = c + j·d
where,xy = ρc·e-d·θ·[cos(c·θ + d·ln ρ) + j·sin(c·θ + d·ln ρ)]
________
ρ = √(a2 + b2)
θ = arctan( b/a ) assure θ is in the correct quadrant
Return to Contents
AbCd Classics - free on-line books