Untitled
unknown
plain_text
2 years ago
578 B
5
Indexable
function newtonAprox1(h) h = str2double(h); x = 0:h:13/10; % domain %syms x s f(x) aprox(s) f = cos((3*x.^2) + 5*x); firstDerivative = diff(f)/h; secondDerivative = diff(firstDerivative)/h; fplot(secondDerivative) hold on aprox = f(x + 4*h); %aprox = (f(x+4*h)- 2*f(x) + f(x-4*h))/(16*h^2); plot(aprox) hold off z=h; difs = []; while z <= 1+3/10 dif = aprox(z) - secondDerivative(z); difs = [difs, dif]; z=z+h; end error = max(difs); disp(error) end
Editor is loading...