Sha256: fed1e940d18eae86d893f8b253de0b12860af0c614b664057787de2cbf8b3088

Contents?: true

Size: 1.74 KB

Versions: 133

Compression:

Stored size: 1.74 KB

Contents

# Complex Numbers

A complex number is a number in the form `a + b * i` where `a` and `b` are real and `i` satisfies `i^2 = -1`.

`a` is called the real part and `b` is called the imaginary part of `z`.
The conjugate of the number `a + b * i` is the number `a - b * i`.
The absolute value of a complex number `z = a + b * i` is a real number `|z| = sqrt(a^2 + b^2)`. The square of the absolute value `|z|^2` is the result of multiplication of `z` by its complex conjugate.

The sum/difference of two complex numbers involves adding/subtracting their real and imaginary parts separately:
`(a + i * b) + (c + i * d) = (a + c) + (b + d) * i`,
`(a + i * b) - (c + i * d) = (a - c) + (b - d) * i`.

Multiplication result is by definition
`(a + i * b) * (c + i * d) = (a * c - b * d) + (b * c + a * d) * i`.

The reciprocal of a non-zero complex number is
`1 / (a + i * b) = a/(a^2 + b^2) - b/(a^2 + b^2) * i`.

Dividing a complex number `a + i * b` by another `c + i * d` gives:
`(a + i * b) / (c + i * d) = (a * c + b * d)/(c^2 + d^2) + (b * c - a * d)/(c^2 + d^2) * i`.

Exponent of a complex number can be expressed as
`exp(a + i * b) = exp(a) * exp(i * b)`,
and the last term is given by Euler's formula `exp(i * b) = cos(b) + i * sin(b)`.


Implement the following operations:
 - addition, subtraction, multiplication and division of two complex numbers,
 - conjugate, absolute value, exponent of a given complex number.


Assume the programming language you are using does not have an implementation of complex numbers.



## Source

Wikipedia [https://en.wikipedia.org/wiki/Complex_number](https://en.wikipedia.org/wiki/Complex_number)

## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Version data entries

133 entries across 133 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.158 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.157 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.156 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.155 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.154 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.153 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.152 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.151 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.150 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.149 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.148 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.147 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.146 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.145 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.144 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.143 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.142 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.141 tracks/kotlin/exercises/complex-numbers/README.md
trackler-2.2.1.140 tracks/kotlin/exercises/complex-numbers/README.md