# Integrating the inverse square law, $\ln$ vs $\tan^{-1}$ - domain issue?

EDIT: I ran the $y'(t)$ through Wolfram|Alpha with $p = 1$, $v = 1$ and $k = -1$. The missing answer now comes out in terms of the arctangent function. So what is going on here? Why does it come out in terms of the arctangent instead of natural logarithm?

For $y(t)$ where $y$ is the distance between two point masses, classical mechanics gives us $y''(t) = \frac{k}{y(t)^2}$ for gravitational or electromagnetic attraction.

Multiplying each side by $y'(t)$ and integrating: $$\int y''(t) y'(t) = \int \frac{k y'(t)}{y(t)^2}$$ $$\frac1{2}y'(t)^2 = c_1 - \frac{k}{y(t)}$$

Initial position $p = y(0)$ and velocity $v = y'(0)$: $c_1 = \frac1{2}v^2 + \frac{k}{p}$

This brings us to: $y'(t) = \pm \sqrt{ v^2 + 2k\frac1{p} - 2k\frac1{y(t)}}$

Solving this differential equation results in an implicit function, basically the inverse of $y(t)$: $$c_2 \pm t = \dfrac{k p^{3/2}}{(2k + pv^2)^{3/2}} \ln\left(y(t) \left(\sqrt{(2k - 2k\frac{p}{y(t)} + pv^2)(2k + pv^2)} + 2k + pv^2\right) - kp\right)$$ $$+ y(t) \dfrac{p \sqrt{2k\frac1{p} - 2k\frac1{y(t)} + v^2}}{2k + pv^2}$$ (Wolfram|Alpha)

Now solving for $c_2$ in terms of $p$, $v$ and $k$ (at $t = 0$): $$c_2 = \dfrac{k p^{3/2}}{(2k + pv^2)^{3/2}} \ln\left(p\sqrt{pv^2(2k + pv^2)} + p^2v^2 + kp\right) + \dfrac{p^2|v|}{2k + pv^2}$$

Substituting back in, converting $\ln(a) - \ln(b)$ to $\ln(a/b)$: $$\pm t = \dfrac{k p^{3/2}}{(2k + pv^2)^{3/2}} \ln\left(\dfrac{y(t) \left(\sqrt{(2k - 2k\frac{p}{y(t)} + pv^2)(2k + pv^2)} + 2k + pv^2\right) - kp}{p\sqrt{pv^2(2k + pv^2)} + p^2v^2 + kp}\right)$$$$+ \dfrac{y(t)p\sqrt{2k\frac1{p} - 2k\frac1{y(t)} + v^2} - p^2|v|}{2k + pv^2}$$

And for $v < 0$, we need to switch the sign in front of $t$ on the left hand side (multiply by $\frac{|v|}{v}$) to preserve initial conditions: $$t = \dfrac{k p^{3/2}}{(\frac{2k}{v^2} + p)^{3/2}v^3} \ln\left(\dfrac{y(t) \left(\sqrt{(2k - 2k\frac{p}{y(t)} + pv^2)(2k + pv^2)} + 2k + pv^2\right) - kp}{p\sqrt{pv^2(2k + pv^2)} + p^2v^2 + kp}\right)$$$$+ \dfrac{y(t)pv\sqrt{\frac{2k}{pv^2} - \frac{2k}{y(t)v^2} + 1} - p^2v}{2k + pv^2}$$

So, after all this. The function becomes undefined when $2k < -pv^2$ because of the $\sqrt{2k + pv^2}$, but numeric integration clearly shows that there should be values just as legitimate here. What should I do to fix this? What's missing?

Resolution: Joriki's answer pointed me in the right direction. After wading through mounds of complex algebra, I have verified that the result above is correct for complex numbers and that to define the function in terms of real numbers when $2k < -pv^2$ you must use the arctangent function ($\ln(x + iy) = \ln(\sqrt{x^2 + y^2}) + i\tan^{-1}(\frac{y}{x})$, see Complex Logarithm). So here is my result for $2k < -pv^2$:

$$t = -\dfrac{k p^{3/2}}{(-\frac{2k}{v^2} - p)^{3/2}v^3} \tan^{-1}\left(\dfrac{(k+pv^2)\sqrt{(-2k-pv^2)(-2k\frac{p}{y} + 2k + pv^2)} - (-k\frac{p}{y} + 2k + pv^2)\sqrt{pv^2(-2k - pv^2)})}{(k+pv^2)(-k\frac{p}{y} + 2k + pv^2) - (2k+pv^2)\sqrt{pv^2(-2k\frac{p}{y} + 2k + pv^2)}}\right)$$$$+ \dfrac{y(t)pv\sqrt{\frac{2k}{pv^2} - \frac{2k}{y(t)v^2} + 1} - p^2v}{2k + pv^2}$$

(Any suggestions for simplification are appreciated!)

Edit: Fixed.

-
 Interesting notation. For starters, if it helps: $y''(t)=\frac{k}{y(t)^2}$ are the Euler lagrange equations with $L=T−V$ for the kinetic energy $T=\frac{y'^2}{2}$ and the potential $V=−\frac{k}{y}$. Your condition $2k<−pv^2$ says that for $t=0$ you have $T0$ the term $\frac{k}{y(t)^2}$ is always positive. That's not gravity or electrostatics. – Nick Kidman Dec 13 '11 at 15:32 As far as $k > 0$, I had magnetic repulsion in mind. But when I have a negative $k$ and positive $v$, there is a spot that is undefined that should define the distance over time of an object falling under gravitational acceleration. I'd like it to work for both. – jnm2 Dec 13 '11 at 16:24 I'm not sure if you understand what I ment. Say you have a charge with $k>0$ at the position $q=0$ on your distance axis. Furthermore you have a testcharge which is affected by that charge. By the model $F=y''(t)$ and $y''=\frac{k}{y(t)^2}$ you describe a force, which always pushes in the positive q-direction. This is attraction on the left side of the axis and repulsion on the right. The force equations therefore always have to involve unit vectors. Also, there is no magnetic repulsion like this. (monopole) – Nick Kidman Dec 13 '11 at 17:13 Well, as far as that goes, I could have written $y''(t) = \frac{k}{y(t)|y(t)|}$ and $y'(t) = \pm sgn(y(t)) \sqrt{ v^2 + 2k\frac1{|p|} - 2k\frac1{|y(t)|}}$, but since $p$ is always positive I didn't want to complicate things by normalizing it. It stays on the same side. Bad shortcut? – jnm2 Dec 13 '11 at 22:57 @Nikolaj: You got the sign wrong; the potential corresponding to this force is $V=k/y$, so the condition is $E\lt0$ (which makes a lot more sense). – joriki Dec 14 '11 at 16:43

The sign issues have already been discussed in the comments. I'll focus on the region $p\gt0$, where the force is repulsive if $k\gt0$ and attractive if $k\lt0$.

For $p\gt0$, your inequality $2k\lt-pv^2$ can be rewritten as

$$c_1=\frac12v^2+\frac kp\lt0\;,$$

and since $\frac12v^2$ is the kinetic energy (assuming unit mass as you seem to be doing) and the potential corresponding to this force is $k/p$, this is just the condition that the (time-independent) total energy is negative. Since the kinetic energy is non-negative, this can only happen if $k\lt0$, i.e. in the attractive case. In this case, there are two different types of trajectories. For negative total energy, the trajectory first leads away from the origin until the kinetic energy is used up, and then back to the origin; for positive total energy, the trajectory escapes to infinity. This qualitative distinction corresponds to the difference in the two solutions you see.

Note that there are logarithmic forms for the inverse trigonometric functions, so it may well be that the general solution Wolfram|Alpha gives actually covers both cases if you appropriately interpret the square roots of negative values as imaginary numbers.

In the future, you may want to ask such questions at http://physics.stackexchange.com, where people may be more familiar with differential equations that arise in physics and may have stronger intuitions e.g. about the interpretation of their integration constants.

-