Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel\(\rightarrow\)Restart) and then run all cells (in the menubar, select Cell\(\rightarrow\)Run All).
Make sure you fill in any place that says YOUR CODE HERE or “YOUR ANSWER HERE”, as well as your name and collaborators below:
NAME = ""
COLLABORATORS = ""
There are two balls on trajectories in the xy plane. One ball’s trajectory follows the equation:
\(y = x^2 - 2x + 1\)
The other ball follows an elliptical trajectory of:
\(9 (x-2)^2 + 4 (y-2)^2 - 36 = 0\)
First, plot the two trajectories on the range of x=(0, 4).
It is not obvious how to plot an ellipse, so, note that the general equation for an ellipse is:
\(\frac{(x-h)^2}{a^2} + \frac{(y-k)^2}{b^2} = 1\)
Then, you can plot the parametric equations:
\(x = h + a cos(t)\) and \(y = k + b sin(t)\)
so, for a circle of radius 1, centered at the point (0.5, 2) we have:
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, 2 * np.pi)
h, a = 0.5, 1
k, b = 2.0, 1
x = h + a * np.cos(t)
y = k + b * np.sin(t)
plt.plot(x, y)
plt.axis('equal');
Find all of the possible collision points (i.e. that they have the same (x, y) coordinates at the same time) and plot them on your graph.
When you are done, download a PDF and turn it in on Canvas. Make sure to save your notebook, then run this cell and click on the download link.
%run ~/f23-06623/f23.py
%pdf