# 牛顿分形

f(z) = z3 − 1的牛顿分形

${\displaystyle p(z)=z^{d}+p_{1}z^{d-1}+\cdots +p_{d-1}z+p_{d}:=(z-\zeta _{1})(z-\zeta _{2})\cdots (z-\zeta _{d})}$ .

${\displaystyle z_{mn}=z_{00}+m\,\Delta x+in\,\Delta y;\quad m=0,\ldots ,M-1;\quad n=0,\ldots ,N-1}$

## 牛顿分形的推广

${\displaystyle z_{n+1}=z_{n}-a{\frac {p(z_{n})}{p'(z_{n})}}}$

### 新星分形

${\displaystyle z_{n+1}=z_{n}-a{\frac {p(z_{n})}{p'(z_{n})}}+c=G(a,c,z)}$

${\displaystyle {\frac {\partial }{\partial z}}G(a,c,z)=0.}$

## 实现

{\displaystyle {\begin{aligned}f(z)&=z^{3}-1\\f'(z)&=3z^{2}\end{aligned}}}

${\displaystyle z=1,\ -{\tfrac {1}{2}}+{\tfrac {\sqrt {3}}{2}}i,\ -{\tfrac {1}{2}}-{\tfrac {\sqrt {3}}{2}}i}$

//z^3-1
float2 Function (float2 z)
{
return cpow(z, 3) - float2(1, 0); //cpow is an exponential function for complex numbers
}

//3*z^2
float2 Derivative (float2 z)
{
return 3 * cmul(z, z); //cmul is a function that handles multiplication of complex numbers
}


float2 roots[3] = //Roots (solutions) of the polynomial
{
float2(1, 0),
float2(-.5, sqrt(3)/2),
float2(-.5, -sqrt(3)/2)
};

color colors[3] =  //Assign a color for each root
{
red,
green,
blue
}

For each pixel (x, y) on the target, do:
{
zx = scaled x coordinate of pixel (scaled to lie in the Mandelbrot X scale (-2.5, 1))
zy = scaled y coordinate of pixel (scaled to lie in the Mandelbrot Y scale (-2, 1))

float2 z = float2(zx, zy); //z is originally set to the pixel coordinates

for (int iteration = 0;
iteration < maxIteration;
iteration++;)
{
z -= cdiv(Function(z), Derivative(z)); //cdiv is a function for dividing complex numbers

float tolerance = 0.000001;

for (int i = 0; i < roots.Length; i++)
{
float2 difference = z - roots[i];

//If the current iteration is close enough to a root, color the pixel.
if (abs(difference.x) < tolerance && abs (difference.y) < tolerance)
{
return colors[i]; //Return the color corresponding to the root
}
}

}

return black; //If no solution is found
}


## 参考文献

1. ^ Simon Tatham. Fractals derived from Newton–Raphson. [2022-06-05]. （原始内容存档于2022-06-15）.
2. ^ Damien M. Jones. class Standard_NovaMandel (Ultra Fractal formula reference). [2022-06-05]. （原始内容存档于2018-12-15）.
3. ^ Damien M. Jones. dmj's nova fractals 1995-6. [2022-06-05]. （原始内容存档于2017-08-20）.
4. ^ Michael Condron. Relaxed Newton's Method and the Nova Fractal. [2022-06-05]. （原始内容存档于2022-03-28）.
5. ^ Frederik Slijkerman. Ultra Fractal Manual: Nova (Julia, Mandelbrot). [2022-07-08]. （原始内容存档于2022-01-04）.