#!/Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia dt = 0.01 # time step in seconds g = 9.8 # acceleration of gravity in m/s^2 function dynamics(y::Float64, v::Float64, t::Float64) for i in 1:100 y = y + v * dt v = v - g * dt t = t + dt end return y, v, t end y0 = 10.0 # initial position in meters v0 = 0.0 # initial velocity in m/s y, v, t = dynamics(y0, v0, 0.0) # evolave for 100 time steps println("\n\t Results") println("final time = ", t) println("y = ", y, " and v = ", v) println("exact v = ", v0 - g * t) println("exact y = ", y0 + v0 * t - 0.5 * g * t^2.0)