The task is to integrate:
$$ \int\sqrt{(x-a)(b-x)}dx $$
Letting $ h = x -a $ we get: $$ \int\sqrt{(x-a)(b-x)}dx = \int\sqrt{h(b-a-h)}dh $$ Letting $ c = b - a$ we get: $$ \int\sqrt{h(b-a-h)}dh = \int\sqrt{h(c-h)}dh $$ After that substitute $z = h - \frac{c}{2}$ and we get: $$ \int\sqrt{h(c-h)}dh = \int\sqrt{(z + \frac{c}{2})(\frac{c}{2}-z)}dz $$ Then we let $e= \frac{c}{2}$ so that: $$ \int\sqrt{(z + \frac{c}{2})(\frac{c}{2}-z)}dz = \int\sqrt{(z + e)(e-z)}dz = \int\sqrt{e^2-z^2}dz = \int\frac{e^2-z^2}{\sqrt{e^2-z^2}}dz = \int\frac{e^2}{\sqrt{e^2-z^2}}dz - \int\frac{z^2}{\sqrt{e^2-z^2}}dz = \int\frac{e^2}{|e|\sqrt{1-\frac{z^2}{e^2}}}dz - \int\frac{z^2}{|e|\sqrt{1-\frac{z^2}{e^2}}}dz =\int\frac{|e|}{\sqrt{1-\frac{z^2}{e^2}}}dz - \frac{1}{|e|}\int\frac{z^2}{\sqrt{1-\frac{z^2}{e^2}}}dz $$
Next we let $g = \frac{z}{e}$, which means $z = ge, dz= edg$ after which we get: $$ \int\frac{|e|}{\sqrt{1-\frac{z^2}{e^2}}}dz - \frac{1}{|e|}\int\frac{z^2}{\sqrt{1-\frac{z^2}{e^2}}}dz = \int\frac{|e|}{\sqrt{1-\frac{e^2g^2}{e^2}}}edg - \frac{1}{|e|}\int\frac{e^2g^2}{\sqrt{1-\frac{e^2g^2}{e^2}}}edg = \int\frac{|e|e}{\sqrt{1-g^2}}dg - \frac{e^3}{|e|}\int\frac{g^2}{\sqrt{1-g^2}}dg $$ Integrating the term on the left gives: $$ \int\frac{|e|e}{\sqrt{1-g^2}}dg - \frac{e^3}{|e|}\int\frac{g^2}{\sqrt{1-g^2}}dg = |e|e\arcsin{g} - \frac{e^3}{|e|}\int\frac{g^2}{\sqrt{1-g^2}}dg $$ For the second term we let $\sin{u} = g$ from which $\cos(u)du = dg$ and so: $$ |e|e\arcsin{g} - \frac{e^3}{|e|}\int\frac{g^2}{\sqrt{1-g^2}}dg = |e|e\arcsin{g} - \frac{e^3}{|e|}\int\frac{\sin^2{u}\cos{u}}{\sqrt{1-\sin^2{u}}}du $$ Now since $\sqrt{1-\sin^2{a}} = \cos{a}$ we have: $$ |e|e\arcsin{g} - \frac{e^3}{|e|}\int\frac{\sin^2{u}\cos{u}}{\sqrt{1-\sin^2{u}}}du = |e|e\arcsin{g} - \frac{e^3}{|e|}\int\sin^2{u}du $$ But $\sin^2{u} = \frac{1}{2} - \frac{\cos{2u}}{2}$ so: $$ |e|e\arcsin{g} - \frac{e^3}{|e|}\int\sin^2{u}du = |e|e\arcsin{g} - \frac{e^3}{|e|}\int \frac{1}{2} - \frac{\cos{2u}}{2} du = |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}u - \frac{1}{4}\sin{2u}) $$ Using $\sin{2a} = 2\sin{a}\cos{a} = 2\sin{a}\sqrt{1-\sin^2{a}}$ we have: $$ |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}u - \frac{1}{4}\sin{2u}) = |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}u - \frac{1}{2}\sin{u}\sqrt{1-\sin^2{u}}) $$ Unwinding the substitution $\sin{u} = g$ we get $u = \arcsin{g}$ we have: $$ |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}u - \frac{1}{2}\sin{u}\sqrt{1-\sin^2{u}}) = |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}\arcsin{g} - \frac{1}{2}\sin{\arcsin{g}}\sqrt{1-\sin^2{\arcsin{g}}}) = |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}\arcsin{g} - \frac{1}{2}g\sqrt{1-g^2}) $$ Distributing the $\frac{e^3}{|e|}$, and since $\frac{e^3}{|e|} = e|e|$ we get: $$ |e|e\arcsin{g} - \frac{e^3}{|e|}(\frac{1}{2}\arcsin{g} - \frac{1}{2}g\sqrt{1-g^2}) = |e|e\frac{\arcsin{g}}{2} + |e|e\frac{1}{2}g\sqrt{1-g^2} $$ Unwinding $g = \frac{z}{e}$ we get: $$ |e|e\frac{\arcsin{g}}{2} + |e|e\frac{1}{2}g\sqrt{1-g^2} = |e|e\frac{\arcsin{\frac{z}{e}}}{2} + |e|e\frac{1}{2}\frac{z}{e}\sqrt{1-\frac{z^2}{e^2}} = |e|e\frac{\arcsin{\frac{z}{e}}}{2} + \frac{|e|}{2}z\sqrt{\frac{e^2-z^2}{e^2}} = |e|e\frac{\arcsin{\frac{z}{e}}}{2} + \frac{1}{2}z\sqrt{e^2-z^2}= |e|e\frac{\arcsin{\frac{z}{e}}}{2} + \frac{1}{2}z\sqrt{(z+e)(e-z)} $$ Unwinding $\sqrt{(z+e)(e-z)}$ we get $\sqrt{(x-a)(b-x)}$ also unwinding $z=h-\frac{c}{2} = x - a - \frac{b-a}{2} = \frac{2x-(b+a)}{2}$ in the second term we get: $$ |e|e\frac{\arcsin{\frac{z}{e}}}{2} + \frac{1}{2}z\sqrt{(z+e)(e-z)} = |e|e\frac{\arcsin{\frac{z}{e}}}{2} + \frac{1}{2}\frac{2x-(b+a)}{2}\sqrt{(x-a)(b-x)} = |e|e\frac{\arcsin{\frac{z}{e}}}{2} + \frac{1}{4}(2x-(b+a))\sqrt{(x-a)(b-x)} $$ The right answer should be (I left out the $+C$ term for clarity):
$$ \frac{1}{4}|b-a|(b-a)\arcsin{\sqrt{\frac{x-a}{b-a}}} + \frac{1}{4}(2x-(b+a))\sqrt{(x-a)(b-x)} $$ Experssing this with $e = \frac{b-a}{2}$ and $z=x-a-\frac{b-a}{2}$ we get: $$ |e|e\arcsin{\sqrt{\frac{z+e}{2e}}} + \frac{1}{4}(2x-(b+a))\sqrt{(x-a)(b-x)} $$ The problem is that $$\arcsin{\sqrt{\frac{z+e}{2e}}} \ne \frac{\arcsin{\frac{z}{e}}}{2}$$ in general and I can't find an error in my calculations. Can anyone point out the erroneous step I made?
I figured out what went wrong, it's not obvious so I figured I post it here for reference.
The last equation in my question states $$ \arcsin{\frac{\sqrt{z+e}}{2e}} \ne \frac{\arcsin{\frac{z}{e}}}{2} $$
however it turns out they differ only by a constant since: $$ D = \frac{d}{dz}\left[\arcsin{\frac{\sqrt{z+e}}{2e}} - \frac{\arcsin{\frac{z}{e}}}{2}\right] = \frac{d}{dz}\arcsin{\frac{\sqrt{z+e}}{2e}} - \frac{d}{dz}\frac{\arcsin{\frac{z}{e}}}{2} $$ taking the derivatives we get $$ D =\frac{1}{\sqrt{1-\frac{z+e}{2e}}}\frac{1}{2\sqrt{\frac{z+e}{2e}}}\frac{1}{2e} - \frac{1}{2}\frac{1}{\sqrt{1-\frac{z^2}{e^2}}}\frac{1}{e} \\ D = \frac{1}{2e}\left[\frac{1}{2\sqrt{\frac{e-z}{2e}}}\frac{1}{\sqrt{\frac{z+e}{2e}}}-\frac{1}{\sqrt{\frac{e^2-z^2}{e^2}}}\right] \\ D = \frac{1}{2} \left[\frac{e}{\sqrt{e^2-z^2}} - \frac{e}{\sqrt{e^2-z^2}}\right] = 0 $$
Thus my result and the right answer differ only by a constant which is hidden in the +C. I appreciate all the comments and answers.