Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
AMATH 301
Homework
Instructions for submitting:
• Problems 1-3 should be submitted to MATLAB Grader. You have 3 attempts for
each problem.
• Problems 4-5 should be submitted to Gradescope. The solutions and the code used
to get those solutions should be submitted as a single pdf. All code should be at the
end of the file. You must select which page each problem is on when you submit
to Gradescope.
(32 points) Problem 1: MATLAB Grader
Consider an object attached to a spring.
The object has a mass of m = 1 kg, the spring has a stiffness of k = 1/4 N/m, and there
is a damping force of 1 N (the spring is critically damped). Let x(t) be a function that
gives the position of the object at time t where x = 0 represents the equilibrium position
of the spring. If the object has an initial position of x(0) = 1/3 and an initial velocity of
v(0) = 17/6, then the position of the object is given by the formula
x(t) = 1
3
e
−t/2 + 3te−t/2
.
We wish to find the maximum value of x(t) and the time tmax at which that value
occurs.
(a) Use fminbnd to find the time tmax at which the spring is most elongated. Use the
range 0 < t < 10. Also find the value of x(tmax) which is how far the spring is
stretched past its equilibrium length when it is most elongated. Create a 1 × 2 row
vector named ans1 that contains the value of tmax as the first component and x(tmax)
as the second component.
Hint: The function fminbnd only finds the minimum of a function. How can you
restate the problem as a minimization problem?
(b) Use golden section search to find tmax by minimizing the same function you minimized
in part (a). Use an initial interval [0, 10] (i.e. a = 0 and b = 10), and stop when
b − a < 10−3
. Create a 1 × 2 row vector named ans2 with the final value of a as the
first component and the final value of b as the second component.
(c) Recall that you can find the maximum of the function x(t) by finding the root of the
function x
0
(t). Use Netwon’s method to find tmax by finding the root of x
0
(t) (where
x(t) is the same function as part (a)). Use an initial guess of t0 = 0 and stop when
|tk+1 − tk| < 10−3