Complex numbers

From Fractal Wiki
Jump to navigation Jump to search

The complex numbers, denoted [math]\mathbb{C}[/math], are the real numbers [math]\mathbb{R}[/math] adjoined with a special value [math]i[/math] satisfying [math]i^2 = -1[/math]. A general complex number is written [math]a + b i[/math] where [math]a, b \in \mathbb{R}[/math].

Mathematics of complex numbers

Arithmetic

conjugation

[math]\bar{a + b i} = a - b i[/math]

addition

[math](a + b i) + (x + y i) = (a + x) + (b + y) i[/math]

subtraction

[math](a + b i) - (x + y i) = (a - x) + (b - y) i[/math]

multiplication

[math](a + b i) (x + y i) = (a x - b y) + (b x + a y) i[/math]

division

[math]c / z = (c \bar z) / (z \bar z)[/math]

norm

[math]|z|^2 = z \bar z[/math]

argument

[math]\arg(a + b i) = \tan^{-1} \frac{b}{a}[/math], taking care to use the correct quadrant (see the function atan2 available in some programming languages). The argument is unique only up to an integer multiple of [math]2 \pi[/math], the prinicipal argument is usually taken to be in the range [math][-\pi,\pi)[/math]

Functions

sqrt

[math]\sqrt{z} = \sqrt{r}\frac{z + r}{|z + r|} \text{ where } r = |z|[/math] source

exp

[math]\exp(a + b i) = \exp(a)((\cos b) + (\sin b) i)[/math]

log

[math]\log(z) = \log(|z|) + \arg(z) i[/math]

sin

[math]\sin z = (\exp(i z) - \exp(- i z)) / (2i)[/math]

cos

[math]\cos z = (\exp(i z) + \exp(- i z)) / 2[/math]

tan

[math]\tan z = \frac{\sin z}{\cos z}[/math]

sinh

[math]\sinh z = (\exp(z) - \exp(- z)) / 2[/math]

cosh

[math]\cosh z = (\exp(z) + \exp(- z)) / 2[/math]

tanh

[math]\tanh z = \frac{\sinh z}{\cosh z}[/math]

asin

[math]\sin^{-1} z = -i \log(iz + \sqrt(1 - z^2))[/math]

acos

[math]\cos^{-1} z = -i \log(z + i \sqrt(1 - z^2))[/math]

atan

[math]\tan^{-1} z = (\log(1 + i z) - \log(1 - i z)) / (2 i)[/math]

asinh

[math]\sinh^{-1} z = \log(z + \sqrt(1 + z^2))[/math]

acosh

[math]\cosh^{-1} z = 2 \log(\sqrt((z + 1) / 2) + \sqrt((z - 1) / 2))[/math]

atanh

[math]\tanh^{-1} z = (\log(1 + z) - \log(1 - z)) / 2[/math]

Programming language support

C

complex numbers in C

#include <complex.h>

typedef double _Complex C;

C z = 2 + 3 * I;

There is also the MPC library for arbitrary precision complex numbers, based on GMP and MPFR. It is free software under LGPLv3+ license.

C++

complex numbers in C++

#include <complex>

typedef std::complex<double> C;

C z(2, 3);

Haskell

complex numbers in Haskell

import Data.Complex

type C = Complex Double

z = 2 :+ 3


Original Page by Claude