# PS7Ex1.py an Example of a Euler-Cromer method to solve an ODE
# Example for a=-kx, where 'a' is the second, and 'v' is the first differntial of 'x'
import matplotlib.pyplot as plt
# Make empty lists
tlist = []
xlist = []
vlist = []
#The initial values and constant are set next.
# Set inital values and constants
t = 0.0 # initial time=0
dt = 0.001 # time step
x = 10.0 # initial 'x'
v = 0.0 # initial 'v'
tf = 10.0 # end time
k = 5.0
#The initial values are appended to the lists.
# Append inital values to the lists
tlist.append(t)
xlist.append(x)
vlist.append(v)
#Inside of a loop, equations (3) and (4) are used to find values of the derivative and the function (in that order) at the next time.
#The type of loop used depends on how you want to determine when the program will stop.
#The new values are appended to the lists.
while t