# Complex Number Operations

 Team Fly

Page 620

experiment with the sample applications and discover other values of the Cx and Cy parameters that yield rich, colorful Julia shapes ). Note, however, that most numbers you enter randomly will produce uninteresting fractals, and that your numbers must be between –2 and +2. Also remember that often the most elegant pictures result from zooming into the initial Julia fractal six or eight times.

```1.  Cx=–0.754         Cy=0.049
2.  Cx=–0.744         Cy=0.097
3.  Cx=–0.736         Cy=0.097
4.  Cx=–0.756         Cy=0.097
5.  Cx=–0.743         Cy=0.097
6.  Cx=–0.766227      Cy=0.096990
7.  Cx=–0.9           Cy=0.12
8.  Cx=–0.745429      Cy=0.113008
9.  Cx=–1.0300        Cy=-0.9200
10. Cx=0.320          Cy=0.043
11. Cx=0.3080         Cy=0.46
12. Cx=–1.330         Cy=0.043
13. Cx=–0.16          Cy=1.32
14. Cx=–1.8           Cy=–1.67
```

### Complex Number Operations

Most readers are not likely interested in the details about addition and multiplication of complex numbers. So, we left this discussion for the end of the chapter. For the intrepid, here are the three basic complex number operations: addition, subtraction, and multiplication. Complex numbers are actually pairs of numbers (the real and imaginary parts) that are handled separately. The sum of two complex numbers is another complex number, whose real number is the sum of the real parts and whose imaginary part is the sum of the imaginary parts of the operands.

Adding and Subtracting Complex Numbers Here are the formulae for adding and subtracting complex numbers:

```(a + ib) + (c + id) = (a + c) + i(b + d)
(a + ib) – (c + id) = (a – c) + i(b – d)
```

or

```(a, b) + (c, d) = (a + c, b + d)
(a, b) – (c, d) = (a – c, b – d)
```

And here are some examples of addition and subtraction of complex numbers:

```(3 + i7) + (–2 + i2) = (1 + i9) also: (3, 7) + (–2, 2) = (1, 9)
(3 + i7) – (–2 + i2) = (5 + i5) also: (3, 7) – (–2, 2) = (5, 5)
```

Multiplying Complex Numbers To multiply two complex numbers, we form all four products:

```(a + ib) * (c + id) = a*c + ib*c + ia*d + ib*id
```
 Team Fly
 Team Fly

Page 622

### Summary

In this chapter we discussed some advanced graphics topics by means of two demonstration applications: a practical application for plotting 2-dimensional functions and a ''fun" application that generates fractals. While building the plotting application you learned how to build GraphicsPath objects and how to apply transformations to graphics elements before rendering them in the drawing surface. You also learned how to calculate arbitrary math expressions at runtime with the MSScript ActiveX control.

The second sample application of this chapter was a simple fractal generator that produces startling fractal images. This application generates the fractals by painting one pixel at a time. The calculation of each pixel's color involves some math, which isn't beyond the grasp of the average developer. You can enhance the fractal generator in many ways and the most challenging aspect of the application is the design of a palette for coloring the fractals.

 Team Fly