Professional Documents
Culture Documents
i = 1;
p0 = 1; %initial conditions
N = 100; %maximum number of iterations
error = 0.00000001; %precision required
syms 'x'
f(x) = x^2 - 6; %the function we are root finding.
dx = diff(f); %first and second derivatives of f(x)
ddx = diff(dx);
while i <= N
p = p0 - (f(p0)/dx(p0))*(1 - (f(p0)*ddx(p0)/dx(p0)^2))^(-1);
%Implementation og Halleys Methof (i.e. g(x)).
i = i + 1;
p0 = p; %update p0
end
end