# Complex numbers

You can see a simple implementation of a complex number in Java.

## imaginary unit

By definition

``i2 = -1``

Because no real number satisfies this equation, i is called an imaginary number.

## complex number

Complex number c is expressed as

``````c = α + i*β
``````

Where

• α is called real part of complex number
• β is called imaginary part of complex number
• i is imaginary unit

You can visualize a complex number as point (α, β) on the complex plane. ## basic operations

• a = b, if αa = αb and βa = βb
• a + b = (αa + αb, βa + βb)
• a*b = (αab - βab, αab + αba)
• a/b = (  (αab + βab)/(αb2 + βb2), (αba - αab)/(αb2 + βb2)  )

## Modulus

• |a| = sqrt(α2 + β2)
• |a*b| = |a|*|b|
• |a+b| <= |a| + |b|

## de Moivre's identity

``````(cos(φ) + i*sin(φ))n = cos(n*φ) + sin(n*φ)
``````

## Euler's formula

``````ei*x = cos(x) + i*sin(x)

sin(x) = (eix - e-ix) / 2i

cos(x) = (eix + e-ix) / 2

tan(x) = (e-ix - eix) / (eix + e-ix)
``````

## trigonometric form

``````c = |c| * ( cos(φ) +i*sin(φ) )
``````

## exponential form

``````c = |c|*ei*φ
``````