newton top xuxa
unknown
matlab
2 years ago
436 B
6
Indexable
function newtonAprox(h) hDouble = str2double(h); syms x f(x) f(x) = cos((3*x^2) + 5*x); fplot(diff(f,x,2)) 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 secondDerative = diff(f,x,2) 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...