Two Cases Of Harmonic Motion Caused By Gravity I'm a highschool student and we learned not so long ago Simple Harmonic Motion, and I'm trying to analyse "similar" cases which I thought of.

Here we have a body (with mass $m$) being affected by the gravity of a body whose mass is $M$, yet it doesn't collide with it (it just goes through its center depiste not being so realistic). I want to mathematically describle this motion.
Just as doing with SHM, we get the differential equation
$m\frac{d^2x}{dt^2}=\frac{GMm}{x^2}\Rightarrow x^2 \frac{d^2x}{dt^2}=GM:=k$
Obviously I don't have the tools to solve such equation (I can only solve easy separables and using Laplace Transform), But Wolfram gave me the following solution

Looking back, I realized that at $x=0$ the force is "infinite" and I kind of stopped there since I'm clueless (plus I couldn't find the constants)
Another case I thought of which might be more realistic is the following

Here the movment on the perpendicular bisector of course.
We have $\Sigma F=2(\frac{GMm}{d^2+x^2})\cos\alpha=\frac{2GMmx}{(d^2+x^2)\sqrt{d^2+x^2}}$ So
$\frac{d^2x}{dt^2}(d^2+x^2)^\frac{3}{2}=2GMx:=kx$, which Wolfram couldn't solve.
I'm pretty sure this might not be far fetched, I came here to see if anyone has any contributions to my understanding? Perhaps some good way to approximate one of the motions?
Thanks for reading this mess!
 A: The first case is very different from a harmonic oscillator. The speed of the moving body becomes infinite as passes through the center. 
The second case could be analyzed by expanding $$\frac{x}{(d^2+x^2)^{3/2}}= \frac{x}{d^3}\left(1-\frac{3x^2}{2d^2} + \ldots\right)\tag 1$$
If $x\ll d$ you need only to retain the first term in the expansion $(1),$
$$\frac{\mathrm d^2x}{\mathrm dt^2}=-\frac{2GM}{d^3}x\,.$$
Here I have inserted a minus sign that you missed in all of your equations. It comes from that the force is in the opposite direction to the $x$-coordinate.
A: Harmonic motion $(x=A\sin(\omega t))$ depends on having a restoring force which is proportional to the displacement from the equilibrium position. 
This is not true for your 1st case. Although there will be an oscillation, it is not harmonic. You can avoid the infinite force at $x=0$ by giving mass $M$ a finite radius and constant density, and creating a narrow tunnel through one diameter. The force inside $M$ is then proportional to displacement from the centre of $M$, so if $m$ remains inside $M$ the motion will be harmonic.
In the 2nd case there is approximate SHM for small values of displacement $x$.
