I'm trying to write a simple game engine with gravitation between players and various things, but when objects get rather close the linear approximations get direly inaccurate, and I wanted to be able to keep energy conserved.

So I'm trying to work out this problem here, as the first step before taking it into vector calculus, which I know nothing about:

(note that k = m2*G, because m1a = (m1*m2*g)/x^2, and we assume that mass 2 is held in place... somehow....)

I don't quite know what to do with it, when I tried working it out I got this:

But I don't believe I can find the derivative of x^2 with respect to t like this....

I am only in high school calculus, but can generally get a good quick grasp of math-stuffs, especially if I need it for programming stuffs like this. >.> But if this doesn't qualify as a differential equation as I suspected, just PM me if you move it to another section.

[edit]

I tried to take it a lot further with some substitutions and came up with some weird stuff with natural logs of negative numbers in it.

My logic is clearly screwy in how I try to manipulate the differentials, because if that worked, then so would this:

Which would imply that as long as an acceleration equation exists, velocity is constant, which definitely makes no sense.

So now I'm at a loss again. Can someone please help me out here?

[edit] For those interested, here's my most accurate (and complicated) attempt at a system of equations to show the behavior I need to solve for position over time.

where k = G*m2

And any help drafting a complete system of equations to represent the behavior ofndifferent particles gravitating toward one another, or the pointing out of any flaws in my current system (besides the fact that it only represents gravitation of one particle around another, stationary particle) would also be appreciated.