How to calculate the distance an accelerating object will be pulled by another object in a given amount of time? [closed]

How can I calculate the distance an accelerating object will be pulled by another object in a given amount of time?

I am creating a simulation of space objects interacting with each other. To test the strength of gravity, Earth does not orbit the sun but will be pulled into it. The Earth will start slowly, and accelerate. I know the time, initial speed, distance between the two objects at the start of the time, and both objects' masses. This question is different from this question because that question assumes that the Earth isn't already accelerating. Thanks.

Edit: To garyp, sorry, I didn't want to just repeat the title above, but basically, it's the second offered. "how to calculate that distance for large (say a month, so that the acceleration will obviously change) intervals of time?"

This is not a homework question, and only mentions that I am creating a simulation so that it is known that I don't want the actual acceleration of Earth or an explanation of why the Earth doesn't fall into the Sun. I wanted an equation of distance fallen over time, which would be useful to the broader community, and to future users. I wasn't the one who tagged it as a homework and exercises question, so sorry about that.

closed as off-topic by heather, John Rennie, sammy gerbil, Emilio Pisanty, ACuriousMind♦Aug 8 '16 at 22:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – John Rennie, sammy gerbil, Emilio Pisanty, ACuriousMind
If this question can be reworded to fit the rules in the help center, please edit the question.

• there are almost certainly kinematic/ orbital codes already available that will do a great job. I'd suggest looking for what already exists. – anon01 Aug 8 '16 at 15:22
• The answer is given by Newton's laws, and the equations of kinematics. Are you familiar with them? Your question is not clear. Do you want to know how to set up a simulation, or how to calculate that distance for large (by which I mean not infinitesimal) intervals of time? – garyp Aug 8 '16 at 17:30
• Your question is an "exercise" within the meaning of the policy because it asks for a calculation or a method of calculation. – sammy gerbil Aug 9 '16 at 17:25
• Maybe it is an exercise question, but what I said is that it is not a "homework" question. It was flagged as off topic as a "homework-like" question, not as an exercise question. – AplGuy Aug 9 '16 at 19:46

I think the answer you want is $\Delta x(t)=x(t)-x_0$ where $x$ is found from basic kinematic equations for an object traveling in a straight line:

$x(t)=\frac{a t^2}{2}+v_0 t+x_0$

where $x_0$ is the initial position, $v_0$ is the initial velocity, and $a$ is the acceleration. This answer is only exact if the acceleration is constant. For changing acceleration, this could be a reasonable approximation if the change in acceleration is small compared to the average acceleration.

For the general case of changing acceleration $a(t)$, you have to integrate:

$v(t)=\int_{t_0}^t a(\tau) d\tau$

$x(t)=\int_{t_0}^t v(\tau) d\tau$

and the constants of integration are $v(t_0)=v_0$ and $x(t_0)=x_0$. This solution requires you to know the acceleration as a function of time. If you are doing the integration numerically, it should be no trouble to solve for $x$ on each timestep and feed it back to solve for $a$. If you are solving numerically and you use a short enough time step, you can use the constant acceleration for as an approximation.

From what I understand from your question and assuming

The Earth will start slowly

means that it is initially at rest (not possible, but still for the sake of this problem).

From Newton's equation of kinematics (where 's' is the distance traveled under constant acceleration 'a' in time 't'),

s = ut + (1/2) * a * (t ^ 2)

since u is zero here...

s = (1/2) * a * (t ^ 2)

by rearranging...

t = (2 * s / a) ^ 0.5

But these are standard (which everyone should know) equations of motion. If you don't know these, I wonder how you would create a simulation of space objects interacting with each other.