5
I’m trying to plot a graph of an image called Newton Fractal:
Follows model:
The problem is to plot the roots of the equation z^4 = 1
, where it has 4 roots being (-1, 1, i and -i), where to find the roots I use Newton’s method to make the approximation.
The different colors (red, green, yellow or blue) in the image mean which root Newton’s method is approaching (and black if it’s not any), but I’m not getting the code that generates the image. I’m using Scilab which is very similar to Matlab.
Follow what I’ve managed to do:
function [z] = f(x,y)
clc
f(x,y) = z^4 -1 = 0;
f1(x,y) = 4*z^3;
niter = 100;
x0 = 0.5;
for i=1:niter
for j=1:niter;
end
[X,Y] = meshgrid(x,y);
Z(i,j) = f(x(i), y(j) );
end
end
surf(X,Y,Z)
endfunction.
Look, I personally know almost nothing about Matlab, but looking at his code, it seems to me that the
end
the inner loop is in the wrong place.– Victor Stafusa