Second-order non-linear differential equation containing sgn function encountered in literature on the SYK model. I'm trying to solve the following differential equation:
$$J^2\frac{1}{2^{q-1}}\operatorname{sgn}(\tau)e^{g(\tau)}=\partial_\tau^2\Big(\frac{1}{2q}\operatorname{sgn}(\tau)g(\tau)\Big).$$
Here $J^2$ and $q$ are constants and I want to solve for $e^{g(\tau)}$. I encountered this equation in a paper by Gábor Sárosi et al. called "AdS$_2$ holography and the SYK model" (p.38) and "Comments on the Sachdev-Ye-Kitaev model" (p.12) by Juan Maldacena and Douglas Stanford.
According to them the general solution to this differential equation is given by:
$$e^{g(\tau)} =\frac{c_1^2}{\mathcal{J}^2}\frac{1}{\sin^2(c_1(|\tau|+c_2))}$$ where $$\mathcal{J}=J\sqrt{\frac{q}{2^{q-1}}}$$
I am unable to reach the same result unfortunately. What I tried to do is solve the equation for $$|\tau|>0$$ so that I loose the sgn function (this could potentially be the problem) since I'm not sure how to deal with it otherwise. I get:
$$\frac{d^2g(\tau)}{d\tau^2}=J^2\frac{q}{2^{q-2}}e^{g(\tau)}$$
It would be nice if we could make this a first order differential equation so
multiplying both sides by $$\frac{dg(\tau)}{d\tau}$$ and integrating w.r.t. $\tau$ gives:
$$\int\frac{dg(\tau)}{d\tau}\frac{d^2g(\tau)}{d\tau^2}d\tau=J^2\frac{q}{2^{q-2}}\int e^{g(\tau)}\frac{dg(\tau)}{d\tau}d\tau\\$$
$$\frac{1}{2}\Big(\frac{dg(\tau)}{d\tau}\Big)^2=J^2\frac{q}{2^{q-2}}(e^{g(\tau)}+c_1)$$
Here I used integration by parts to rewrite the lhs. Rearranging a bit gives:
$$\frac{dg(\tau)}{d\tau}=J\sqrt{\frac{q}{2^{q-3}}}\sqrt{(e^{g(\tau)}+c_1)}$$
Now that the equation is a separable first order differential equation we can integrate to find the general solution:
$$\int\frac{dg(\tau)}{\sqrt{(e^{g(\tau)}+c_1)}} =J\sqrt{\frac{q}{2^{q-3}}}\int d\tau$$
$$-\frac{2}{\sqrt{c_1}} \operatorname{artanh}\Big(\frac{\sqrt{e^{g(\tau)}+c_1}}{\sqrt{c_1}}\Big) =J\sqrt{\frac{q}{2^{q-3}}}(\tau+c_2)$$
So that:
$$e^{g(\tau)} =c_1\bigg(\tanh^2\Big(\mathcal{J}\sqrt{c_1}(\tau+c_2)\Big)-1\bigg)$$ where again $$\mathcal{J}=J\sqrt{\frac{q}{2^{q-1}}}$$
Obviously this is not the same as the general solution they state in their paper. Hopefully someone can help me see where I go wrong. 
If I check the solution they give in the paper $\Big(e^{g(\tau)} =\frac{c_1^2}{\mathcal{J}^2}\frac{1}{\sin^2(c_1(|\tau|+c_2))}\Big)$ it does work out:
$$\frac{d^2g(\tau)}{d\tau^2}=\mathcal{J}^2e^{g(\tau)}$$
$$\frac{c_1^2}{\sin^2(c_1(|\tau|+c_2))}=\frac{c_1^2}{\sin^2(c_1(|\tau|+c_2))}$$
But I can think of no way of finding the constants of integration ($c_1$ and $c_2$) using boundary conditions $$g(0)=g(\beta)=0$$
 A: I tried to analyze the situation and to understand what happens. I shall refer to the paper by Maldacena and Stanford as to [MS] and to the paper by Sárosi as to [S].
At p. 11 in the first line of the paper [MS] is written that $\tau=it$. Then, I guess, Equation 2.16 from [MS] implies the equation $$\frac{d^2g(\tau)}{d\tau^2}=\color{red}-2\mathcal J^2e^{g(\tau)},$$ whereas (132) from [S] transforms to this equation, but without the minus sign. Nevertheless, both papers provide the same general solution for both equations (assuming $\sin(c(|\tau|+\tau_0))^2$ means $\sin^2(c(|\tau|+\tau_0))$), so I guess that in the later paper ([S]) it was taken from the former paper ([MS]) and the correct equation should have the minus sign. Farther I assume that the funсtion $g$ is real-valued.
Anyway, your way of solution should be applicable mutatis mutandis to both equations. I think that the key point is the following. When we obtain an equality 
$$\left(\frac{dg(\tau)}{d\tau}\right)^2=\color{red}-4\mathcal J^2 (e^{g(\tau)}+c_1), \tag{1}\label{1}$$
we should care about the sign of $c_1$. This is important because Mathcad suggests that the expression for $\int\frac{1}{\sqrt{e^g+c}}dg$ depends on sign of $c$. For a general form it indeed gives an answer 
$\frac{-2}{\sqrt c}\color{blue}{\operatorname{artanh}}{\frac{\sqrt{e^g+c}}{\sqrt c}}$, but for $c=-1$ it
it gives an answer $2\color{blue}{\operatorname{artan}}{\sqrt{e^g-1}}$. So I gave to it an integral  $\int\frac{1}{\sqrt{e^g\color{blue}-c}}dg$ and obtained an answer $\frac{2}{\sqrt c}\color{blue}{\operatorname{artan}}{\frac{\sqrt{e^g-c}}{\sqrt c}}$.
Since the left hand side of the equation \ref{4} is non-negative and at the right hand side it should have the red minus sign, $c_1$ should be non-positive and so the equation transforms to 
$$\frac{dg(\tau)}{d\tau}=2\mathcal J\sqrt{-c_1- e^{g(\tau)}}.$$
But $\int\frac{1}{\sqrt{-c_1-e^g}}dg$ equals $\frac{-2}{\sqrt{–c_1}}\color{blue}{\operatorname{artanh}}\frac{\sqrt{-c_1-e^g}}{\sqrt{–c_1}}.$ But here we again have an archyperbolic function, so I guess that I have misunderstood something, thus we shouldn’t have the red minus.  Then we have an equation 
$$\frac{dg(\tau)}{d\tau}=2\mathcal J\sqrt{e^{g(\tau)}+c_1}.$$
Its general solution  should be 
$$\frac{1}{\sqrt{–c_1}}\operatorname{artan}\frac{\sqrt{e^{g(\tau)}+c_1}}{\sqrt{–c_1}}=\mathcal J\tau+c_2.$$
This should imply 
$$\frac{e^{g(\tau)}+c_1}{-c_1}=\tan^2 (\sqrt{-c_1}(\mathcal J\tau +c_2))$$
So $$e^{g(\tau)}=-c_1-c_1\tan^2 (\sqrt{-c_1}(\mathcal J\tau+c_2))=\frac {-c_1}{\sin^2 (\sqrt{-c_1}(\mathcal J\tau+c_2) +\tfrac\pi2)}.$$

But I can think of no way of finding the constants of integration ($c_1$ and $c_2$) using boundary conditions $$g(0)=g(\beta)=0$$

Given a general solution $e^{g(\tau)}=\left(\frac{\frac{c}{\mathcal{J}}}{\sin c(\tau+\tau_0)}\right)^2$ for $\tau\ge 0$, we have $1=\left(\frac {\frac{c}{\mathcal{J}}}{\sin c\tau_0}\right)^2=\left(\frac {\frac{c}{\mathcal{J}}}{\sin c(\beta+\tau_0)}\right)^2$. This should imply  $\frac{c}{\mathcal{J}}=\pm \sin c\tau_0=\pm \sin c(\beta+\tau_0)$ and then by routine trigonometric transformations lead to solutions [MS, 2.18-19], [S, 134].
