Final 6666
Final 6666
2. Problem description.
A company makes floats for toilets. The floating ball has a specific gravity of 0.6 and
has a radius of 5.5 cm. We are required to apply numerical methods, incorporated
into computer programs, to find the depth to which the ball is submerged under water.
1
3. Derivation of the equation for the depth.
According to Newton’s third law of motion, every action has an equal and opposite reaction. In
this case, the weight of the ball is balanced by the buoyancy force .
Weight of ball = Buoyancy force (1)
The weight of the ball is given by
Weight of ball = (Volume of ball) (Density of ball) (Acceleration due
To gravity)
= (4/3 𝜋𝑅 3 ) (ρ𝑏 ) (𝑔) (2)
Where
R = radius of ball (m),
ρ = density of ball (kg/𝑚2),
g = acceleration due to gravity (m/𝑠 2).
The buoyancy force is given by
The buoyancy force = weight of water displaced
= (Volume of ball under water) (Density of water) (Acceleration due to gravity)
𝑥
= 𝜋𝑥 2 (𝑅 - ) ρ𝑤 𝑔 (3)
3
Where
x = depth to which ball is submerged,
ρ𝑤 = density of water.
2
substituting Equations (2) and (3) in Equation (1),
4 /3 𝜋𝑅 3 ρ𝑏𝑔 = 𝜋𝑥 2 (𝑅 – 𝑥 3) ρ𝑤 𝑔
4𝑅 3 ρ𝑏 = 3𝑥 2 (𝑅 – 𝑥 3) ρw
4𝑅 3 ρ𝑏 – 3𝑥 2𝑅ρ𝑤 + 𝑥 3 ρ𝑤 = 0
4𝑅 3 ρ𝑏 / ρ𝑤 – 3𝑥 2𝑅 + 𝑥 3= 0
4𝑅 3 γ𝑏 – 3𝑥 2𝑅 + 𝑥 3= 0 (4)
Where
The sp ecific gravity of the ball, 𝛾𝑏 is given by
ρ𝑏
γ𝑏 = (5)
ρ𝑤
Given
R = 5.5cm = 0.055 m,
γ𝑏 = 0.6, and
Substituting in Equation (4), we get
3
Derivation of the formula for the volume of a ball submerged under water.
Where
r = radius of the ball,
h = height of the ball to which the ball is submerged.
From calculus,
Where A is the cross-sectioned area at a distance x from the center of the sphere. The lower
limit of integration is x = r-h as that is where the water line is
And the upper limit is r as that is the bottom of the sphere. So, what is the A at any location
X
From the above Figure, for a location x,
OB = x,
OA = r,
4
Then
𝐴𝐵 = √𝑂𝐴2 − 𝑂𝐵2
= √𝑟 2 − 𝑥 2 (9)
𝐴 = π(𝐴𝐵) 2 = π(𝑟 2 − 𝑥 2 ) (10)
𝑟
𝑉 = ∫ 𝜋(𝑟 2 − 𝑥 2 ) ⅆ𝑥
𝑟−ℎ
𝑟
𝑥3
= 𝜋 (𝑟 2 𝑥 − )
3 𝑟−ℎ
𝑟3 (𝑟−ℎ) 3
= 𝜋 [(𝑟 2 𝑟 − ) − (𝑟 2 (𝑟 − ℎ) − )]
3 3
𝜋ℎ2( 3𝑟−ℎ)
= (11)
3
f(x)=0
so
f(x)= 𝑥 3– 0.165𝑥 2 +3.993 ×10−4
The above equation is a nonlinear equation. Solving it by Bisection Method
and Newton-Raphson Method it would give us the value of ‘𝑥’, that is, the depth to which the
ball is submerged under water.
5
4. Solution by the Bisection method.
4.1. Flow chart.
6
4.2. Program.
function bisection_iteration()
% Define the function
% Interval [a, b]
XL = 0; % Lower bound
XU = 0.11; % Upper bound
R_error = 0.05; % Relative error tolerance (%)
maxIter = 1000; % Safety limit to avoid infinite loops
iter = 0;
rel_error = Inf; % Initialize relative error
% Display results
fprintf('%5d %8.6f %8.6f %8.6f %8.6f %8.6f\n', ...
iter, XL, XU, XM, fm, rel_error);
end
subplot(2, 1, 2);
plot(iterations, rel_errors, '-o', 'LineWidth', 1.5);
title('Relative Error Over Iterations');
xlabel('Iteration');
ylabel('Relative Error (%)');
grid on;
if iter == maxIter
warning('Maximum number of iterations reached before meeting tolerance.');
end
end
7
4.3. Result.
8
5. Solution by the Newton-Raphson method.
5.1. Flow chart
9
5.2. Program.
% Define the function and its derivative
f = @(x) x^3 - 0.165*x^2 + 3.993*10^-4;
fd = @(x) 3*x^2 - 0.33*x;
% Newton-Raphson iteration
while E > Es
I = I + 1;
Xn = X0 - f(X0) / fd(X0); % Newton-Raphson formula
E = abs((Xn - X0) / Xn) * 100; % Calculate relative error
subplot(2, 1, 2);
plot(iterations, errors, '-o', 'LineWidth', 1.5);
xlabel('Iteration');
ylabel('Relative Error (%)');
title('Convergence of Relative Error');
grid on;
10
5.3. Result.
Iteration Xn |𝜺𝒂 |% S
1 0.0624 19.9003 0
2 0.0624 0.0716 2
3 0.0624 0.0000 4
11
6- Discussion
The Bisection Method and Newton-Raphson Method are numerical techniques for
finding equation roots, each suited to different scenarios. The Bisection Method, a
robust bracketing technique, converges linearly and is ideal for functions with
unknown characteristics or multiple roots. In contrast, the Newton-Raphson Method
converges quadratically, offering higher computational efficiency but requiring a
good initial guess and being sensitive to function behavior. The choice between
them depends on the problem's characteristics and the balance between robustness
and efficiency.
Hence in our example it is better to use the newton Raphson method because of its fast
convergence and also us having a good initial guess.
Newton-Raphson gave us the solution in three iterations while the bisection method gave us the
same result but in eleven iteration.
12
References
1-https://nm.mathforcollege.com
2-https://lucid.app/documents#/dashboard?folder_id=home
3-https://matlab.mathworks.com
13
Appendices
14