# 由特定功能定义的Mandelbrot集Mandelbrot set defined by a specific function

``````f(z) = c^e(-z)
``````

（公式取自一本带有分形示例的书）？

``````function computeRow(task) {
var iter = 0;
for (var i = 0; i < task.width; i++) {
var z_r = 0, z_i = 0;

for (iter = 0; z_r*z_r + z_i*z_i < escape && iter < max_iter; iter++) {
// z -> z^2 + c
var tmp = z_r*z_r - z_i*z_i + c_r;
z_i = 2 * z_r * z_i + c_i;
z_r = tmp;
}
if (iter == max_iter) {
iter = -1;
}
}
}
``````

## 1 个回复1

### ===============>>#1 票数：5 已采纳

``````z_r*z_r+2*z_r*z_i*i - z_i*z_i + c_r + c_i*i = (z_r*z_r - z_i*z_i + c_r) + (2*z_r*z_i + c_i)*i
``````

``````tmp = z_r*z_r - z_i*z_i + c_r
``````

``````2*z_r*z_i + c_i
``````

``````z_r = z_r*z_r - z_i*z_i + c_r
z_i = 2*z_r*z_i + c_i
``````

``````e^z = e^(z_r+z_i*i) = e^z_r * (e^z_i*i) = e^z_r * (cos(p)+i*sin(p)) = (e^z_r * cos(p)) + i * (e^z_r * sin(p))
``````

``````(e^z_r * cos(p)) + i * (e^z_r * sin(p)) - c_r - c_i*i = (e^z_r * cos(p) - c_r) + i * (e^z_r * sin(p) - c_i)
``````

``````z_r = (e^z_r * cos(p) - c_r) = (e^z_r * cos(z_i/z_r) - c_r)
z_i = (e^z_r * sin(p) - c_i) = (e^z_r * sin(z_i/z_r) - c_i)
``````