Next Previous Contents

11. Complex number commands

11.1 The r>c command

This command takes two real numbers as arguments, and returns a complex number whose real part is the level two argument and whose imaginary part is the level one argument.

Examples:

> pi 1 exp
[ 2]          3.14159265358979
[ 1]          2.71828182845905
> r>c
[ 1] (3.14159265358979,
     2.71828182845905)

11.2 The re>c command

This command takes a real number as argument, and returns a complex number whose real part is its argument and whose imaginary part is zero.

Examples:

> pi
[ 1]          3.14159265358979
> re>c
[ 1]      (3.14159265358979,0)

11.3 The im>c command

This command takes a real number as argument, and returns a complex number whose real part is zero and whose imaginary part is its argument.

Examples:

> pi
[ 1]          3.14159265358979
> im>c
[ 1]      (0,3.14159265358979)

11.4 The c>r command

This command takes a complex number as argument and returns two real numbers, representing its real and imaginary parts.

Examples:

> (3, -4)
[ 1]                    (3,-4)
> c>r
[ 2]                         3
[ 1]                        -4

11.5 The re command

This command takes a complex number as argument and returns a real number representing its real part.

Examples:

> (3, -4)
[ 1]                    (3,-4)
> re
[ 1]                         3

11.6 The im command

This command takes a complex number as argument and returns a real number representing its imaginary part.

Examples:

> (3, -4)
[ 1]                    (3,-4)
> im
[ 1]                        -4

11.7 The conj command

This command returns the conjugate of its argument.

> (3, -4)
[ 1]                    (3,-4)
> conj
[ 1]                     (3,4)

11.8 The arg command

This command returns the argument of a complex number, that is, it's angle when represented in polar form.

Examples:

> set anglemode deg
> (4 4)
[ 1]                     (4,4)
> arg
[ 1]                        45
> (-2 4)
[ 2]                        45
[ 1]                    (-2,4)
> arg
[ 2]                        45
[ 1]          116.565051177078


Next Previous Contents