Regular Falsi Method

//Regular Falsi Method

deff('d=f(x)','d=x^3-100')
a=input("Enter the value of a:")
b=input("Enter the value of b:")
n=input("Enter the number of iterations n:")
for i=1:n
    c=(a*f(b)-b*f(a))/(f(b)-f(a))
    disp([i,c])
if f(a)*f(c)<0 then
    b=c
end
if f(b)*f(c)<0 then
    a=c
end
c1=(a*f(b)-b*f(a))/(f(b)-f(a))
if abs(c1-c)<0.00001 then
    disp("We get accurate roots")
    break;
    end
end

Output
-->exec('D:\Scilab prog by me\Regular Falsi.sce', -1)
Enter the value of a:4
Enter the value of b:5
Enter the number of iterations n:100

    1.    4.5901639

    2.    4.6377884

    3.    4.6413098

    4.    4.6415684

    5.    4.6415873

 We get accurate roots  

9 comments:

  1. I want code solution for bisection method

    ReplyDelete
  2. Replies
    1. Open scilab->click on first icon below file option->A blank file will open->write your code in it->then click on execute and click 'Save and execute'->now go to scilab->write the function name (the function that you have defined in that code)->Press Enter..
      If there are errors then it will display otherwise it will show output....

      Delete
  3. how about if there is an equation, how do i input it to the code?

    ReplyDelete
  4. very nice, easy to use and execute.....

    ReplyDelete
  5. Nice solution, Thank you so much

    ReplyDelete