Find the cube root of 25 to four decimal places, using: The midpoint method The
ID: 3168154 • Letter: F
Question
Find the cube root of 25 to four decimal places, using: The midpoint method The secant method (two-point recursion) Regula falsi Newton's method Aitken's method to improve the worst of the linear methods Find the cube root of 25 to four decimal places, using: The midpoint method The secant method (two-point recursion) Regula falsi Newton's method Aitken's method to improve the worst of the linear methods The midpoint method The secant method (two-point recursion) Regula falsi Newton's method Aitken's method to improve the worst of the linear methodsExplanation / Answer
%%%%%%%%%%%% Matlab code
clc;
clear all;
close all;
format long;
syms x
f=x^3-25;
tol=0.0001;
% % % bisection method
disp('Bisection method :');
a=0;
b=3;
for n=1:100;
l1=subs(f,a);
l2=subs(f,b);
c(n)=(a+b)/2;
l3=subs(f,c(n));
if (n>2)
if (abs( c(n)-c(n-1))< tol)
break;
end
end
if ( l3 < 0 )
a=c(n);
else
b=c(n);
end
end
fprintf('cube roots of 25 is : %f ', c(end) );
% %%% Secant method
y(1)=0;
y(2)=3;
disp('Secant method');
for n=2:100
f1=subs(f,y(n));
f2=subs(f,y(n-1));
y(n+1)=y(n)-f1*(y(n)-y(n-1))/(f1-f2);
err=abs(y(n+1)-y(n));
if ( err < tol)
break;
end
end
fprintf('cube roots of 25 is : %f ', y(n+1) );
%%%Regula False Position method
disp('Regula False-position method ');
%
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('cube roots of 25 is : %f ', y(n+1) );
% % % % N-R Method
disp('Newton Raphson method');
s(1)=3;
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('cube roots of 25 is : %f ', s(end) );
OUTPUT:
Bisection method :
cube roots of 25 is : 2.924103
Secant method
cube roots of 25 is : 2.924018
Regula False-position method
cube roots of 25 is : 2.924018
Newton Raphson method
cube roots of 25 is : 2.924018
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.