function Newton (y,z,err)
sym x
g = diff (y);
m = inline (g);
f = inline (y);
s = z - ( f(z) / m(z) );
if ( m(z) == 0 )
error (' Warning: Please try again ');
else
fprintf (' z f(z)\n\n ');
while ( abs (f(z)) > err )
fprintf (' %f2.6 %f2.6 \n\n ',z,f(z));
if( m(z) == 0 )
break;
else
z = s;
end
s = z - ( f(z) / m(z) );
end
fprintf (' %f2.6 %f2.6 \n\n ',z,f(z));
fprintf (' The Root is = %g \n\n ',z);
end
end
شامل 5 صفحه فایل word قابل ویرایش
دانلود مقاله برنامه محاسبات عددی