//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
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
very easy code solution Thanks!
ReplyDeleteI want code solution for bisection method
ReplyDeletehow to run this on console
ReplyDeleteOpen 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..
DeleteIf there are errors then it will display otherwise it will show output....
please reply
ReplyDeleteit works well !
ReplyDeletehow about if there is an equation, how do i input it to the code?
ReplyDeletevery nice, easy to use and execute.....
ReplyDeleteNice solution, Thank you so much
ReplyDelete