# How to evaluate the integral $\int_a^b{\int_0^{2\pi}{\sqrt{y^2(\cos^2{\theta}-1)+1}}\mathrm{d}\theta}\mathrm{d}y$

How to evaluate the following integral in Matlab? $$\int_a^b{\int_0^{2\pi}{\sqrt{y^2(\cos^2{\theta}-1)+1}}\,\mathrm{d}\theta}\,\mathrm{d}y$$

$a$ and $b$ are vectors with values.

-

dblquad(@(t,y)sqrt(y.^2*(cos(t).^2-1)+1), 0, 2*pi, a, b)

-
dblquad() does only accept scalar vectors. So, I will have to inclose it in a for loop. – Osama Gamal Jul 2 '11 at 13:03

I can't tell what evaluating an integral with vector limits means, unless you're doing things componentwise. In that case, you're asking how to evaluate

$$\int_a^b{\int_0^{2\pi}{\sqrt{1-y^2\sin^2{\theta}}}\,\mathrm{d}\theta}\,\mathrm{d}y$$

which simplifies by symmetry to

$$4\int_a^b{\int_0^{\pi/2}{\sqrt{1-y^2\sin^2{\theta}}}\,\mathrm{d}\theta}\,\mathrm{d}y$$

and the complete elliptic integral of the second kind pops up:

$$4\int_a^b{E(y^2)}\,\mathrm{d}y$$

where $E(m)$ is the complete elliptic integral of the second kind with parameter $m$, as implemented in MATLAB.

You can then use the usual quadrature routines (e.g. quad()) like so: construct the appropriate function

function e = osama(x)
[k, e] = ellipke(x^2);


and then feed the function handle to the quadrature routine: 4.*quad(@osama,a,b).

As for a closed form, it involves hypergeometric functions, so I doubt such a thing would be of any use to you.

-
That's pretty useful, thanks :) – Osama Gamal Jun 30 '11 at 9:32