TEST 1:
“Check that coriolis returns an array of the correctsize.”
assertnp.allclose(coriolis(3,3,np.pi/6,[1,0,1,0],np.linspace(0,20,200)).shape,[200,3])
assertnp.allclose(coriolis(2,1,np.pi/2,[1,-1,1,2],np.linspace(0,10,100)).shape,[100,3])
print(“Problem 5 Test 1: Success!”)
TEST 2:
“Check that coriolis returns the correct values.”
solution =coriolis(2,1,np.pi/2,[1,-1,1,2],np.linspace(0,10,200))
M = np.array([[ 0. , 1. , 1. ],
[ 0.05025126, 0.94974454, 1.09781044],
[ 0.10050251, 0.89943111, 1.18959012],
[ 0.15075377, 0.84891533, 1.2744251 ]])
assert np.allclose(solution[:4,:],M)
print(“Problem 5 Test 3: Success!”)
TEST 3:
“Check that coriolis returns the correct values.”
solution =coriolis(2,1,np.pi/2,[1,-1,1,2],np.linspace(0,10,200))
M = np.array([[9.89949749,1.306117,0.6589853],
[9.94974874,1.29575448,0.76147343],
[10.,1.2822863,0.85746863]])
assert np.allclose(solution[-3:,:],M)
print(“Problem 5 Test 3: Success!”)
Problem 4 (5 points) Write a function called coriolis which takes input parameters w, Omega , phi , uo and t . The function uses scipy.integrate.odeint to numerically solve the system of equations dx = -w-x + 212 sin(o) = -oʻy – 282 sin(o) given the initial conditions (x(to), x’ (to), y(to), y’ (to)] defined by u0 (a Python list of length 4), and where t is a 1D NumPy array of t values over an interval [to, tf]. The parameters o, 12, and are given by w, Omega , and phi respectively. The function plots the trajectory (x(t), y(t)) of the solution and returns a 2D NumPy array M of size len(t) by 3 where the column at index 0 is the array of t values, the column at index 1 is the corresponding array of x values and the column at index 2 is the corresponding array of y values. Show transcribed image text Problem 4 (5 points) Write a function called coriolis which takes input parameters w, Omega , phi , uo and t . The function uses scipy.integrate.odeint to numerically solve the system of equations dx = -w-x + 212 sin(o) = -oʻy – 282 sin(o) given the initial conditions (x(to), x’ (to), y(to), y’ (to)] defined by u0 (a Python list of length 4), and where t is a 1D NumPy array of t values over an interval [to, tf]. The parameters o, 12, and are given by w, Omega , and phi respectively. The function plots the trajectory (x(t), y(t)) of the solution and returns a 2D NumPy array M of size len(t) by 3 where the column at index 0 is the array of t values, the column at index 1 is the corresponding array of x values and the column at index 2 is the corresponding array of y values.
Expert Answer
Answer to TEST 1: “Check that coriolis returns an array of the correct size.” assert np.allclose(coriolis(3,3,np.pi/6,[1,0,1,0],np…