Solving intersection of translated spiric curve The spiric section is the curve obtained by slicing a torus along a plane parallel to its axis. Assume the torus midplane lies in the $z=0$ plane, $a$ is the radius of the torus tube and $c$ is the distance from the origin of the center of the tube.
Now cut the torus with the plane $y = r$ and we get the curve:
$$z^2=a^2-(c-\sqrt{x^2+r^2})^2$$

I'm interested only in the bottom part:
$$f(x)=z=-\sqrt{a^2-(c-\sqrt{x^2+r^2})^2}$$

And more specifically I'm trying to find the horizontal position of the intersection between $f(x)$ and a translated copy $q+f(x+p)$ (with $p$ and $q$ integers), in other words:
I want to solve the following equation for $x$, symbolically if possible:
$$q - \sqrt{a^2 - (c - \sqrt{(p - x)^2 + r^2})^2} + \sqrt{a^2 - (c - \sqrt{r^2 + x^2})^2} = 0$$
(in the appropriate domain where square roots are real)

Note: I don't have a lot of experience with math software, but I have tried both SageMath and WolframAlpha, and wasn't able to get a closed form solution, although WolframAlpha can solve the case where $c=0$:.
 A: The implicit equation of the torus is
$$(x^2+y^2+z^2+R^2-r^2)^2=4r^2(x^2+y^2)$$
and the parametric equation of the shifted one is
$$\begin{cases}x=(R+r\cos\theta)\cos\phi+p\\y=(R+r\cos\theta)\sin\phi\\z=r\sin\theta+q.\end{cases}$$
The sections are given by
$$y=Y$$ and by eliminating $\theta$,
$$R+r\cos\theta=Y\csc\phi,\\
\\
x=Y\cot\phi+p,\\z=q\pm\sqrt{r^2-\left(Y\csc\phi-R\right)^2}.$$
Then plugging one into the other,
$$\left((Y\cot\phi+p)^2+Y^2+\left(q\pm\sqrt{r^2-\left(Y\csc\phi-R\right)^2}\right)^2+R^2-r^2\right)^2=4r^2((Y\cot\phi+p)^2+Y^2).$$
We can rationalize with $\csc\theta=\dfrac{1+t^2}{2t}$ and $\cot\theta=\dfrac{1-t^2}{2t}$, giving
$$\left(\left(Y\dfrac{1-t^2}{2t}+p\right)^2+Y^2+\left(q\pm\sqrt{r^2-\left(Y\dfrac{1+t^2}{2t}-R\right)^2}\right)^2+R^2-r^2\right)^2=4r^2\left(\left(Y\dfrac{1-t^2}{2t}+p\right)^2+Y^2\right),$$
or, multiplying by $16t^4$,
$$\left(\left(Y(1-t^2)+2pt^2\right)^2+4(Y^2+R^2-r^2)t^2+\left(2qt\pm\sqrt{4r^2t^2-\left(Y(1+t^2)-2Rt\right)^2}\right)^2\right)^2=16r^2\left(\left(Y(1-t^2)+2pt\right)^2+4Y^2t^2\right)t^2.$$
It is possible to turn this equation in a polynomial one after leeennnngthy computation to eliminate the square root.
