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