I have a C++ code that computes jacobian elliptic sn, cn and dn.
void elipticjacobi(double u, double m, double * sn, double * cn, double * dn) {
if(fabs(m) > 1.0) {
*sn = 0.0;
*cn = 0.0;
*dn = 0.0;
//error code
}
....
}
If I calculate sn(2,0.2) with my code, and if I calculate sn(2,0.2) with WolframAlpha I am getting the same result and the result is 0.953667.
The elliptic function second argument must be |m|<1 but if I calculate sn(2,4) with WolframAlpha I am getting -0,29.
What could be the problem?
Mathematica (which WA is built upon) implements the Jacobi elliptic functions $\operatorname{sn}(z,m)$ etc. not just for $0<m<1$ but also for complex values of $m$; the documentation for JacobiSN says that it's a meromorphic function in both arguments. But I haven't managed to find the exact definition in the documentation. It's $\operatorname{sn}(z,m) = \sin \operatorname{am}(z,m)$, and the documentation for JacobiAmplitude says a little about branch cuts and $m>1$ at least. Perhaps someone at the Mathematica SE would know more about the details?