<jupyter_start><jupyter_text>Projectile MotionRecall that the equation for projectile motion when acceleration is constant can be written as $$y=y_{0}+v_{0}t+\frac{a}{2}t^{2}.$$1. Create a Matlab or Python function that generates a plot of $y(t)$. You should be able to easily change the initial velocity, the initial position, and the acceleration. Be sure to include axis labels as appropriate. The function should take $y_{0}$, $v_{0}$, $a$ and a vector of $t$ as arguments. The function should:    (a) Plot $y(t)$ with labeled axes and a grid on the plot.        (b) Return the vector $y(t)$.    2. Determine $t_{\mathrm{end}}$ such that $y(t_{\mathrm{end}})=0$. In the event that there are two times that produce $y=0$ you should use the larger of the two. HINT: Solve the quadratic equation for the projectile.You do not need to submit a report for this problem - only your Matlab or Python files.  Solution  Question 1Create a Matlab or Python function that generates a plot of $y(t)$. You should be able to easily change the initial velocity, the initial position, and the acceleration. Be sure to include axis labels as appropriate. The function should take $y_{0}$, $v_{0}$, $a$ and a vector of $t$ as arguments. The function should:    (a) Plot $y(t)$ with labeled axes and a grid on the plot.        (b) Return the vector $y(t)$.<jupyter_code>%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
def projectile(y0,v0,a,t):
    """The method's docstring
    params:
    y0: value
    v0: value 2
    """
    result = y0 + v0 * t + a/2.0 * t * t
    plt.title('Projectile')
    plt.xlabel('time (s)', fontsize=18)
    plt.ylabel('Height (m)', fontsize=16)
    plt.plot(t,result)
    return result
y0=0.1
v0=10
a=-9.81
t = np.linspace(0,2,200)
y = projectile(y0,v0,a,t)<jupyter_output><empty_output><jupyter_text>Question 2Determine $t_{\mathrm{end}}$ such that $y(t_{\mathrm{end}})=0$. In the event that there are two times that produce $y=0$ you should use the larger of the two. HINT: Solve the quadratic equation for the projectile.What we can do here is use numpy's roots function<jupyter_code>tend = np.max(np.roots([a/2,v0,y0]))
print('The Projectile will reach the ground in:', tend)
t = np.linspace(0,tend,200)
y = projectile(y0,v0,a,t)<jupyter_output>The Projectile will reach the ground in: 2.048687409049999
{'fraction_non_alphanumeric': 0.11513859275053305, 'fraction_numerical': 0.029850746268656716, 'mean_word_length': 4.3439635535307515, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '508233', 'license': 'MIT', 'n_tokens_mistral': 784, 'n_tokens_neox': 746, 'n_words': 313, 'path': 'misc/Ex01. Projectile Motion.ipynb', 'repo_name': 'jomorodi/NumericalMethods', 'size': '2345'}