Why am I getting two different answers while calculating $\int \frac{dx}{\sqrt{2ax-x^2}}$?

I was calculating the antiderivative of the function $\frac{1}{\sqrt{2ax-x^2}}$. I got two different answers in two different ways.

First way: $$\int \frac{dx}{\sqrt{2ax-x^2}}=\int \frac{dx}{\sqrt x\cdot\sqrt{2a-x}}=2\int \frac{\frac{1}{2\sqrt x}dx}{\sqrt{2a-(\sqrt x)^2}}=\int \frac{d(\sqrt x)}{\sqrt{(\sqrt {2a})^2-(\sqrt x)^2}}=2\sin^{-1}\sqrt{\frac{x}{2a}}+c$$

Second way: $$\int \frac{dx}{\sqrt{2ax-x^2}}=\int \frac{dx}{\sqrt{a^2-(x-a)^2}}=\int \frac{d(x-a)}{\sqrt{a^2-(x-a)^2}}=\sin^{-1}\frac{x-a}{a}+c$$

It seems that $2\sin^{-1}\sqrt{\frac{x}{2a}}$ and $\sin^{-1}\frac{x-a}{a}$ are unequal. So I think one of my methods is wrong. But I've checked and found nothing wrong. So what is happening here? And if both of my methods are correct, how to show that these two expressions are equal?


Indeed, $2\arcsin\left(\sqrt{\frac x{2a}}\right)$ and $\arcsin\left(\frac{x-a}a\right)$ are distinct functions, since the first one maps $0$ into $0$ and the second one maps $0$ into $-\frac\pi2$. But if you differentiate them, then you will get $\frac1{\sqrt{2ax-x^2}}$ (assuming that $a>0$). So, you always have$$2\arcsin\left(\sqrt{\frac x{2a}}\right)=\arcsin\left(\frac{x-a}a\right)+\frac\pi2.\tag1$$That is, they are indeed not equal, but their difference is a constant. So, there is no problem here.

The fact that $(1)$ holds can also be proved without differentiation. Just note that\begin{align}\sin\left(2\arcsin\left(\sqrt{\frac x{2a}}\right)\right)&=2\sin\left(\arcsin\left(\sqrt{\frac x{2a}}\right)\right)\cos\left(\arcsin\left(\sqrt{\frac x{2a}}\right)\right)\\&=2\sqrt{\frac x{2a}}\sqrt{1-\frac x{2a}}\\&=\frac{\sqrt{2ax-a^2}}a\end{align}and that\begin{align}\sin\left(\arcsin\left(\frac{x-a}a\right)+\frac\pi2\right)&=\cos\left(\arcsin\left(\frac{x-a}a\right)\right)\\&=\sqrt{1-\left(\frac{x-a}a\right)^2}\\&=\frac{\sqrt{2ax-a^2}}a.\end{align}


You can take the sine or cosine of both expressions, if you account for a $\pi/2$ shift (the integration constants are different).

For the first part, $$\cos\left(2\sin^{-1}\sqrt\frac{x}{2a}\right)=1-2\sin^2\left(\sin^{-1}\sqrt\frac{x}{2a}\right)=1-2\frac x{2a}=1-\frac xa$$

For the second one, you need to shift by $\pi/2$, $$\cos\left(\sin^{-1}\frac{x-a}a+\frac\pi2\right)=-\sin\left(\sin^{-1}\frac{x-a}a\right)=1-\frac xa$$

You can see this in enter image description here