Using Matlab
1. Give the flowchart for finding the root of the function f(x) = [tanh(x-2)] [sin(x+3)+2]
with the following methods (6 significant figures required):
a) Modified Regula Falsi (Choose two reasonable integers as your initial upper and lower bounds)
b) Newton’s Method (Choose one reasonable integer as your initial guess for the root)
% Newton
f=@(x) tanh(x-2).*(sin(x+3)+2);
deriv_f=@(x) tanh(x-2).*(cos(x+3))+
(sech(x-2))^2.*(sin(x+3)+2);
x=1;
for i=1:10
x=x-f(x)/deriv_f(x);
end
disp('Newton Solution is : ')
disp(x)
% Regula -falsi modified
a=2.1;
b=1.91;
if (f(a)*f(b)<0)
c=b-(f(b)*(b-a))/(f(b)-f(a));
for i=1:20
if(f(b)*f(c)<0)
a=b;
b=c;
c=b-(f(b)*(b-a))/(f(b)-f(a));
else
b=c;
c=b-(f(b)*(b-a))/(f(b)-f(a));
end
end
else
disp('Error ')
end
disp('Regular Falsi Method:')
disp(c)
Get Answers For Free
Most questions answered within 1 hours.