Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|cite|improve this question
up vote 2 down vote accepted

Use the dblquad function.

dblquad(@(t,y)sqrt(y.^2*(cos(t).^2-1)+1), 0, 2*pi, a, b)
share|cite|improve this answer
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


which simplifies by symmetry to


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


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.

share|cite|improve this answer
That's pretty useful, thanks :) – Osama Gamal Jun 30 '11 at 9:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.