Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

N=100 #The number of iterations (Euler steps) to do t=0 # Initial time in second

ID: 3742246 • Letter: N

Question

N=100 #The number of iterations (Euler steps) to do
t=0 # Initial time in seconds
a= -9.8# Acceleration in units of m/s**2
y=10.0 # Initial height in meter
v=0.0 # initial velocity in m/s
dt=0.1 # Time step in seconds

I need help with coding in Python trying to complete this task

Default values are

Part 1: Create a function that will simulate the falling ball until it hits the ground and will plot the results. This function should take two parameters as required input, and it should take the other parameters as option input (with appropriate default values). The two parameters that should be given as required input are: The maximum time (in seconds) to be simulated The value of the time step, At. From these two numbers, you can compute the (integer) number of times steps to be simulated, N. When executed, this function should plot both height versus time and velocity versus time. Each plot should contain two datasets: the analytical results, and the numerical results. All of the computed data should be store in arrays, which can be constructed by either repeatedly appending data to the arrays or using array indices (square brackets). When plotting, the arrays will be needed in order to (1) plot the data with connecting lines and (2) create a legend. In order to clearly see each of the datasets in the plots, you might need to play with the "linewidth" property in the plots. As always, be sure your plots are nicely formatted!

Explanation / Answer

import matplotlib.pyplot as plt
def PLOT_DATA(T,dt):
a=-9.8;
theta=45;
N=math.ceil(T/dt);
y=10.0;
v=0.0;
dt=0.1;
for time in range(0,N):
height=(v*(time*dt)*sin())-((1/2)*g*(time*dt)^2);
y.add(height);
plt.plot(range(0,N),y,color='blue',linestyle='dashed',linewidth=5,marker='0',markerfacecolor='red', markersize=15);
PLOT_DATA(0.3,30);