# MATLAB computes Incomplete Elliptic Integrals incorrectly?

Discussion in 'MATLAB' started by Ishan Sharma, Apr 24, 2010.

1. ### Ishan SharmaGuest

I compute the Incomplete Elliptic Function of the second kind in both MATLAB and Maple. For some values, I obtain an exact match, but not so for others. Please see below:

CASE 1: Perfect match
MATLAB output
MAPLE13 output: 0.9863238216

CASE 2: No match.
MATLAB output
MAPLE13 output: 0.9495803244

Can someone throw light on this?

Thanks!

ishan

Ishan Sharma, Apr 24, 2010

2. ### Walter RobersonGuest

You are mixing floating point numbers and exact numbers, which often
leads to problems. You might get a different result (or not) if you were
to use something like,

mfun('EllipticE', sqrt(1-sym('4/10')^2),
sqrt((1-sym('6/10')^2)/(1-sym('4/10')^2)))

I converted a 10th order series of EllipticE with the same first
argument, and the second near 9/10 (one of your second arguments is
below that, the other above that). Some large numbers are involved --
large enough to present precision problems if the second argument was
not too much bigger (relatively.) Even so, the default 10 digits of
precision within mfun are enough that one can clearly see that in that
range of values, the curve approximates linear fairly closely, which the

I would thus say that you have found a bug.

Walter Roberson, Apr 24, 2010

3. ### Roger StaffordGuest

----------
I don't know the parameters MAPLE13 uses for elliptic integrals but you should check on it. Even within Mathworks there are two conflicting definitions used. Here are two excerpts from Mathworks manuals:

ellipke:
"Some definitions of K and E use the elliptical modulus k instead of the
parameter m. They are related as k^2 = m."

EllipticE(x,k):
"This definition uses modulus k. The numerical ellipke function and the MuPAD functions for computing elliptic integrals use the parameter m = k^2."

Also I would advise you to display your matlab results to a higher accuracy by using 'format long', so the comparisons will be more valid. You might find that your "perfect match" was not so perfect.

Roger Stafford

Roger Stafford, Apr 24, 2010
4. ### Roger StaffordGuest

After consulting some old tables of elliptic integrals I agree with Walter. The answer 1.4182 you quote as being given by 'EllipticE' is way off the correct value for the arguments you state you have given it. That answer would only be correct for a k value well below .6 and an x value much closer than yours to 1. After double checking your answers you should report this to Mathworks.

Roger Stafford

Roger Stafford, Apr 24, 2010
5. ### moiseev.igorGuest

You may try to use the "elliptic12" function from the elliptic package

Just get the single file elliptic12.m, put it in your PATH and it
gives the results for incomplete ellip. integrals F and E.

The only difference with Maple is that it calculates the integrals
with different to maple representation,
check the sample code for "asin" and square of "sqrt((1-.6^2)/(1-.
4^2))" to obtain the same results!

[F,E] = elliptic12(asin(sqrt(1-.4^2)),(1-.5^2)/(1-.4^2))
F =
1.474960073006188
E =
0.949580324404286

moiseev.igor, Apr 27, 2010
6. ### DanielGuest

Can I ask how well this package has been validated?
Being the only (if not the only) full elliptic function package in Matlab which is available to my knowledge, I wanted to know how well it works? ... feedback from users etc...? Couldn't find much about this online...

Daniel, Dec 7, 2011