NextFractal

# Mandelbrot set of trigonometric function sin(z)

In this example you will learn how to create the Mandelbrot set of trigonometric function sin(z) where z is a complex number.

```fractal {
// Set region margins and declare state vector as [x,n] where x and n are built-in variables
orbit [<-3.0,-3.0>,<3.0,3.0>] [x,n] {
begin {
// Julia is an internal variable
if (~julia) {
// Set variable x to initial state pi / 2
x = <pi / 2,0>;
}
}
// Iterate for n from 0 to 200 stopping when abs(im(x)) > 100
loop [0, 200] (abs(im(x)) > 100) {
// Precalculate values
xr = re(x);
xi = im(x);
wr = re(w);
wi = im(w);
ta = cos(xr);
tb = sin(xr);
tc = exp(+xi);
td = exp(-xi);
te = 0.5 * tb * (tc + td);
tf = 0.5 * ta * (tc - td);
zr = wr * te - wi * tf;
zi = wi * te + wr * tf;
// Set x to complex number zr + zi i
x = <zr,zi>;
}
}
// Set background color to alpha=1, red=1, green=1, blue=1
color [(1,0,0,0)] {
// Create palette with 200 colors and name gradient
[#FFFF0000 > #FFFFFFFF, 10];
[#FFFFFFFF > #FFFFFFFF, 190];
}
// Apply rule when n > 0 and set opacity to 1.0
rule (n > 0) [1] {
// Set color to element n - 1 of gradient (gradient has 200 colors starting from index 0)