secant_64

# secant_64 - if i == 1 else Ea(i,1 =...

This preview shows page 1. Sign up to view the full content.

function secant_64 f dx = 0.001; d xi = zeros(6,1); x x_dx = zeros(6,1); x fx = zeros(6,1); f fxdx = zeros(6,1); f dfx = zeros(6,1); d Ea = zeros(6,1); E xi(1,1) = 0.3; x Ea(1,1) = 0; E for i = (1:6) x_dx(i,1) = xi(i,1) + dx*xi(i,1); fx(i,1) = F(xi(i,1)); fxdx(i,1) = F(x_dx(i,1)); dfx(i,1) = (fxdx(i,1) - fx(i,1))/(dx*xi(i,1)); xi(i+1,1) = xi(i,1) - (dx*xi(i,1)*fx(i,1))/(fxdx(i,1) - fx(i,1));
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if i == 1 else Ea(i,1) = abs((xi(i,1)-xi(i-1,1))/xi(i,1))*100; end end i = (0:5)'; fprintf (' i x x + dx f(x) f(x+dx) df(x) Ea\n') for r = (1:6) fprintf('%3d %8.6f %8.6f %8.6f %8.6f %8.6f %7.3f\n', i(r,1), xi(r,1), x_dx(r,1), fx(r,1), fxdx(r,1), dfx(r,1), Ea(r,1)) end end e function new1 = F(x) f new1 = 8*sin(x)*exp(-x) - 1; n end...
View Full Document

Ask a homework question - tutors are online