1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Euler's Method and Free Fall

  1. Feb 24, 2016 #1


    User Avatar

    1. The problem statement, all variables and given/known data
    Write a C program to simulate a falling object. The program should ask for the initial height of the object, in feet. 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. Your program should use Euler’s method to numerically solve the differential equations describing the motion of a falling object. 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. 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 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 you would integrate until the position becomes less than or equal to zero.

    I'm having difficulty understanding what to do here. I don't really understand what the point of using these equations when t=sqrt(2d/g) gives us time of free fall.

    Thanks for the help.

    2. Relevant equations
    v(t+dt) = v(t) + g * dt
    p(t+dt) = p(t) + v(t+dt) * dt
    p(t+dt) = p(t) - v(t+dt) * dt

    3. The attempt at a solution

    p(t+dt) = p(t) - v(t+dt) * dt
  2. jcsd
  3. Feb 24, 2016 #2


    User Avatar

    Staff: Mentor

    Welcome to the PF.

    Yes, clearly without any air resistance issues, you can solve for this algebraically. But the point of the programming exercise is to give you an easy problem to solve numerically. You should compare the answers you get from your numerical solution with the equation you mention, to see what the accuracy is. You could even vary the dt values to see how they affect the accuracy of the numerical solution. :smile:
  4. Feb 24, 2016 #3
    I give a similar exercise to my students. The point is to give you some practice with numerical integration. The fact that you know the analytic solution allows you to check your answer. The importance of the exercise is that for many (most?) 'real' problems (systems modeled by differential equations) an analytic solution may not exist, or may be very difficult to find. Numerical integration allows for a relatively easy way to analyze the system.

    Edit: Sorry for the redundancy - berkeman's post must have posted as soon as I started typing!
  5. Feb 24, 2016 #4


    User Avatar

    I'm still unsure what v(t+dt) and p(t+dt) represent.
  6. Feb 24, 2016 #5


    User Avatar

    Staff: Mentor

    It's probably best to start with an Excel spreadsheet to get a feel for how these sequential calculations go.

    The first column is time, starting at zero, and incrementing by dt for each row after that. The second column is y(t), the third is velocity v(t). All are zero in the first row.

    Then put in formulas into the second row, second and third columns to calculate the new position and velocity based on the previous values in the previous row. That's what v(t+dt) and p(t+dt) represent. Then just do a click-drag down for the y(t) and v(t) cells and do a Fill-Down to paste the same formulas (with adjusted row numbers) in the cells below. You should see how the position and velocity are changing with time when you do this. Makes sense?

    Then you just need to code up the same thing in C... :smile:
  7. Feb 24, 2016 #6
    v(t+dt) is the velocity after a short time interval. Even for non-constant acceleration the velocity will be approximately linear for very short intervals of time - that's why the method is so simple.

    p(t+dt) is the position after a short time interval. Similar to the example above the change in position is approximately linear for short time intervals. You use the velocity you calculated to calculate each subsequent change in position.

    As @berkeman said, it would be worth your time to set this up in a spreadsheet - that is actually what I instruct my students to do.
  8. Feb 24, 2016 #7


    User Avatar

    How would I solve for time with these equations though? if g=-32.2 and assume p=100?
  9. Feb 24, 2016 #8
    You don't solve for time in the algebraic sense - you iterate the equations until the desired position is reached. Time is a parameter that everything else depends on and you pick the time step, dt. For example, suppose we pick a time step of 1 second (a poor choice if we want to be close to approximate for the position). The first few columns for various rows in a spreadsheet would look like:

    t a v p
    0 10 0 0
    1 10 10 0
    2 10 20 10
    3 10 30 30
    4 10 40 60
    5 10 50 100

    Edit: hopefully you can understand what I've written here; I just quickly typed it in nicely spaced so I didn't need to spend time making a chart, but the spacing didn't show up right... (a is acceleration, v is velocity, p is position and I used an acceleration of 10 to make the numbers look nice.)

    The nth entry in the velocity column is calculated by using the n-1 acceleration term and adding the n-1 velocity. Similarly, the nth position entry is calculated by using the n-1 velocity and adding the n-1 position.

    Suppose the question is to find the time for the object to fall 100 meters. The time would be 5 seconds according to this spreadsheet. Does that help?
  10. Feb 24, 2016 #9


    User Avatar

    It's making a bit more sense. What is your work to calculate those values? If we assume dt=1 and g=10 and p=10, does that mean p(0)=100?

    p(t+1) = p(t) + v(t) + 10 is this true?

    I really appreciate the help
  11. Feb 24, 2016 #10
    Let me start with the velocity explicitly. Let v0 be the initial velocity. The next velocity (after time dt) will be

    v1 = a0 * dt + v0 where a0 is the initial acceleration (note that for free fall the acceleration is always constant, but I'm going to give instructions as if it was changing so everything is more general, and hopefully more clear).

    Then, the velocity after the second time interval is

    v2 = a1 * dt + v1

    And the third velocity is

    v3 = a2 * dt + v2

    And so on. In the line for t = 4 seconds in post 8 above the velocity was calculated as v4 = (10) (1) + 30 = 40

    The position works the same way except you use the velocity in place of the acceleration:

    p1 = v0 * dt + p0

    p2 = v1 * dt +p1

    p3 = v2 *dt +p2

    So p4 from the example in post 8 is p4 = 30 * 1 + 30 = 60

    And p5 is p5 = 40 * 1 + 60 = 100
  12. Feb 24, 2016 #11


    User Avatar

    Alright it makes sense now. Thanks so much for the help.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted