Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hello I will put the question the I will put the function mentioned in the quest

ID: 670511 • Letter: H

Question

hello

I will put the question the I will put the function mentioned in the question

the question :

Euler`s method is simply a rst order Taylor series expansion
f(xi+1) = f(xi) + f0(xi)h + R1 (3)
where R1 is the truncation error of the rst order Taylor series expansion and it has the following
form:
R1 =
f00(c)h2
2!
(4)
Thus when we halve the step size, we expect the error go down by the step size squared. For exam-
ple, if we changed the step size h from 1 to 0.5, we would expect the error term R1 to be reduced
from its initial value to 0.25 times that value.
Now, let's go back to our skydiver example. Function skydiver_ error (Find this function in HW2
folder) gives true and approximate percent error for skydiver falling speed at t = 10 sec using four
dierent time increments (step sizes). Results arising from this function shows that halving the step
size cut the error in half which conicts the explanation given above. Explain why we observe this
conict.

the function :

function skydiver_error(m,g,c)
% Function to calculate true and approximate percent
% error for skydiver falling speed at t = 10 sec using
% four different time increments
%
% Inputs: mass m (kg)
% gravity g (m/s^2)
% drag coefficient c (kg/m)
% time increment dt (s)
% All inputs are passed into the function.
%
% Outputs: final falling speed v (m/s)
% true percent error et (%)
% approximate percent error ea (%)

% Assign 4 dt values
dt = [2 1 0.5 0.25]';

% Allocate memory for approximate solutions
vapprox = zeros(4,1);

% Calculate analytical solution at t = 10 sec
vtrue = sqrt(m*g/c)*tanh(sqrt(g*c/m)*10);

% Allocate memory for true and approximate percent errors
et = zeros(4,1);
ea = zeros(4,1);

% Loop through dt values and calculate the true percent
% and approximate percent error in each case
for i = 1:4
  
% Determine time vector and number of points
t = [0:dt(i,1):10]';
npts = size(t,1);
v = 0;

% Use Euler's method to generate approximate solution
for j = 1:npts-1
% Update v
dvdt = g-(c/m)*v^2;
v = v + dvdt*dt(i,1);
end
  
% Save approximate solution
vapprox(i,1) = v;
  
% Calculate true and approximate percent errors
et(i,1) = abs((vapprox(i,1)-vtrue)/vtrue)*100;
if i == 1
ea(i,1) = NaN;
else
ea(i,1) = abs((vapprox(i-1,1)-vapprox(i,1))/vapprox(i,1))*100;
end
end

% Output results in a formatted table
vtrue = vtrue*ones(4,1);
outputs = [dt vtrue vapprox et ea];
fprintf(' dt vtrue vapprox et ea ')
fprintf('%4.2f %5.2f %5.2f %5.3f %5.3f ', outputs')
fprintf(' ')

Explanation / Answer

drag_coefficient = 1.5.to_f
mass = 100.to_f
cross_sectional_area = 0.7.to_f
GRAVITY = 9.8.to_f
density = 1.2690.to_f # Air density
def terminal_velocity
((2.to_f * mass * GRAVITY / (density * drag_coefficient * cross_sectional_area)) ** 0.5.to_f).to_f
end

# Air resistance in N
def drag_force
(0.5.to_f * drag_coefficient * density * cross_sectional_area * @velocity) ** 2
end

# Delta time in seconds
def tick(delta_time)
@velocity += (acceleration * delta_time)
end

# Acceleration in m/s
def acceleration
(gravitational_force - drag_force) / mass
end

# Gravitational force in N
def gravitational_force
mass * GRAVITY
end