# Squaring a complex number

### More on complex arithmetics for the curious

Although there is enough other information elsewhere on this site to write a Mandelbrot program, you may still be curious about the background, or more specifically the strange formula for multiplying to complex numbers.

Here it is: A complex number is really written as **a + bi**.

**bi** is called the "imaginary component", and its origin is in the very reason for using complex numbers, namely in making it possible to calculate the square root of a negative number.

In non-complex mathematics, the square root of a negative number is undefined. The only thing complex arithmetic adds is the symbol * i* representing the square root of -1, and this enables us to represent the square root of any negative number.

The calculation rules are simple. The only thing worth mentioning is that

* i^{2}* = -1

Now, to multiply two parenthesized sums (a_{1} + b_{1}) (a_{2} + b_{2}), you just multiply and add together the four possible combinations of elements:

(a_{1} + b_{1})(a_{2} + b_{2}) = a_{1}a_{2} + a_{1}b_{2} + b_{1}a_{2} + b_{1}b_{2}

If we do this to two complex numbers (a_{1} + b_{1}*i*) and (a_{2} + b_{2}*i*), we end up with

a_{1}a_{2} + a_{1}b_{2}*i*+ b_{1}a_{2}*i* + b_{1}b_{2}*i*^{2}

But *i ^{2}* is of course -1, so we can simplify this:

a_{1}a_{2} - b_{1}b_{2} + (a_{1}b_{2} + a_{2}b_{1})*i*

If we do this to the z^{2} calculation we used in the Mandelbrot formula above, writing z as (x,y), we just substitute "x" for "a_{1}" and "a_{2}", and "y" for "b_{1}" and "b_{2}" to yield

x^{2} - y^{2} + 2xy*i*

or, written as a complex number

(x^{2} - y^{2}, 2xy)

which is equvalent to the formula used in the Mandelbrot code.

## Recent comments

18 weeks 1 day ago

25 weeks 21 hours ago

6 years 24 weeks ago

6 years 51 weeks ago

7 years 2 weeks ago

7 years 7 weeks ago

7 years 7 weeks ago

7 years 23 weeks ago

7 years 33 weeks ago

7 years 33 weeks ago