Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- f(x)=x^2-2*x-5
- a=3
- b=4
- Ans:
- 3.4
- 3.4444444
- 3.4489796
- 3.4494382
- */
- function[] = regula_falsi(f);
- a=input('Value of a: ')
- b=input('Value of b: ')
- if(f(a)*f(b)<0)
- for i=1:4
- x=(a*f(b)-b*f(a))/(f(b)-f(a));
- if(f(x)*f(b)<0)
- a=x
- else
- b=x
- end
- disp(x)
- end
- end
- endfunction
- deff('y=f(x)',['y=x^2-2*x-5'])
- regula_falsi(f)
Add Comment
Please, Sign In to add comment