syms x
f= cos(3*x) – x
x(1)=input('Enter your guess:');
tol=input('Enter the tolerance:');
fdash=diff((f));
for i=1:100
sym x(i+1)=x(i)-(f(x(i))/fdash(x(i))); if abs((x(i+1)-x(i)))<tol; break end
end
root=x(i).
The error I get is:
??? Error using ==> mupadmex Error in MuPAD command: Index exceeds matrix dimensions.
Error in ==> sym.sym>sym.subsref at 1366 B = mupadmex('mllib::subsref',A.s,inds{:});
Error in ==> newtonraphson2 at 8 if abs((x(i+1)-x(i)))<tol;_ * * *
Best Answer