Skip to main content
12-Amethyst
October 4, 2016
Solved

Complete Elliptic Integral

  • October 4, 2016
  • 1 reply
  • 3962 views

Hi everyone!

It seems strange to me, but I am not finding in the forum any previous post to the subject.  I need to calculate the Complete Elliptic Integral of the 2nd kind.

Since it will be evaluated many times inside a double loop, it would be probably unwise to define it using its "integral definition", because of performance.

(from Wikipedia... sorry, I am not a mathematician...)

Unbenannt.JPG

Has someone good advice for me?  What I am going to try is to use the "Gauss hypergeometric function" that seems to be available in Mathcad (fhyper)

Nevertheless I am unsure if this is a good idea.

Thanks a lot for any hints

Best regards

Claudio

Best answer by StuartBruff

Have a look at this thread ... Length of a sine curve

Stuart

1 reply

23-Emerald V
October 4, 2016

Have a look at this thread ... Length of a sine curve

Stuart

12-Amethyst
October 4, 2016

Hi Stuart and thanks!

yes I believe this is the way I decided to go! Although I programmed it with inverted signs (due to Wikipedia):  That means the first argument is -1/2, the second 1/2.

Unbenannt1.JPG

I made a short test and the results seems to be identical.  Thanks a lot, apparently this is the "way" to compute the elliptical integral in Mathcad.

Have a nice day

Claudio

23-Emerald V
October 4, 2016

Claudio Pedrazzi wrote:

Hi Stuart and thanks!

yes I believe this is the way I decided to go! Although I programmed it with inverted signs (due to Wikipedia):  That means the first argument is -1/2, the second 1/2.

Unbenannt1.JPG

I made a short test and the results seems to be identical.  Thanks a lot, apparently this is the "way" to compute the elliptical integral in Mathcad.

Have a nice day

Claudio

I'm having second thoughts about the hypergeometric function implementation.  (Well, when I say "thoughts", I mean the random firing of the miswired neurons that pass for my brain)

One of these random thoughts made me wonder how the values and execution times might differ between the different means of evaluating the elliptic integral.  So I created an integral representation, looked up some values in Abramowitz and Stegun (A&S), and ran a few values in Matlab and Wolfram Alpha.  I wish I hadn't because the hypergeometric form is different to the integral values, the A&S values and those of Matlab and Wolfram Alpha ... markedly so.

Unfortunately, the symbolic processor doesn't know about fhyper, so I couldn't it to check that the more limited precision of the numerical processor wasn't the source of the discrepancies.  I used hypergeom to get some symbollically-generated values to get round this problem, but (I can't decide whether it's for better or worse), I got the roughly the same values using hypergeom as I did using fhyper.

In addition, the fhyper-based function also had problems evaluating some values (see Matlab / Wolfram Alpha comparison below).

I don't know what's going on, and I haven't had time to look into it in any detail.

Definitions:

Comparisons with A&S:

Comparison with Matlab and Wolfram Alpha:

Symbolic Processor hypergeom implementation:

SymE4, in the results below, is the result of running EllipticE4 on the (0,5..45) degree range

Stuart