ErnieParke (talk | contribs)
(Saving work.)
'''[[Recursion]]''' is the process of repeating items in a self-similar way. Recursion can be implemented in [[Scratch]] by making a block that uses itself. This can be used to create '''[[wikipedia:Fractal|fractals]]'''. A fractal is pattern that produces a picture, which can be zoomed into infinity and will still produce the same picture. Some common examples of fractals are the [[wikipedia:Mandelbrot set|Mandelbrot set]], the [[wikipedia:Sierpinski triangle|Sierpinski Triangle]], and the [[wikipedia:Koch snowflake|Koch Snowflake]].
==Creating the Koch Curve==
The Koch Curve is a fractal that can be created relatively easily in Scratch. The Koch Curve is part of a larger fractal, the [[wikipedia:Koch snowflake|Koch Snowflake]].
The Koch Curve is a fractal that can be created relatively easily in Scratch. The Koch Curve is a piece of the larger fractal, the [[wikipedia:Koch snowflake|Koch Snowflake]].
===Understanding Recursion in the Koch Curve===
[[File:Recersion in Koch Curve.png|500px]]
The triangle in the center is an equilateral triangle, therefore each of it's angles have a measure of 60°.
[[File:Equilateral Triangle in Koch Curve.png|500px]]
==Creating the Mandelbrot Set==
[[File:Mandelbrot Set.gif|thumb|175px|An animation of zooming in on the Mandelbrot set.]]
The Mandelbrot set is a mathematical fractal defined in the complex plane. It was named after its discoverer, Benoit Mandelbrot, and has many close relationships to the [[Wikipedia:Julia Sets|Julia Sets]].
The Mandelbrot set is a mathematical fractal defined in the complex plane. It is completely self-similar, meaning that it repeats over and over as one zooms in. The Mandelbrot set was named after its discoverer, Benoit Mandelbrot, and has many close relationships to the [[Wikipedia:Julia Sets|Julia Sets]].
[[File:Mandelbrot Equation.png]]
For example, letting c=1 yields the sequence 0, 1, 2, 5, 26, 677, ect... That sequence escapes to infinity and therefore c=1 is not part of the Mandelbrot set. Meanwhile, the sequence c=-1 gives 0, -1, 0, -1, 0, ect..., is bounded and so belongs to the Mandelbrot set.
First, one starts with a z value of c (i.e. z<sub>1</sub> = c). Then, when one puts that z back into the equation, it becomes z^2+c. That z is then taken and put back through the equation over and over. This is called iteration.
To note, it has been proven that if any sequence contains a complex value that is outside a distance of 2 from the origin, it will escape to infinity.
====Coloring====
[[File:Mandelbrot Coloring.gif|thumb|150px|An animation of the Mandelbrot set under iteration.]]
In a basic Mandelbrot set, white is used for a c-values that escapes to infinity and black is used for all c-values that do not.
In most Mandelbrot sets, though, colors are used to help depict the Mandelbrot set or make it more art-orientated. Colors are not defined through an equation, but rather through the last iteration before escaping a distance of two from the origin. The iteration is then assigned a color of the creator's preference.
====Final Product====
==Julia Set==
[[File:Julia Set Equation.png]]
<gallery widths=160px perrow=5 caption="Julia Set">
File:Julia Set Image1.png|Julia set for c=-0.835-0.2321i
File:Julia Set Image2.png|Julia set for c=-0.4+0.6i
File:Julia Set Image3.png|Julia set for c=0.285+0i
[[Category: Scripting Tutorials]]