# Is there a easy way to plot Jacobi Elliptic Functions with Tikz-PGF?

So The Jacobi Elliptic Functions are a little bit tricky to plot because they depend on the complete elliptic integral of the first kind `K(k)` that can be written as a sum of double factorials, and the Fourier series for the Jacobi Elliptic Functions then depend on exponentials of these elliptic integrals, I can easily write all the mathematical formulas, but I don't know an easy way to represent them on Tikz or PGF, probably gnuplot would be the easiest but I would like to make it depend only on Tikz PGF because of configurations problems I am having with gnuplot, and I would like to write that in a formulaic form, instead of a table because I would like to change a parameter easily from one compilation to another.

Basically, is there a way to calculate summations and double factorials in Tikz - PGF on some variables and then use them in a plot of a function that will depend on those ?

Bassically I need a way of calculating:

``````K(k) = pi/2 sum[n=0:10] ((( 2 * n - 1)!!)/((2 * n)!!)) * (k^(2*n))
``````

and for a given `u` and `v= sqrt(1-u^2)`

``````q = exp(-pi * (K(v)/K(u)))
``````

calculate and plot for example:

``````sn_u(x) = (2* pi/(K(u) * u)) * sum[n=0:5] (((q^(n+0.5)) * sin((2*n+1) * x * pi/(2 * K(u))))/(1-(q^(2n+1))))
``````

How do I implement these sums and double factorial as a function? Also is there a way to make these calculations modular in the way I wrote them?

• this image is a true or false example about your `sn_u(x)`, imgur.com/rXpzMTX. Jun 19 at 11:47
• It seems about right, but 0.5 is a boring value for u, it is too much like a sin function, a u=0.95 is the interesting one. Jun 19 at 16:46
• imgur.com/TJwWe3s Jun 19 at 17:16
• Jacobi elliptic functions are defined in Sage, here. This can be accessed with the sagetex package and the output can be forced through tikz/pgf in the similar fashion to this post on modified Bessel functions. It sounds like this would address your concern with gnuplot.I'm not sure of your parameters in jacobi('sn', ?, ?) but it seems like it would be straightforward.
– DJP
Jun 19 at 18:04
• @NguyenVanChi1998 yes, looks like you got it to work, I don't know if you put more terms in the sums but the approximation is very good. Here is a Desmos graph with all of the functions, but if you could answer how did you do for sn I can modify it easily for the other functions. Jun 19 at 18:11