Definite Integral: $\int_{0}^{2\pi}\frac{d \theta }{\sqrt{1-k^{2}\cos( \theta )}}$

308 Views Asked by At

I need integral result for following integral: $$\int_{0}^{2\pi}\frac{d \theta }{\sqrt{1-k^{2}\cos( \theta )}}$$

It will be useful in an electromagnetic simulator. It is obtained as the medium 1/distance from one ring to a point that is separated to the axis. Actually due the objects where split in a 3-d mesh of 24k pieces so to solve the problem its takes 3 hours due inverse of 24k x 24k arrays (that reach the 16GB limit of RAM).

I have look for at definite integral tables but was not found It would help an APPROXIMATE solution that reduces the 3-D problem to 2D. It is said it is a first kind elliptic integral, but I do not know how to place in an elliptic expression and what lib can be used with C++. Boost is included in actual C++11 but I do not know if the elliptic integral lib is included in it

2

There are 2 best solutions below

0
On

The response is: $$\displaystyle\int_{0}^{2\pi}\frac{d \theta }{\sqrt{1-k^{2}\cos( \theta )}}=2\displaystyle\int_{0}^{\pi}\frac{d \theta }{\sqrt{1-k^{2}\cos( \theta )}}$$

$$\displaystyle\int_{0}^{\pi/2}\frac{dt }{\sqrt{1-k^{2}\cos(2t)}}=4\displaystyle\int_{0}^{\pi/2}\frac{dt }{\sqrt{1-k^{2}(1-2sin^2(t))}}=4\displaystyle\int_{0}^{\pi/2}\frac{dt }{\sqrt{(1-k^{2})+2k^2sin^2(t)}}$$ That is an elliptic integral of the first order.

Result can be found here: Forum math

Where $$\theta=2t$$

I used boost and worked. Elliptic integrals are included in in C++17, so it is not needed install boost:

#include<iostream>
#include <cmath>


const double PI = 3.1415926535897932384626433832795;
const double PI2 = 2.0 * PI;

using namespace std;


int main()
{
    double flimit = PI, k = 0.25, f;
    f = ellint_1(k, flimit);
    double expected = 1.596242222131783510149;
    cout << "Ellint error for k,F=" << k << " & " << flimit << " = " << fabs(f - expected) << endl;

    cout << endl << "=== END ===" << endl; getchar();
    return 1;
}
0
On

In the notation here, we get a complete elliptic integral of the first kind viz. $$\int_{0}^{2\pi}\frac{d\theta}{\sqrt{1-k^{2}\cos\theta}}=2\int_{0}^{\pi}\frac{d\theta}{\sqrt{1-k^{2}\cos\theta}}=\frac{4}{\sqrt{1-k^{2}}}\int_{0}^{\pi/2}\frac{d\phi}{\sqrt{1-\frac{2k^{2}}{k^{2}-1}\sin^{2}\phi}}=\frac{4}{\sqrt{1-k^{2}}}K\left(\sqrt{\frac{2k^{2}}{k^{2}-1}}\right).$$As discussed therein, the easiest fast accurate calculation for a given $k$ uses the aithmetic-geometric mean.