Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [xo,n]=falsi (f,a,b,tol,ftol)
- if (f(a)*f(b)<0)
- n=0;
- h = 10^(-5);
- pochodna=(f(a+h)-(2*f(a))+f(a-h))/h^2;
- if(f(a)*pochodna>0)
- xs=a;
- xo=b;
- else
- xs=b;
- xo=a;
- end
- while(1)
- n=n+1;
- xpop=xo;
- xo=xs-f(xs)*((xo-xs)/(f(xo)-f(xs)));
- if(abs(f(xo))<ftol)
- break;
- end
- if(abs(xpop-xo)<tol)
- break;
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement