Please answer the following questions in complete sentences in a typed manuscript and submit the solution on Gradescope by - April 30th at 5am if you want it graded before the final - May 3rd at noon if you want it graded after the final. (No penalty, just no feedback before the exam.)
Please identify anyone, whether or not they are in the class, with whom you discussed your homework. This problem is worth 1 point, but on a multiplicative scale.
Make sure you have included your source-code and prepared your solution according to the most recent Piazza note on homework submissions.
Consider the ODE with .
Apply the stretching transformation to obtain the equivalent ODE And show the relationship between and .
Show that applying the forward Euler method to the ODE for in with step size is equivalent to applying the same method to the ODE for in with step size that satisfies .
Consider the following system that describes the behavior of two masses in the presence of a third mass of (small) size. The masses are and (earth and sun): The initial conditions are Let .
Implement a 4th order RK method for this problem.
Show what happens for , and , , steps. Discuss any interesting observations.
Use a standard integration software package
such as ode45
or one of the Julia ODE packages or an
equivalent tool to study this problem.
Newton's equations for the motion of a particle on a planar orbit (with eccentricity , ) are
Verify that the solution can be written in the form of
Write a program to solve the nonlinear equation at each step using Newton's method and plot the exact solution for .
Write a forward and backwards Euler solver for this problem.
Evaluate the error with and time-steps using the same values of .
Recall the Raptor problem from the midterm.
function simulate_raptors(angle)
vhuman=6.0
vraptor0=10.0 # the slow raptor velocity in m/s
vraptor=15.0 #
raptor_distance = 20.0
raptor_min_distance = 0.2 # a raptor within 20 cm can attack
tmax=10.0 # the maximum time in seconds
nsteps=1000
# initial positions
h = [0.0,0.0]
r0 = [1.0,0.0]*raptor_distance
r1 = [-0.5,sqrt(3.)/2.]*raptor_distance
r2 = [-0.5,-sqrt(3.)/2.]*raptor_distance
# how much time el
dt = tmax/nsteps
t = 0.0
hhist = zeros(2,nsteps+1)
r0hist = zeros(2,nsteps+1)
r1hist = zeros(2,nsteps+2)
r2hist = zeros(2,nsteps+2)
hhist[:,1] = h
r0hist[:,1] = r0
r1hist[:,1] = r1
r2hist[:,1] = r2
tend = tmax
"""
This function will compute the derivatives of the
positions of the human and the raptors
"""
function compute_derivatives(angle,h,r0,r1,r2)
dh = [cos(angle),sin(angle)]*vhuman
dr0 = (h-r0)/norm(h-r0)*vraptor0
dr1 = (h-r1)/norm(h-r1)*vraptor
dr2 = (h-r2)/norm(h-r2)*vraptor
return dh, dr0, dr1, dr2
end
for i=1:nsteps
dh, dr0, dr1, dr2 = compute_derivatives(angle,h,r0,r1,r2)
h += dh*dt
r0 += dr0*dt
r1 += dr1*dt
r2 += dr2*dt
t += dt
hhist[:,i+1] = h
r0hist[:,i+1] = r0
r1hist[:,i+1] = r1
r2hist[:,i+1] = r2
if norm(r0-h) <= raptor_min_distance ||
norm(r1-h) <= raptor_min_distance ||
norm(r2-h) <= raptor_min_distance
# truncate the history
hhist = hhist[:,1:i+1]
r0hist = r0hist[:,1:i+1]
r1hist = r1hist[:,1:i+1]
r2hist = r2hist[:,1:i+1]
tend = t
break
end
end
return tend
end
Modify this code to use Heun's method instead of forward Euler and comment on how the results change with angle.
Not assigned in the end (Tentative, not currently assigned.) Something using Backward Euler. This involves solving the nonlinear system which is more like the previous problem.