2) روش نیوتون ( Newton Method ) دانلود رمز فایل : AliAshouri
disp (' This is the code of Newton-Raphson 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 (' at first calculate the differential of function which used in this method.so write at commond window:')
disp (' ')
disp (' syms y;')
disp (' diff(f(y)) ------- f(y) is your function at term like sin(y) or y.^2')
disp (' ')
disp (' ')
disp (' then y must be at double class and write its limit in commond window. like: y=-1:0.00001:1')
disp(' ')
disp (' function should be start by @(x) like : @(x) sin(x)')
disp (' ')
disp (' ')
disp (' Differential function should be start by @(y) like : @(y) cos(y)')
disp (' ')
f=input('enter your function: ');
h=input('enter your differential of function: ');
x0=input('enter the initial number : ');
disp(' ')
disp(' ')
disp (' choose one of the model for stoping criterion and input as char:')
disp (' abs(f(xn))<=eps abs(f(xn))=P eps=d')
disp (' abs(xn-x0)<=eps abs(xn-x0)=P eps=d')
disp (' ')
disp (' ')
P=input('choose P as char: ');
d=input('enter the epsilon number : ');
tic
double (x);
n=1;
xn=x0-f(x0)./h(x0);
disp('n I x0 I x I f(xn)')
disp ------------------------------------------------------------------------------------------------------------------------------------
r=[num2str(n),' I ',num2str(x0),' I ',num2str(xn),' I ',num2str(f(xn))];
disp (r)
switch P
case 'abs(f(xn))'
while abs(f(xn))>=d
x0=xn;
xn=x0-f(x0)./h(x0);
n=n+1;
r=[num2str(n),' I ',num2str(x0),' I ',num2str(xn),' I ',num2str(f(xn))];
disp (r)
end;
case 'abs(xn-x0)'
while abs(f(xn))>=d
x0=xn;
xn=x0-f(x0)./h(x0);
n=n+1;
r=[num2str(n),' I ',num2str(x0),' I ',num2str(xn),' I ',num2str(f(xn))];
disp (r)
end;
otherwise
disp ('your model choice is incorrect')
end;
disp (' ')
disp ([' c= ',num2str(xn)])
disp ([' n= ',num2str(n)])
toc;
میخام همه جوره بهت کمک کنم خداییش دمت گرم ایمیلتو برام ایمیل کن تا هروقت چیزی دستم رسید برات بفرستم بزاری تو وبلاگ.
خداییش دمت گرم