Scilab Program - regula falsi method while loop - IProgramX


Program

function[]=gf(a,b,d,f)
    c=(a*f(b)-b*f(a))/(f(b)-f(a))
    while(abs(f(c))>d)
        c=(a*f(b)-b*f(a))/(f(b)-f(a))
        if(f(a)*f(c)<0)then b=c
        elseif(f(c)*f(b)<0)then a=c
        end
    end
    printf('root by regular falsi method=%f',c)
endfunction

Output:

-->deff('y=f(x)','y=x*tan(x)+1')

-->gf(2.5,3,50,f)
root by regular falsi method=2.801252 

Post a Comment

0 Comments