Lab 6: Extreme Values



You may have noticed over the years that Mars occasionally appears especially bright in the night sky. The media certainly tends to make a fuss out of it when it happens. This is because the Earth and Mars become unusually close in their orbits around the Sun. The following diagram allows you to visualize the relative positions of the Earth and Mars (time is measured in days since January 1, 2000 and distance is measured in AU: 1 AU = 12,960,000 miles).

Because Earth is closer to the sun than Mars, it orbits faster. As a result, the two planets are closest together when Earth passes between Mars and the Sun.

Planets orbit approximately in ellipses, but this is only an approximation. Below are equations that give the approximate \( (x,y,z) \) coordinates of Earth and Mars in space over time (measured in days after January 1, 2000). The equations are messy, because orbits are complicated. The important takeaway from these formulas is that xearth(t), yearth(t), zearth(t) are the coordinates of the Earth on day \(t\) and xmars(t), ymars(t), zmars(t) are the coordinates of Mars on the same day.
MC=0.093405
MO(t)=0.0091458*t+0.3246
MG(t)=MO(t)+MC*sin(MO(t))*(1+MC*cos(MO(t)))
MH(t)=atan2((0.9956)*sin(MG(t)),(cos(MG(t))-MC))+5.0003
MF(t)=1.5236*sqrt(( cos(MG(t))-MC)^2+((0.9956)*sin(MG(t)))^2)
EC=0.016709
EO(t)=6.21419244 + 0.017202*t
EG(t)=EO(t)+EC*sin(EO(t))*(1+EC*cos(EO(t)))
EH(t)=atan2(0.99986*sin(EG(t)),cos(EG(t))-EC)+4.938241
EF(t)=-sqrt(1+EC^2*sin(EG(t))^2+(-2*cos(EG(t))*EC+EC^2))
xearth(t) = EF(t)*cos(EH(t))
yearth(t) = EF(t)*sin(EH(t))
zearth(t) = 0
xmars(t) = MF(t)*(0.648685933*cos(MH(t))-0.761056213*sin(MH(t))*0.999478937)
ymars(t) = MF(t)*(0.761056213*cos(MH(t))+0.648685933*sin(MH(t))*0.999478937)
zmars(t) = MF(t)*(sin(MH(t))*0.032277747)

3. Copy the above equations into the SageMath evaluation cell below. Below them, create a new function to measure the distance between Earth and Mars on day \(t\): \[ \mathrm{dist}(t)= \sqrt{ (x_{\rm Mars}(t)-x_{\rm Earth}(t))^2 + (y_{\rm Mars}(t)-y_{\rm Earth}(t))^2 + (z_{\rm Mars}(t)-z_{\rm Earth}(t))^2}. \]

dist(t) = sqrt((xmars(t)-xearth(t))^2+(ymars(t)-yearth(t))^2+(zmars(t)-zearth(t))^2)

(a) Consider the time from January 1, 2023, which is day 8401, until December 31, 2030, day 10958. Using the plot() command, create a plot of the distance from Earth to Mars over this time period (from \(t=8401\) to \(t=10958\)).
(b) How many local extrema do you see on this graph? How many of them are local maxima and how many local minima?
(c) Use the diff() command to compute the derivative of \( \mathrm{dist}(t) \) and store it in a new function \( \mathrm{ddist} \). Then plot this function over the same time period.
(d) Note that the critical points of \( \mathrm{dist}(t) \) are the places where this graph crosses the horizontal axis. For each critical point, find an interval that contains only that critical point. For example: if it looks like the graph crosses the axis around \(t = 8450\), you might use \( (8400,8500) \). Now use the command find_root() to find the exact value of each critical point. Write down the exact values of each critical point on \( (8401, 10958) \) to two decimal places.
(e) Find the distance from Earth to Mars at each critical point by evaluating dist(c), where \(c\) is the value your critical point. When were the two planets closest during this decade? How close were they? When were they furthest? How far apart were they?

You can compare the closest approach that you found to the actual value here: Closest Approaches of Mars. How far off was your answer? Why wasn’t your answer exactly right? (Hint. It isn’t your fault. However, you should be close!)

Name:
Skip to toolbar