# Simpson's rule with changing volumes

• noelll

Hi there,

## Homework Statement

I am doing a simulation of a free-fall lifeboat trajectory into the ocean and there is a part where i need to get the volume of the lifeboat to obtain its buoyancy force.

Buoyancy force is proportional to the immersed volume of the body and this volume can be obtain by integrating the immersed cross-section area along the length of the boat(I am using Simpson's rule 1/3 for this).

2. Homework Equations

Buoyancy force = Density*gravity*volume

Question i would like to ask, do i need to find the volume in a time-step manner, currently the ideal i have in mind is at each meter of the lifeboat length i will obtain a cross-section and after reaching the end of the lifeboat length which is 8.5 m i add up all the cross-section area? however i do not know how to do it.

## The Attempt at a Solution

i tried doing the simpson's rule. But i could only get a single number.
Code:
%INPUTS
L      = 0;   %lower limit
U      = 8.5; % upper limit
n      = 40;  % number of segments
Length = 1;
Breath = 3;
Height = 2.3;
density= 1.025;
g      = 9.81;

func = @(x) (Breath * Height);
h = (U-L)/n;

st4 = 0;
st2 = 0;

for i = 2:h:n
st4 = st4 + 4*func(i);
end

for i = 3:h:n
st2 = st2 + 2*func(n);
end

buoyancy_force = (density*g)*(h/3*(func(1)+st4+st2+func(i)));

disp (buoyancy_force)
fprintf('step %.3f\n',i);
disp (st4)
disp (st2)

I hope anybody out there could help me, really need your help, thank you so much!
Best Regards,
Noel

Last edited:

Hi there,

## Homework Statement

I am doing a simulation of a free-fall lifeboat trajectory into the ocean and there is a part where i need to get the volume of the lifeboat to obtain its buoyancy force.

Buoyancy force is proportional to the immersed volume of the body and this volume can be obtain by integrating the immersed cross-section area along the length of the boat(I am using Simpson's rule 1/3 for this).

2. Homework Equations

Buoyancy force = Density*gravity*volume

Question i would like to ask, do i need to find the volume in a time-step manner, currently the ideal i have in mind is at each meter of the lifeboat length i will obtain a cross-section and after reaching the end of the lifeboat length which is 8.5 m i add up all the cross-section area? however i do not know how to do it.

## The Attempt at a Solution

i tried doing the simpson's rule. But i could only get a single number.
Code:
%INPUTS
L      = 0;   %lower limit
U      = 8.5; % upper limit
n      = 40;  % number of segments
Length = 1;
Breath = 3;
Height = 2.3;
density= 1.025;
g      = 9.81;

func = @(x) (Breath * Height);
h = (U-L)/n;

st4 = 0;
st2 = 0;

for i = 2:h:n
st4 = st4 + 4*func(i);
end

for i = 3:h:n
st2 = st2 + 2*func(n);
end

buoyancy_force = (density*g)*(h/3*(func(1)+st4+st2+func(i)));

disp (buoyancy_force)
fprintf('step %.3f\n',i);
disp (st4)
disp (st2)

I hope anybody out there could help me, really need your help, thank you so much!
Best Regards,
Noel
Well, volume is a single number. You are calculating the area under the curve of cross-sectional areas for the hull of the lifeboat, and this area is numerically equal to the volume.

If the immersed volume of the lifeboat is changing in time, then you'll have to calculate a new volume with each time step, assuming you can determine the shape of the cross sections which compose this volume at the corresponding time.

Well, volume is a single number. You are calculating the area under the curve of cross-sectional areas for the hull of the lifeboat, and this area is numerically equal to the volume.

If the immersed volume of the lifeboat is changing in time, then you'll have to calculate a new volume with each time step, assuming you can determine the shape of the cross sections which compose this volume at the corresponding time.

Hi,
yes the immersed volume of the lifeboat is changing as it enters the water and i would need to evaluate a new volume each sec, when it dives in. However, i tried doing a while loop, and my code just kept running, my knowledge in MATLAB is at beginner's level, but i am keen to learn so i hope you could teach me what to do?

Code:
%INPUTS
L      = 0;   %lower limit
U      = 8.5; % upper limit
n      = 40;  % number of segments
Length = 1;
Breath = 3;
Height = 2.3;
density= 1.025;
g      = 9.81;

func = @(x) (Breath * Height);
h = (U-L)/n;

st4 = 0;
st2 = 0;

while (i < 40)

for i = 2:h:n
st4 = st4 + 4*func(i);
end

for i = 3:h:n
st2 = st2 + 2*func(n);
end

Buoyancy_Force = (density*g)*(h/3*(func(1)+st4+st2+func(i)));

end
disp (Buoyancy_Force)
fprintf('step %.3f\n',i);
disp (st4)
disp (st2)

The following while loop i used i<40 , the reason why i put that was, i divided the lifeboat into 40 strips and so i was thinking my simpson's rule could evaluate at every i interval till it reached the 40th strip and stop.

Thank you!,
Best Regards,
Noel

#### Attachments

• lifeboat.png
2.2 KB · Views: 465
Hi,
yes the immersed volume of the lifeboat is changing as it enters the water and i would need to evaluate a new volume each sec, when it dives in. However, i tried doing a while loop, and my code just kept running, my knowledge in MATLAB is at beginner's level, but i am keen to learn so i hope you could teach me what to do?

Code:
%INPUTS
L      = 0;   %lower limit
U      = 8.5; % upper limit
n      = 40;  % number of segments
Length = 1;
Breath = 3;
Height = 2.3;
density= 1.025;
g      = 9.81;

func = @(x) (Breath * Height);
h = (U-L)/n;

st4 = 0;
st2 = 0;

while (i < 40)

for i = 2:h:n
st4 = st4 + 4*func(i);
end

for i = 3:h:n
st2 = st2 + 2*func(n);
end

Buoyancy_Force = (density*g)*(h/3*(func(1)+st4+st2+func(i)));

end
disp (Buoyancy_Force)
fprintf('step %.3f\n',i);
disp (st4)
disp (st2)

The following while loop i used i<40 , the reason why i put that was, i divided the lifeboat into 40 strips and so i was thinking my simpson's rule could evaluate at every i interval till it reached the 40th strip and stop.

Thank you!,
Best Regards,
Noel
IDK anything about MATLAB programming, but there seems to be something strange with the structure of your loops.

You calculate h = (U - L)/n, which gives you 0.2125 using the data in your script. It's not clear how MATLAB decodes i = 2:h:n or i = 3:h:n, but if your loop counter is being incremented by 0.2125 each time, that may be a problem. h is a fixed quantity; I'm just not sure what it's doing in a loop counter.

IDK anything about MATLAB programming, but there seems to be something strange with the structure of your loops.

You calculate h = (U - L)/n, which gives you 0.2125 using the data in your script. It's not clear how MATLAB decodes i = 2:h:n or i = 3:h:n, but if your loop counter is being incremented by 0.2125 each time, that may be a problem. h is a fixed quantity; I'm just not sure what it's doing in a loop counter.

Hi!
Base on my knowledge, i = 2:h:n refers to i starting value 2 will have a increment of h till it reached the value of n .

Is this causing me the problems? What would you suggest me to do instead?

Sorry to trouble you!
Best regards,
Noel

Hi!