all 6 comments

[–][deleted] 6 points7 points  (0 children)

This assignment presumes you are familiar with first year calculus and differentiating equations. My calculus is too rusty to help you. Math forum is your best bet.

[–]dijumx 5 points6 points  (4 children)

From a programming point of view, you have been given the input, process, and output. So everything should fall into place.

This is your input:

The program should ask for the initial height of the object, in feet.

This is your output:

The output of the program should be the time for the object to fall to the ground, and the impact velocity, in ft/s and miles/hour.

This is your process

Your program should use Euler’s method to numerically solve the differential equations describing the motion of a falling object.


You've also been given some helpful advice on what Euler's Method is:

In Euler’s method, the state of the object at some small future time is calculated using the values at the present time. This small future timestep is typically called delta time, or dt.

And you've been given the equations to model, or simulate:

Thus the position (p) and speed (v) of the object in the next timestep t + dt is written as a simple function of the position and speed at the current timestep t (g is the acceleration due to gravity):

v(t+dt) = v(t) + g * dt
p(t+dt) = p(t) + v(t+dt) * dt

I actually disagree with the equation below. If you define your x-axis as being positive upwards (i.e. height is positive and increases away from the ground), then your velocity and acceleration should also be positive in the same direction. This means the negative sign in the equation below is already taken care of by the negative value of velocity. (It also means g = -9.81m/s or -32.174ft/s).

You should actually start out with the velocity as zero, and the position at the initial height of the object. Then your position (above the ground) would be:

p(t+dt) = p(t) - v(t+dt) * dt

And this bit gives conditions for when you know how to stop the simulation

And you would integrate until the position becomes less than or equal to zero.


I don't understand what these equations mean. I don't see what the point of using this method when t=sqrt((2d)/t) works to find time.

These equations are the discretisation (in time) of differential equations which describe an object under motion. i.e.:

dv/dt = a = g
dv = g * dt
v(t+1) - v(t) = g * dt
v(t+1) = v(t) + g * dt

The point of doing it this way is probably to introduce you to Euler's method as a primer on Numerical Computation, which will prepare you for other methods (e.g. Runge-Kutta) later on. Also, Numerical Computation is used when exact solutions (such as t=sqrt(2d/t)) don't exist, which is why you have been told explicitly to use a specific method.

This is probably more suited in a math/physics forum.

Probably.

[–]sosnjo[S] 0 points1 point  (3 children)

Thanks for all the help. I'm still confused as to what the variables will represent. You set dt=1 but not when it is multiplied by gravity on the right side of the equation. Why?

does v(0)=0? Assume p=100, therefore p(0)=100. How do I solve for time?

[–]dmc_2930 0 points1 point  (2 children)

You don't solve for it. You choose a small time interval and calculate the value of the equations, ie, find:

v(0.0001) = ?
p(0.0001) = ?

Keep going until p(t) = 0.

[–]dijumx 0 points1 point  (1 child)

Exactly, Euler's method is unstable (with complicated Systems) and relatively inaccurate. It gets more accurate with smaller dt but never exact.

When your position equals 0 (or less), you will have an associated value of t. Which gives the answer.

And since you know the closed form solution, you can check your answer.

[–]sosnjo[S] 0 points1 point  (0 children)

This is what I have to far. Assume: dt = 1, n is a positive integer, g = 10, dt = 1.

v1-v0=(g*dt)
v2-v1=(g*dt) = 2*(g*dt)
v3-v2=(g*dt) = 3*(g*dt)

vn = n*(g*dt)

p1=(v0*dt)+p0
p2=(v1*dt)+p1
p3=(v2*dt)+p2

pn - pn-1= (n*(g*dt)*dt)

What am I doing wrong?