Best way to numerically evaluate derivative of complete elliptic integral 2 kind (C++)

101 Views Asked by At

I need to compute numerically

$$ \frac{d}{dk}E(k) = \frac{E(k)-K(k)}{k} $$ where E and K are the complete elliptic integrals of the second and first kind respectively.

Note that Wolfram uses $m=k^2$. In C++ we have these functions. To go from the C++ function to the wolfram function just raise k to 2 in wolfram or take the sqrt root in C++.

I have to compute with accuracy this derivative in the complete domain [0,1], therefore using the representation I put before or central differences do not give good enough results. I also tried a series expansion which works fine for small k, but not for big k.

What is a good way to evaluate this derivative numerically? In this case, I care about performance.

1

There are 1 best solutions below

2
On

Taking into account all your requirements, for the computation of $$\frac{d}{dk}E(k) = \frac{E(k)-K(k)}{k}$$what I should use is a spline function for $$g(k)=\exp\Big[E(k)-K(k) \Big]$$ which is a nice and smooth function.

You only need one creation of this spline (or any other interpolating function).