0
$\begingroup$

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.

2 Answers 2

2

Use the dblquad function.

dblquad(@(t,y)sqrt(y.^2*(cos(t).^2-1)+1), 0, 2*pi, a, b) 
  • 0
    dblquad() does only accept scalar vectors. So, I will have to inclose it in a for loop.2011-07-02
2

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.

  • 0
    That's pretty useful, thanks :)2011-06-30