newton final
unknown
matlab
3 years ago
453 B
4
Indexable
function newtonAprox(h)
hDouble = str2double(h);
syms x f(x)
f(x) = cos((3*x^2) + 5*x);
secondDerative = diff(f,x,2)
fplot(secondDerative)
hold on
syms aprox(x)
aprox(x) = (f(x+4*hDouble)- 2*f(x) + f(x-4*hDouble))/(16*hDouble^2);
fplot(aprox)
hold off
z=hDouble;
difs = [];
while z <= 1+3/10
dif = aprox(z) - secondDerative(z)
difs = [difs, dif];
z=z+hDouble;
end
error = max(difs)
disp(error)
end
Editor is loading...