What is the analytical solution for the following integral?
$ \int^{a}_{0}\sqrt{R^2-x^2}dx, $
where $a<R$. I came across this video for that answer, but still have yet to go through it in detail, https://www.youtube.com/watch?v=Jkhrx7h16s0.
How about in 2 dimensions?
Imagine a semi-sphere on a flat X-Y grid surface. I am looking at this sphere from the top, like looking at it with a microscope. I would like to calculate the volume of the sphere which lies in a single grid box at an arbitrary location.
We need to solve the double integral,
$ \int\int\sqrt{R^2-\left(x^2+y^2\right )}dxdy, $
where R is the radius. Lets say $R=10$ cm and I want to know the area in every, $a=1$ cm grid box. The center of the sphere is at coordinates (0,0) and first limits of integration go from -0.5 to 0.5 and 0.0 to 1.0. A grid box, which is exactly straddling the x-axis, could be calculated by setting limits of integration as follows.
$ \int_{a(c-1)}^{ac}\int_{-\frac{a}{2}}^{\frac{a}{2}}\sqrt{R^2-\left(x^2+y^2\right )}dxdy, $
where $a$ and $R$ are given above and c is the number of grid boxes away from the center. One could exploit the symmetry here and calculate
$ 2\int_{a(c-1)}^{ac}\int_{0}^{\frac{a}{2}}\sqrt{R^2-\left(x^2+y^2\right )}dxdy, $
My main question is, what is the analytical solution of this final integral?
This is kind of like a pillar with a square base and a spherical top surface. I know I could approximate this as a sort of wall and only would need the circle equation, however I would like to consider the spherical curvature for completeness.
Update as of 4 March 2018.
Good advice Paul. I will be a little more specific about the constants as well. The integral can now be written as,
\begin{eqnarray} 2\int_{a(c-1)}^{ac}\int_{0}^{\frac{a}{2}}\sqrt{\Psi{}^2+x^2}dxdy, \end{eqnarray}
where $\Psi{}^2=R^2-y^2$, $R$ is the radius, $a=35$, and c=2,3,4,...,16. In words, we are solving the problem for 15 grid points from the center of a sphere to its 2-D projected perimeter (the first pixel is c=2). Note that $35\times{}15=525$, which is the furthest distance from the semi-sphere center, however, $R$ is some arbitrary value between 14 and 15 pixels, or $490<R<525$. This bring up a new problem, that integrating outside the semi-sphere should not contribute to the volume, or $ac>R$. I think this is the same as saying, that I am only considering the real solution and ignoring the imaginary part at the sphere edge in contact with the grid.
Since $\Psi$ is a constant with respect to $x$, our solution for the inside integral is
$ \int_{0}^{\frac{a}{2}}\sqrt{\Psi{}^2+x^2}dx=2\left[\frac{\Psi{}^2}{2}\sin^{-1}{\left(\frac{x}{\Psi}\right)}+\frac{x}{2}\sqrt{\Psi{}^2-x^2}\right]_0^{\frac{a}{2}}. $
Then substituting in the integration limits we get,
$ =2\left[\frac{\Psi{}^2}{2}\sin^{-1}{\left(\frac{a/2}{\Psi}\right)}+\frac{a/2}{2}\sqrt{\Psi{}^2+\left(a/2\right)^2}-\frac{\Psi{}^2}{2}\sin^{-1}{\left(\frac{0}{\Psi}\right)}+\frac{0}{2}\sqrt{\Psi{}^2+0^2}\right]. $
Simplifying and substituting back into the double integral we get the following equation,
$ \int_{a(c-1)}^{ac}2\int_{0}^{\frac{a}{2}}\sqrt{\Psi{}^2+x^2}dxdy=\int_{a(c-1)}^{ac}\left[\Psi{}^2\sin{}^{-1}\left(\frac{a}{2\Psi{}}\right)+\frac{a}{2}\sqrt{\Psi{}^2-\left(\frac{a}{2}\right)^2}\right]dy, $
and substituting $\Psi$ back in we get
$ =\int_{a(c-1)}^{ac}\left[\left(R^2-y^2\right)\sin{}^{-1}\left(\frac{a}{2\sqrt{R^2-y^2}}\right)+\frac{a}{2}\sqrt{R^2-y^2-\left(\frac{a}{2}\right)^2}\right]dy, $
which can be split into 2 integrals,
\begin{eqnarray} =\int_{a(c-1)}^{ac}\left[\left(R^2-y^2\right)\sin{}^{-1}\left(\frac{a}{2\sqrt{R^2-y^2}}\right)\right]dy+\frac{a}{2}\int_{a(c-1)}^{ac}\sqrt{R^2-y^2-\left(\frac{a}{2}\right)^2}dy. \end{eqnarray}
The right hand term (r.h.t) is an integral with a familiar form and using the substitution, $\rho{}^2=R^2-\frac{a^2}{4}$, it becomes
$ \frac{a}{2}\int_{a(c-1)}^{ac}\sqrt{\rho{}^2-y^2}dy. $
The solution is
$ \frac{a}{2}\left[\frac{\rho{}^2}{2}\sin{}^{-1}\left(\frac{y}{\rho}\right)+\frac{y}{2}\sqrt{\rho{}^2-y^2}\right]_{a(c-1)}^{ac}. $
Substituting back in and putting in the integration limits we get for the r.h.t.
$ \frac{a}{2}\left[\frac{R^2-\frac{a^2}{4}}{2}\sin{}^{-1}\left(\frac{ac}{\sqrt{R^2-\frac{a^2}{4}}}\right)+\frac{ac}{2}\sqrt{R^2-\frac{a^2}{4}-a^2c^2}-\frac{R^2-\frac{a^2}{4}}{2}\sin{}^{-1}\left(\frac{a\left(c-1\right)}{\sqrt{R^2-\frac{a^2}{4}}}\right)-\frac{a\left(c-1\right)}{2}\sqrt{R^2-\frac{a^2}{4}-a^2\left(c-1\right)^2}\right]. $
After simplifying, we arrive at the r.h.t. equal to
\begin{eqnarray} \frac{a}{4}\left(R^2-\frac{a^2}{4}\right)\left[\sin{}^{-1}\left(\frac{ac}{\sqrt{R^2-\frac{a^2}{4}}}\right)-\sin{}^{-1}\left(\frac{a\left(c-1\right)}{\sqrt{R^2-\frac{a^2}{4}}}\right)\right]+\frac{a^2}{4}\left[c\sqrt{R^2-\frac{a^2}{4}-a^2c^2}-\left(c-1\right)\sqrt{R^2-\frac{a^2}{4}-a^2\left(c-1\right)^2}\right] \end{eqnarray}
Now we deal with the integral for the left hand term (l.h.t.) which we can split into 2 integrals,
$ \int_{a(c-1)}^{ac}R^2\sin{}^{-1}\left(\frac{a}{2\sqrt{R^2-y^2}}\right)dy-\int_{a(c-1)}^{ac}y^2\sin{}^{-1}\left(\frac{a}{2\sqrt{R^2-y^2}}\right)dy $
What is the solution to the first integral? If I know that, then I can integrate by parts the second, yes? There are solution of arc trigonometeric integrals online, but any advice how to use them?
Also, is it so correct to use only the real solution to these and simply ignore the complex? I think this is the case, but I am not sure.