Im this case V=170cm^3, r =3cm and h=10cm False Position method (3 iterations) c
ID: 3281639 • Letter: I
Question
Im this case V=170cm^3, r =3cm and h=10cm
False Position method (3 iterations) calculate approx relative error ea employ intial guess xo=r
Newton Raphson method
False position malb function
An ice cream drum is made of a waffle cone filled with ice cream such that the ice cream above the cone forms a spherical cap. The volume of the ice cream is given by: Determine H using the Newton-Raphson method if h-4n, r1.1 in and V -1/3 U.S. pint. (1 US. Pint-28.875 in3) . Use an initial value of H 3in Set the maximum number of iterations to 30 the solution reaches the specified accuracy it will stop Hint: Set your equation equal to 0 to find the root. . Set the absolute error on H to 0.01 in . Include a break statement or use a while loop so whenExplanation / Answer
%%%% Newton method
clc;
clear all;
V=170;
r=3;
h=10;
format long
f=@(H)pi*((r^3*h/3)+r^2*H/2+H^3/6)-V; %function
df=@(H)pi*(r^2/2+3*H^2/6);% derivative of function
x=3; %initial value
x1=x;
tol=1e-2;
ebs=0.1;
n=1;
max_iter=30;
disp('_____________________________________________________________________________________')
disp('n x(n)) f(x(n)) error')
disp('_____________________________________________________________________________________')
while(ebs>tol&n<max_iter)
x(n+1)=x(n)-(f(x(n))/df(x(n))); %newton method
x1(n+1)=x1(n)+f(x1(n));
%x=x1;
erorr(n)=abs((f(x(n))/df(x(n))));
ebs=abs(f(x(n)));
y=df(x(n));
fprintf('%d %15f %15f %15f ',n ,x(n),f(x(n)),erorr(n))
n=n+1;
end
f_zer=x(end)
%% Solution
_____________________________________________________________________________________
n x(n)) f(x(n)) error
_____________________________________________________________________________________
1 3.000000 169.292007 5.987480
2 -2.987480 56.547930 2.008338
3 -4.995818 -23.169124 0.434355
4 -4.561463 -1.437621 0.030705
5 -4.530758 -0.006740 0.000145
f_zer =
-4.530612382898211
>>
%%%% Falsi method
clc;
clear all;
V=170;
r=3;
h=10;
f=@(H) pi*((r^3*h/3)+r^2*H/2+H^3/6)-V ; %Given function
% a=input('Starting point a=');
% b=input('End point b=');
% N=input('Number of iteration N=');
a=3; %starting point
b=5; % end point
if(f(b)<f(a))
m=a;
a=b;
b=m;
end
n=1;
N=3150;
err=0.1;
while((err>1e-3)&&n<N)
c=(a*f(b)-b*f(a))/(f(b)-f(a));% false method formula
if ( f(c) == 0 )
break;
elseif ( f(a)*f(c) < 0 )
b = c;
else
a = c;
end
err=abs(a-b);
C1(n)=c;
n=n+1;
end
C1(end)
%%%% Solution %%
ans =
-4.530612379657956
>>