Java Reference
In-Depth Information
iteration count (line 28). The method returns COUNT_LIMIT if the sequence is
bounded (line 31).
The loop in lines 8-9 examines each point (x, y) for and
with interval 0.01 to see if its corresponding complex number
is in the Mandelbrot set (line 10). If so, paint the point black (line
12). If not, set a color that is dependent on its iteration count (line 15). Note that
the point is painted in a square with width u and height 1 . All the points are
scaled and mapped to a grid of 400-by-400 pixels (lines 14-15). Note that the
values 77 , 58 , and 159 are set arbitrarily. You may set different numbers to get
new colors.
Complete the program to draw a Mandelbrot image, as shown in Figure
15.13a.
-
2
6
x
6
2
-
2
6
y
6
2
c
=
x
+
y i
**15.21
( Julia set ) The preceding exercise describes Mandelbrot sets. The Mandelbrot
set consists of the complex c value such that the sequence is
bounded with fixed and c varying. If we fix c and vary the
point (x, y) is said to be in a Julia set for a fixed complex value c , if the func-
tion stays bounded. Revise Exercise 15.20 to draw a Julia set
as shown in Figure 15.13b. Note that you only need to revise the count
method by using a fixed c value
z n +
z n + 1 =
c
z 0
z 0 (
=
x
+
yi ),
z n +
z n + 1 =
c
(
-
0.3
+
0.6 i ).
15.22
( Use the Rational class ) Write a program that computes the following sum-
mation series using the Rational class:
1
2 +
2
3 +
3
4 + c +
98
99 +
99
100
You will discover that the output is incorrect because of integer overflow (too
large). To fix this problem, see Programming Exercise 15.17.
 
Search WWH ::




Custom Search