Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.47 KB | None | 0 0
  1.  function result = metoda_newtona(funkcja,precision,a,b)
  2.  format long;
  3.  fun=inline(funkcja,'x');
  4.    
  5.     diff=inline('x*(3*x-4)','x');
  6.     n=1;
  7.     x0=b;
  8.     x(n)=(((x0)-(fun(x0))) / (diff(x0)));
  9.     result_1= fun(x(n));
  10.     result_2= diff(x(n));
  11.  
  12.        while( abs(result_1) > precision )
  13.  
  14.          x(n+1)= (x(n)-((fun(x(n))))*(1/(diff(x(n)))));
  15.           result_1 = fun(x(n));
  16.            result_2 = diff( x(n) );
  17.             n++;
  18.  
  19.        endwhile
  20.  
  21.   result=x(n);
  22. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement