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!

Euler Method for Orbits

  1. Jun 15, 2015 #1
    Hello everyone,

    I am curious as to if it is possible to use the Euler Method to solve the gravity differential equations? Would the approximations quickly diverge to inaccurate solutions, or would it stay relatively reliable?

    Thanks
     
  2. jcsd
  3. Jun 15, 2015 #2

    HallsofIvy

    User Avatar
    Staff Emeritus
    Science Advisor

    I presume you mean the basic "Euler method" for solving differential equations. (Given a differential equation dx/dt= f(x, t) with initial value [itex]x(t_0)= x_0[/itex], calculate [itex]f(t_0,x_0)[/itex] and construct the line through [itex](t_0, x_0)[/itex] with slope [itex]f(t_0,x_0)[/itex]. Follow that line for some short distance, [itex]\Delta t[/itex] to find [itex]x_1= x_0+ f(t_0, x_0)\Delta t[/itex] and [itex]t_1= t_0+ \Delta t[/itex].)

    Such an approximation method can be made as precise as you want by taking very short [itex]\Delta t[/itex] but generally, no, the step required to make orbit calcultations would have to be so small as to make the method unreasonable, even on a computer. I would recommend a "Runge-Kutta" method of order 3 or higher.
     
  4. Jun 15, 2015 #3
    https://en.wikipedia.org/wiki/N-body_problem

    This document explains how NASA's JPL does it using a variable-step, variable-order multistep method: Euler's method is the most simple method of this class being a single-step method of order one and is only useful for demonstrating how quickly errors propagate! An alternative class of methods is the Runge-Kutta methods: the fourth order method referred to as "RK4" is available in a number of libraries for C, Java etc.
     
  5. Jun 15, 2015 #4
    Thank you, good point about the error propagation.
     
  6. Jun 15, 2015 #5

    Drakkith

    User Avatar

    Staff: Mentor

    Hmm. Maybe the info in this thread can help me figure out why my orbital simulation I created Saturday likes to make the Earth spiral into the Sun and then go flying off into interstellar space.:biggrin:
     
  7. Jun 15, 2015 #6
    Your simulation is probably not using a high enough order Runge - Kutta method, and is giving you increasingly inaccurate results as time goes on.
     
  8. Jun 15, 2015 #7

    Drakkith

    User Avatar

    Staff: Mentor

    My simulation is using a couple of laws from my physics book I just learned, lol. I can't even tell you what method it is!
     
  9. Jun 15, 2015 #8
    can you show what equations you are using?
     
  10. Jun 15, 2015 #9

    Drakkith

    User Avatar

    Staff: Mentor

    I'm using the basic equations for motion along with newton's 2nd law and law of gravitation:

    X = Xo +Vt+1/2At2
    V = Vo + At
    F=MA
    F = GM1M2/r2

    I break up the equations into X and Y components with some trigonometry and then calculate each one using a time step. Then I add the resulting values to their respective variables and repeat. I didn't look up anything on this prior to creating the simulation. I just wanted to see if I could do it using what I've learned in my physics class.
     
  11. Jun 15, 2015 #10
    Oh I see. You cannot do that with orbits as gravity is a differential equation and it is impossible to solve the orbital trajectory explicitly as a function of time.

    You must first write the equation of motion of gravity in polar coordinates like so, \ddot{r}-r \dot{ \theta }^{2}=-\frac{GM}{ r^{2} }.
    Because theta-dot however complicates things, we replace it with, \dot{ \theta } = \frac{h}{ r^{2} }. h is angular momentum. After this, to find r as a function of time, use a numerical method such as Runge-Kutta to find the trajectory as a function of time.

    BTW, Im a high school sophomore too, good luck.
     
  12. Jun 15, 2015 #11

    Drakkith

    User Avatar

    Staff: Mentor

    Gah! I've been outdone by a kid! :eek:
    I'm 31 and in a basic college physics class, lol.
     
  13. Jun 15, 2015 #12

    Drakkith

    User Avatar

    Staff: Mentor

    Doesn't look like the forum liked your math.
     
  14. Jun 16, 2015 #13
    The OP's method is perfectly valid, and all you have done is replaced a numerical solution in cartesian coordinates with a numerical solution in polar coordinates.

    However your assumption that angular momentum of a body is constant is only valid in general for a two body problem, where an analytical solution is available negating the need for numerical integration.
     
  15. Jun 16, 2015 #14

    Drakkith

    User Avatar

    Staff: Mentor

    That was the OP. :biggrin:
     
  16. Jun 16, 2015 #15
    Oh yes, Drakkith, your method is perfectly valid!
     
  17. Jun 16, 2015 #16

    Drakkith

    User Avatar

    Staff: Mentor

    Dang! I thought I had a solution to why the Earth spiraled into the Sun in my simulation, but I guess not.
     
  18. Jun 16, 2015 #17

    tony873004

    User Avatar
    Science Advisor
    Gold Member

    You can compare Euler vs. RK4 here. http://orbitsimulator.com/BA/compare.html . It actually uses Euler-Cromer, the difference being that velocities are updated before positions are updated. It's javascript, so you can view the code and look at functions RK4() and function Euler(). Euler's method is only a few lines long. Runge-Kutta 4 is slower, but you can take larger time steps which makes up for the difference. But Euler's method still works pretty well.
    That's what I did about 12 years after graduating high school. I remembered my physics, but that capital letter G in all the gravitation formulas still confused me. I decided to give it a go anyway. My units were pixels per iteration. I was so happy when I saw a trajectory get bent by a mass. I spent all night zeroing in on the perfect value for a circular orbit. Months later, I wanted to use meters / second instead of pixels per iteration. So I introduced a "fudge factor" in my equations which made "Earth" take 365.24 days to go around "Sun". Later, I learned that what I came up with was Euler-Crommer method, and my fudge factor was G.
     
  19. Jun 16, 2015 #18
    One problem can be too SMALL a time step: you need δt to be large enough that δx/x >> ∈ where ∈ measures the precision of the arithmetical engine (or rather that |δx|/|x| >> ∈ where δx and x are vectors).
     
  20. Jun 16, 2015 #19

    Drakkith

    User Avatar

    Staff: Mentor

    I used meters and seconds in all of the math and just divided the distances by about 2 million or something when I updated their position on screen.
     
  21. Jun 16, 2015 #20

    Drakkith

    User Avatar

    Staff: Mentor

    I'm not familiar with any of that notation. For my timestep I used 12 hours. Since my program runs 60 timesteps per second max, making it much smaller would make the orbit take forever. However, I think I can get around this 60 fps limit by using a 'repeat X number of times' in my program, so it will run each calculation 60X times. Haven't tried it yet though.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Euler Method for Orbits
  1. Euler relation (Replies: 4)

  2. Euler force ? (Replies: 9)

Loading...