روش نابجایی ( Regular falsi method ) دانلود رمز فایل : AliAshouri
disp (' This is the code of Regular falsi method.Is writen by Ali Ashouri')
disp (' ')
disp (' ')
disp (' ********Before enter anything read all of introduction that will write. read all of them*******')
disp (' ')
format long
disp (' x must be at double class and before play the program write its limit in commond window. like: x=-1:0.00001:1')
disp (' ')
disp (' function should be start by @(x) like : @(x) sin(x)')
disp (' ')
f=input('enter your function: ');
a=input('enter the first number of limit: ');
b=input('enter the final number of limit : ');
d=input('the epsilon number : ');
tic
double (x);
n=1;
xn=(a*f(b)-b*f(a))/(f(b)-f(a));
disp('n I a I b I c I f(a) I f(c)')
disp ------------------------------------------------------------------------------------------------------------------------------------
r=[num2str(n),' I ',num2str(a),' I ',num2str(b),' I ',num2str(xn),' I ',num2str(f(a)),' I ',num2str(f(xn))];
disp (r)
while abs(f(xn))>=d
if (f(xn)*f(a))<0
b=xn;
else
a=xn;
end
xn=(a*f(b)-b*f(a))/(f(b)-f(a));
n=n+1;
r=[num2str(n),' I ',num2str(a),' I ',num2str(b),' I ',num2str(xn),' I ',num2str(f(a)),' I ',num2str(f(xn))];
disp (r)
end;
disp (' ')
disp ([' c= ',num2str(xn)])
disp ([' n= ',num2str(n)])
toc;