# Numerical Integration

1. Dec 2, 2013

### slavito

1. The problem statement, all variables and given/known data

This is for my computer simulations in physics class. The problem, as stated, is to numerically integrate a particular equation for a period of one year, given that the Earth starts at the point (1,0) with a velocity of (0,2pi). Then, I must plot the orbit.

I am using Maple for this exercise. I know how to program in it just fine. I really just need help with understanding this problem.

2. Relevant equations

I must integrate this equation:
$$\frac{-GM}{r^2}\hat{r}=\frac{-GM}{(x^2+y^2)^\frac{3}{2}}(x\hat{i}+y\hat{j})$$

$$G= 2\pi$$
$$M= Solar Mass$$

3. The attempt at a solution

I knew that I would have to tackle this integration one part at a time, so I started by distributing the GM term. This part was simple. It is understanding the integration from this point on that I do not understand. I tried integrating in terms of x and then of y, but did not get the results I was expecting. For this plot to be a nice, circular orbit, the x and y components must be sin/cos graphs. I have gotten a few "answers" integrating it my way, but all of these answers were undefined for when x or y are 0. This should not be the case. I also know I am going wrong because I have 2 variables at the end, making the plot of the rotation impossible, even in Maple.

I think I have started to approach the problem wrong as I have not found a way to incorporate the initial position or velocity. I doubt these are superficial pieces of information. My gut is telling me that the limits of integration are x and y, but I don't know how to make this work.

I have tried looking up similar problems on other sites for several hours and I think I have a good handle on what the correct answer will look like when I get it, but at the moment, I'm a little stuck. I would appreciate any sort of help you could give me!

[Note: I wasn't sure if I should post this in adv. physics or calculus help. I'm sorry if I didn't choose correctly!]

2. Dec 2, 2013

### Staff: Mentor

This is a problem in finding the position of the earth moving in orbit about the sun as a function of time. Let x =x(t) and y = y(t) be the location of the earth at time t, and let vx(t) and vy(t) be the components of velocity of the earth at time t. You need to apply Newton's second law of motion to determine the differential equations (with respect to time) for how x, y, vx, and vy are varying with respect to time. Are you able to write down these equations? These are the equations that you need to integrate.

Chet

3. Dec 3, 2013

### slavito

I understand this in theory, but I'm not sure if I am doing it correctly in practice.

The first thing I did was look at a picture of a unit circle to help orient me. I figured this would be the best course of action because I will end up with a perfectly circular rotation of the Earth around the Sun. My simulation will start at position (1,0), so that is where I started as well and began my rotation. What I noticed it that the X component of the position goes 1->0->-1>0, resembling a cosine wave. The Y-component, likewise, resembled a sine wave. Thus, the equations I settled on were:

$$x=x(t)=cos(t)$$
$$y=y(t)=sin(t)$$

I plugged these into the equation I had for the acceleration due to gravity and then distributed. I did an indefinite integral for both the of the components and got:
$$v_x=4pi^2Mcos(t)$$
$$v_y=-4pi^2Msin(t)$$

When I graph this in Maple, I seem to get something that looks like what I was looking for, in that it is a circle around the origin. Unfortunately, it looks like I am actually facing a few problems and I'm not sure if it is a programming error or an error with my math.

Problem #1:
I was expecting my graph to have a radius of 1AU, but I got a radius of 6E31. I don't know if it helps, but I set $$G=2pi*2, M=1.989E30$$. I get the right radius if I set GM=1, but I don't know if there's any justification for doing so.

Problem #2:
I set $$t=0..2pi$$. This seemed to be fine until I realized it causes the rotation to go clockwise when I was actually expecting counter-clockwise. I noticed that it goes the right way if I set $$t=0..-2pi$$, but I don't know if doing so is valid.

Problem #3:
I also noticed that I am having troubles solving the other problems related to this equation. When I increase or lower the velocity, I expect Earth to move closer or further away from the center, but my graphs just so a steady rotation, leading me to believe that even though the graph appeared correct for the first problem, I have a fundamental error somewhere.

Thank you so much for all of your help, Chet! Your direction earlier was excellent and really got me on the right path, so I hope you don't mind helping me just a little bit more!

Last edited: Dec 3, 2013
4. Dec 3, 2013

### Staff: Mentor

This is all just a problem with units. Please check your units carefully.