# Plot Newtons Basin of Attraction using given roots

How can I use the following code without the use of solve command if I new the roots of my system of equations. My equations are a bit complex and solve command is taking to much processing time even after three hours I had no luck. I have found the roots of my equations graphically and want to use in the following command please help that how can I do so. I am a beginner and don't know much. Thanks in advance.

V[x_, y_] := 1/2 (x^2 + y^2) - y (1/3 y^2 - x^2)

Vx = D[V[x, y], x]
Vy = D[V[x, y], y]
Vxx = D[V[x, y], {x, 2}]
Vyy = D[V[x, y], {y, 2}]
Vxy = D[V[x, y], x, y]
Vyx = D[V[x, y], y, x]

**sol = Solve[{Vx == 0, Vy == 0}, {x, y}]**

newton[{x_, y_}] := {x,
y} - {Simplify[(Vx Vyy - Vy Vxy)/(Vyy Vxx -
Vxy^2)], -Simplify[(Vx Vyx - Vy Vxx)/(Vyy Vxx - Vxy^2)]}

newton[{x_, y_}] := {x,
y} - {(x (-1 + 2 x^2 + 2 y + 2 y^2))/(-1 + 4 x^2 +
4 y^2), ((1 + 2 y) (x^2 + (-1 + y) y))/(-1 + 4 x^2 + 4 y^2)}
t = Vx Vyy - Vy Vxy

tab = ParallelTable[
FixedPoint[newton, {i, j}], {j, -2, 2, 0.003}, {i, -2, 2, 0.003}];

rules = Rule @@@ Transpose[{sol[[;; , ;; , 2]], Range[Length[sol]]}]
newtab = Map[First@Nearest[rules, #] &, tab, {2}]

ArrayPlot[newtab, ColorFunction -> "Rainbow", DataReversed -> True]$$$$


## 1 Answer

V[x_, y_] := 1/2 (x^2 + y^2) - y (1/3 y^2 - x^2)

Vx = D[V[x, y], x]
Vy = D[V[x, y], y]
Vxx = D[V[x, y], {x, 2}]
Vyy = D[V[x, y], {y, 2}]
Vxy = D[V[x, y], x, y]
Vyx = D[V[x, y], y, x]

(*sol=Solve[{Vx\[Equal]0,Vy\[Equal]0},{x,y}]*)

mat = {{x -> 0, y -> 0}, {x -> 0, y -> 1}, {x -> -(Sqrt[3]/2),
y -> -(1/2)}, {x -> Sqrt[3]/2, y -> -(1/2)}};
newton[{x_, y_}] := {x,
y} - {Simplify[(Vx Vyy - Vy Vxy)/(Vyy Vxx -
Vxy^2)], -Simplify[(Vx Vyx - Vy Vxx)/(Vyy Vxx - Vxy^2)]}

newton[{x_, y_}] := {x,
y} - {(x (-1 + 2 x^2 + 2 y + 2 y^2))/(-1 + 4 x^2 +
4 y^2), ((1 + 2 y) (x^2 + (-1 + y) y))/(-1 + 4 x^2 + 4 y^2)}
t = Vx Vyy - Vy Vxy

tab = ParallelTable[
FixedPoint[newton, {i, j}], {j, -2, 2, 0.3}, {i, -2, 2, 0.3}];

rules = Rule @@@ Transpose[{mat[[;; , ;; , 2]], Range[Length[mat]]}]
newtab = Map[First@Nearest[rules, #] &, tab, {2}]

ArrayPlot[newtab, ColorFunction -> "Rainbow", DataReversed -> True]


Does the deal. Have fun.

This uses knowledge instead of sol. The number of solutions of sol is 4 and the values of the solution sol from the position in the rules.

Span

Part

These values are the kernel of the representation filtered out of the matrix newtab.

Another step further is to make use of the Properties and Relations section of the documentation page for ArrayPlot.

A strong relation is

ListDensityPlot[
Table[1/2 (x^2 + y^2) - y (1/3 y^2 - x^2), {x, -2, 2, 0.03}, {y, -2, 2, 0.03}],
ColorFunction -> "Rainbow"]


ListDensityPlot[
Table[newton[{x, y}], {x, -2, 2, 0.03}, {y, -2, 2, 0.03}],
ColorFunction -> "Rainbow"]


This algorithm implementation is slightly different:

f[z_] := z^3 - 1;
newton[f_, z_, z0_] :=
Block[{df = D[f, z], fz0, dfz0}, fz0 = (f /. z -> z0);
dfz0 = (df /. z -> z0);
z0 - fz0/dfz0];
nt = Compile[{{z0, _Complex}}, Evaluate@newton[z^3 - 1, z, z0],
CompilationTarget -> "C", RuntimeOptions -> "Speed"];
iterAlgorithm =
Compile[{{c, _Complex}, {lim, _Integer}, {delta, _Real}},
Module[{z1 = c, z2 = nt[c], ctr = 0},
While[ctr < lim && Abs[z2 - z1] > delta, ++ctr;
z1 = z2;
z2 = nt[z1];];
(3*(Arg[z2] + \[Pi] - \[Pi]/3))/(2 \[Pi]) + ctr/lim],
RuntimeOptions -> "Speed", CompilationTarget -> "C",
RuntimeAttributes -> {Listable}, Parallelization -> False];
makeFractal[iterAlgorithm_, lim_, delta_, points_, range_] :=
iterAlgorithm[
Table[x + y I, {y, range[[2, 1]],
range[[2, 2]], (range[[2, 2]] - range[[2, 1]])/points}, {x,
range[[1, 1]],
range[[1, 2]], (range[[1, 2]] - range[[1, 1]])/points}], lim,
delta];

ArrayPlot[
Quiet@makeFractal[iterAlgorithm, 25, 0.001, 128, {{-3, 3}, {-3, 3}}],
PlotRange -> {0, 4}, ColorFunctionScaling -> False,
ColorFunction -> (Darker[
Switch[IntegerPart[#], 0, Yellow, 1, Blue, 2, Red],
FractionalPart[#]] &)]
`

But it still works with the zeros. This is a different potential with almost the very same result in a different resolution and with different coloring.

This belongs to the category of iterative generative computer graphics that depend on the abstract algorithms classes for fractals. The set of zeros is characteristic of the resulting graphics. They are fixpoints of the iteration and like the time needed to converge and the complexity of the resulting specialist algorithm, these are characteristics of the mathematical problem.

As the representation of the iteration step, the choice of the exactness of the zeros/fix points are only important for the actual speed of how the resulting graphics is generated.

In some cases there is a choice among the zeros or fixpoint set but with the surrounding adopted to that choices. Some call the using the loupe.

There is general discussion about these problem category: http://ocw.mit.edu/ans7870/resources/Strang/Edited/Calculus/Calculus.pdf.

There was risen the question of whether there is a correspondence between real attractors in physics and those from the corresponding fractal system. Since there zeros and fixpoint often are the same. And in general, there is none. As is the case that nice fractals do not need to produce beautiful curves of motion.

One strategy aspect is in common, each set of zeros or fixpoint are in need a careful investigation. For zero that is a methodology for finding them and all of them. For the fixpoints find them, identify them, calculate the speed of convergence for the selected starting point set. Each step is rather difficult and more complex than the calculation of such graphics is after the algorithm is taken from the literature. There are books around emergent from investigation of fractals and the attempts of there application to real meaningful systems.

Fractals are a while around and there are at present plenty of articles around summing up the net effect, the benefits of fractals and the perspective of fractals in the future. There has not been much. Search for example the publications of Science.