Dear sir. i need only the matlab parts. thank you. regards 1. The following equa
ID: 3184918 • Letter: D
Question
Dear sir.
i need only the matlab parts.
thank you.
regards
Explanation / Answer
%%% Matlab programm for regula falsi method
%
syms x
f=10*(1-exp(-0.04*x))+4*exp(-0.04*x);
tol=10^(-6);
y(1)=0;
y(2)=3;
for n=2:100
f1=subs(f,y(n));
f2=subs(f,y(n-1));
y(n+1)=(y(n-1)*f1-y(n)*f2)/(f1-f2);
if ( abs(y(n+1)-y(n)) < tol)
break;
end
end
fprintf('Roots of equation at the end of iteration : %f ', y(n+1) );
OUTPUT:
Roots of equation at the end of iteration : -12.770641
%%% NR - Method
syms x
f=10*(1-exp(-0.04*x))+4*exp(-0.04*x);
tol=10^(-6);
% % % % N-R Method
% disp('Newton Raphson method');
s(1)=0;
for n=1:100
l1=subs(f,s(n));
l2=subs(diff(f),s(n));
s(n+1)=s(n)-l1/l2;
e=abs(s(n+1)-s(n));
if (e < tol)
break;
end
end
fprintf('Roots of equation at the end of iteration is : %f ', s(end) );
OUTPUT:
Roots of equation at the end of iteration is : -12.770641
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.