## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Complex numbers

Our understanding is that the square of a number can never be negative. In that case, how do we solve x2 = -9? Sensibly, in math we have the concept of i, as a solution, that is, x = 3i. Numbers such as i, -i, 3i, and 2.27i are called imaginary numbers. "A real number" + "an imaginary number" forms a "complex number".

Complex number = (real part) + (imaginary part) I

The following examples show complex number representation using the Breeze library for Mathematics:

`import breeze.linalg.DenseVector import breeze.math.Complex val i = Complex.i // add println((1 + 2 * i) + (2 + 3 * i)) // sub println((1 + 2 * i) - (2 + 3 * i)) // divide println((5 + 10 * i) / (3 - 4 * i)) // mul println((1 + 2 * i) * (-3 + 6 * i)) println((1 ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required