Simulation parameters: •Define a step size h. Try something small like 0.001 seconds. Define a length for the simulation-perhaps 10 seconds for now, but feel free to adjust it as you see fit. • Create a list of times that begins at 0 and goes up to the simulation length in steps of h. The actual simulation only cares about the step size, so we won't use this in the simulation but we'll use it for plotting at the end.
Simulation parameters: •Define a step size h. Try something small like 0.001 seconds. Define a length for the simulation-perhaps 10 seconds for now, but feel free to adjust it as you see fit. • Create a list of times that begins at 0 and goes up to the simulation length in steps of h. The actual simulation only cares about the step size, so we won't use this in the simulation but we'll use it for plotting at the end.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Plz help with code

Transcribed Image Text:Simulation parameters:
• Define a step size h. Try something small like 0.001 seconds.
• Define a length for the simulation-perhaps 10 seconds for now, but feel free to adjust it as
you see fit.
• Create a list of times that begins at 0 and goes up to the simulation length in steps of h. The
actual simulation only cares about the step size, so we won't use this in the simulation but we'll
use it for plotting at the end.
• Calculate the length of the list created in the previous step and assign it to a variable n.
Data arrays:
• Create a list r of length n that is all zeros (np.zeros could come in handy here).
• Create a list s of length n that is all zeros.
Initial conditions:
• Set the first entry of r to be some initial height of your choosing.
• Set the first entry of s to be some initial velocity of your choosing.
First-order equations:
• We need to define a function that calculates the derivative of r. Since Eq. 2.14 says that r' s,
this is fairlv simply. We iust have to return c in this case In Puthon code this would look like:
![[ ]
k3s = sd(s[i] + h * 0.5 * k2s)
k4r = rd(s[i] + h
* k3s)
k4s = sd(s[i] + h * k3s)
# Update next value of variables
r[i+1] = r[i] + h
s[i+1] = s[i] + h * (k1s + 2 * k2s + 2 * k3s + k4s) / 6.0
* (kir + 2 * k2r + 2 * k3r + k4r) / 6.0
# Uncomment the code on the next line for Q2
# if r[i+1] <= 0: s[i+1] = -s[i+1]
# Plotting the result
plt.plot (t, r)
plt.title('Projectile Motion:')
plt.xlabel('time (s)')
plt.ylabel ('height (m)')
plt.grid(True)
plt.show()
File "<ipython-input-6-62380d648059>", line 15
t =
#Array of times; used only for plotting#
SyntaxError: invaliod syntaY](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F44e7a3ce-803b-45aa-8658-f230b13e4980%2F86affe80-8912-4cf5-8097-17e9ea94f33a%2F2evuleb_processed.jpeg&w=3840&q=75)
Transcribed Image Text:[ ]
k3s = sd(s[i] + h * 0.5 * k2s)
k4r = rd(s[i] + h
* k3s)
k4s = sd(s[i] + h * k3s)
# Update next value of variables
r[i+1] = r[i] + h
s[i+1] = s[i] + h * (k1s + 2 * k2s + 2 * k3s + k4s) / 6.0
* (kir + 2 * k2r + 2 * k3r + k4r) / 6.0
# Uncomment the code on the next line for Q2
# if r[i+1] <= 0: s[i+1] = -s[i+1]
# Plotting the result
plt.plot (t, r)
plt.title('Projectile Motion:')
plt.xlabel('time (s)')
plt.ylabel ('height (m)')
plt.grid(True)
plt.show()
File "<ipython-input-6-62380d648059>", line 15
t =
#Array of times; used only for plotting#
SyntaxError: invaliod syntaY
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY