Using complex numbers

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


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.

This entry was posted in programming and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.