For complex functions f(z) needed to create fractals we could calculate the real and imaginary part separately using basic arithmetic with float numbers. But this is hard to do and may cause many programming errors.

It is better to use complex numbers as objects and define the arithmetic operations as methods that yield complex numbers as results. This allows us to chain operations and to write calculations in a rather natural way. As an example, to calculate a=b*c+d*e we simply write

a=b.mult(c).add(d.mult(e));

In the next post “complex numbers – the code” I define a suitable class for processing. It has complex numbers and some essential operations, such as addition, multiplication and powers. Further, complex conjugation changes the sign of the imaginary part. Inversion of a number is a division of 1 by that number. Both are useful to make different fractals.

### Like this:

Like Loading...

*Related*