Complex numbers

Complex numbers are mathematicals objets.

If you don't know complex, I advise you to start learning it. (example)

How to enter a complex

Just hit the ( key, a popup field will appear, you can continue to enter your complex number, validate it by pressing enter.
If you need to enter complex in his rectangular form (cartesian) use ; ex: (2;1) is 2+i
If you need to enter it in his polar form (trigonometric.) use @, example (2@1) will be interpreted as (2 @:1)

rect/polar display mode

RPNEnh can display complex as rectangular (cartesian) (1;2) or as polar (@:1.5).
Cartesian mode is (x;y) z = x + i y
Polar mode is (ρ @:θ)
ρ stand for rho, the magnitude (module) and θ is the angle.
z = ρ * ei θ

You can switch a mode to another by <>(x;y) :

example :
(1;1) <>(x;y) gives : (1.414213 @:0.785398) or (sqr(2) @:pi/4) if you use the rationalize mode : - recomended.



Complex specifics functions

function usage example
C->XY Gives the two cartesian values of a complex. (1;2) gives 1 and 2
C->R@ Gives the two polar values of a complex. (1;1) gives 1.4142135... and 0.785398...
XY->C Perform the reversal of C->XY : build a complex from two numbers the stack has :
5
6
we execute function XY->C it gives : (5;6)
conj compute the conjugate of a complex (1;2) gives (1;-2)
polar :(3 @:1) gives (3 @:-1)
ABS compute the Magnitude of a complex (1;2) gives 2.23606


Extention of real functions

Serveral functions in Real Mode does not works with negatives values, did you try sqr(-4) ?
The fact that i is defined as i2=-1, using complex number will help you to extend some functions to negative range. RPNEnh allow that !!!

The simpliest example is : try to perform -4 sqr you will get a (nan) : not-a-number ---> an error.
Now use complex number (-4;0) whitch is same as -4 : (-4;0) sqr, you will get : { (0;2) (0;-2) } this is the only exact mathematical result of sqr(-4) !
Yes, in Complex, sqr of -4 has two results : 2i and -2i.
function extended for information, in REAL mode beavior in COMPLEX
sqr just give the first root (and only in positive), as all other dummy calculator
-4 gives (nan)
4 gives 2 (not suffisant, -2 is missing)
gives all two roots, sqr function is defined for positives and negatives
(-4;0) gives { (0;2) (0;-2) }
(4;0) gives { (2;0) (-2;0) }  correct!
ln this function is defined for >= 0
-1 gives (nan)
extended to negatives
(-1;0) gives (0;3.1415...)
x^y
where y=1/n
gives only the first of nth roots
2 0.5 gives 1.41421..
gives all the nth roots
(2;0) 0.5 gives {(1.41..;0)(-1.41..;0)}
if n=5, it gives you a list of 5 roots.
These 3 functions are extended from their classical behavior to provide (correct) results where most of calculator ends with an error or incomplete result.
These functions are also used internally and finaly may extends other functions partially...

General functions


A lot of functions are defined for complex : + - * / NEG are the basics one, see the table below for an overview
functions behavior notes/example
Trigonometrics
SIN/COS/TAN
basic trigonometrics are defined. please note that ASIN, ACOS and ATAN are not yet defined. (1;1) COS gives (1.2984..;0.6349..)
e exponential of complex works.
works for any basis : 10^x
(1;1) e gives (1.468..;2.287..)
ln logarithms of complex works
also for any basis : log
(1;1) ln (0.346..;0.785...)
1/x compute 1/x (1;1) 1/x gives (0.5;-0.5)
x^y This is a very specific function.
x and y can be complex.
see the next table for details
See detailed examples on next table
Sqr Sqr is exactly the same as x^(1/2),
see x^y function (where y=0.5)
See x^y on the table that follow for details.
(1;1) Sqr gives { (1.098..;0.455..) (-1.098..;-0.455..) }
there are two roots.

The specific function x^y, where x and y can be real and complex.
x^y can be used to compute all roots if y=1/n.
x y result
real
2
real
2
compute 22, it gives 4
complex
(2;1)
compute 2(2+i) : (3.0769...;2.5558...)
complex
(2;1)
integer
3
compute (2+i)3 : (2;11)
1/integer
0.3333333333
compute all the n root
{(1.29;0.20) (-0.82;1.01) (-0.47;-1.21)}
other real
1.2556
(2;1)^1.2256 gives (2,25983..;1,44289..)
complex
(2;2)
compute (2;1)(2;2) = (2+i)^(2+2i) : (-1.62...;1.12...)

As you see this x^y function gives a very interresting result for y=1/n (example 0.5 0.3333333 0.25 0.2 and so on)
This works only when x is complex, if you need to know all the five 5th roots of 2, you have to use (2;0) instead of 2 - see extensions
Example : (2;0) 5 1/x x^y gives :
{(1.148698354;0) (0.3549673131;1.092477055) (-0.9293164906;0.6751879523) (-0.929316490;-0.6751879523) (0.3549673131;-1.092477055) } This is the list of the 5 roots.

Notes

  • Complex can be used into matrix, complex matrix works as well as real matrix, all operations supported (DET...)
  • Complex can be stored into list
  • You can embed apn into complex, ex : (`12233`;`55566`), only basic operations are supported yet...