# 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() 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);