mihainan

Lab 06

Apr 3rd, 2014
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.31 KB | None | 0 0
  1. function [ x ] = Newton(x0, f, fd, N, eps, maxiter)
  2.  
  3. maxval = maxiter;      
  4. x1 = x0;
  5.  
  6.     for i=N:-1:0
  7.         xn = xx - f(x1) /fd(x1);
  8.         if abs(f(xn)) < eps
  9.             x = xn;
  10.             iter = 100 - N;
  11.             return
  12.         endif
  13.    
  14.         if abs(f(x1)) > maxval
  15.             disp("Nu converge!");
  16.             break;
  17.         endif
  18.    
  19.         x1 = xn;
  20.     endwhile
  21. endfunction
Advertisement
Add Comment
Please, Sign In to add comment