fork download
  1. f=@(x)exp(-x)-x;
  2. df=@(x)-exp(-x)-1;
  3. root=fzero(f,0.6);
  4. % N-R method
  5. x(1)=1;
  6. x(2)=x(1)-f(x(1))/df(x(1));
  7. err_app(1)=1;
  8. err_app(2)=abs((x(2)-x(1))/x(2));
  9. i=2;
  10. while err_app(i)>=eps
  11. i=i+1;
  12. x(i)=x(i-1)-f(x(i-1))/df(x(i-1));
  13. err_app(i)=abs((x(i)-x(i-1))/x(i));
  14. end
  15. iteration=[1:1:i];
  16. plot(iteration, err_app);
  17.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.d(1): no identifier for declarator f
prog.d(1): expression expected, not '@'
prog.d(1): semicolon expected, not 'exp'
prog.d(1): found '-' when expecting ')'
prog.d(1): no identifier for declarator exp
prog.d(1): semicolon expected, not 'x'
prog.d(1): no identifier for declarator x
prog.d(1): semicolon expected, not ')'
prog.d(1): Declaration expected, not ')'
prog.d(2): no identifier for declarator df
prog.d(2): expression expected, not '@'
prog.d(3): no identifier for declarator root
prog.d(4): Declaration expected, not '%'
prog.d(6): found '2' when expecting ')'
prog.d(6): no identifier for declarator x
prog.d(6): semicolon expected, not ')'
prog.d(6): Declaration expected, not ')'
prog.d(7): found '1' when expecting ')'
prog.d(7): no identifier for declarator err_app
prog.d(7): semicolon expected, not ')'
prog.d(7): Declaration expected, not ')'
stdout
Standard output is empty