Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function result = metoda_newtona(funkcja,precision,a,b)
- format long;
- fun=inline(funkcja,'x');
- diff=inline('x*(3*x-4)','x');
- n=1;
- x0=b;
- x(n)=(((x0)-(fun(x0))) / (diff(x0)));
- result_1= fun(x(n));
- result_2= diff(x(n));
- while( abs(result_1) > precision )
- x(n+1)= (x(n)-((fun(x(n))))*(1/(diff(x(n)))));
- result_1 = fun(x(n));
- result_2 = diff( x(n) );
- n++;
- endwhile
- result=x(n);
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement