1
1
r"""
2
- Jacobi elliptic functions
2
+ Jacobi Elliptic Functions
3
3
4
4
This module implements the 12 Jacobi elliptic functions, along with their
5
5
inverses and the Jacobi amplitude function.
21
21
``c``, ``d``, and ``n``. The rectangle is understood to be lying on the complex
22
22
plane, so that ``s`` is at the origin, ``c`` is on the real axis, and ``n`` is
23
23
on the imaginary axis. The twelve Jacobian elliptic functions are
24
- then $ \operatorname{pq}(x)$ , where ``p`` and ``q`` are one of the letters
24
+ then ` \operatorname{pq}(x)` , where ``p`` and ``q`` are one of the letters
25
25
``s``, ``c``, ``d``, ``n``.
26
26
27
27
The Jacobian elliptic functions are then the unique
36
36
from ``p`` to ``q``. `\operatorname{pq}(x)` is periodic in the other two
37
37
directions as well, with a period such that the distance from ``p`` to one
38
38
of the other corners is a quarter period.
39
- #. If the function $ \operatorname{pq}(x)$ is expanded in terms of $x$ at one of
39
+ #. If the function ` \operatorname{pq}(x)` is expanded in terms of `x` at one of
40
40
the corners, the leading term in the expansion has a coefficient of 1.
41
41
In other words, the leading term of the expansion of `\operatorname{pq}(x)`
42
- at the corner ``p`` is $x$ ; the leading term of the expansion at the corner
43
- ``q`` is $ 1/x$ , and the leading term of an expansion at the other two
42
+ at the corner ``p`` is `x` ; the leading term of the expansion at the corner
43
+ ``q`` is ` 1/x` , and the leading term of an expansion at the other two
44
44
corners is 1.
45
45
46
46
We can write
47
47
48
- .. math ::
48
+ .. MATH ::
49
49
50
- \operatorname{pq}(x)= \frac{\operatorname{pr}(x)}{\operatorname{qr}(x)}
50
+ \operatorname{pq}(x) = \frac{\operatorname{pr}(x)}{\operatorname{qr}(x)}
51
51
52
52
where ``p``, ``q``, and ``r`` are any of the
53
53
letters ``s``, ``c``, ``d``, ``n``, with
54
- the understanding that `\mathrm{ss}=\mathrm{cc}=\mathrm{dd}=\mathrm{nn}=1`.
54
+ the understanding that `\mathrm{ss} = \mathrm{cc} = \mathrm{dd}
55
+ = \mathrm{nn} = 1`.
55
56
56
57
Let
57
58
58
- .. math ::
59
+ .. MATH ::
59
60
60
- u= \int_0^\phi \frac{d\theta} {\sqrt {1-m \sin^2 \theta}}
61
+ u = \int_0^{ \phi} \frac{d\theta} {\sqrt {1-m \sin^2 \theta}},
61
62
63
+ then the *Jacobi elliptic function* `\operatorname{sn}(u)` is given by
62
64
63
- Then the *Jacobi elliptic function* `\operatorname{sn}(u)` is given by
64
-
65
- .. math::
65
+ .. MATH::
66
66
67
67
\operatorname{sn}{u} = \sin{\phi}
68
68
69
69
and `\operatorname{cn}(u)` is given by
70
70
71
- .. math ::
71
+ .. MATH ::
72
72
73
73
\operatorname{cn}{u} = \cos{\phi}
74
74
75
75
and
76
76
77
- .. math ::
77
+ .. MATH ::
78
78
79
79
\operatorname{dn}{u} = \sqrt{1 - m\sin^2 \phi}.
80
80
86
86
solutions to the following nonlinear ordinary differential
87
87
equations:
88
88
89
- - `\operatorname{sn}\,(x;k)` solves the differential equations
90
-
91
- .. math::
92
-
93
- \frac{d^2 y}{dx^2} + (1+k^2) y - 2 k^2 y^3 = 0,
94
-
95
- and
96
-
97
- .. math::
98
-
99
- \left(\frac{dy}{dx}\right)^2 = (1-y^2) (1-k^2 y^2).
89
+ - `\operatorname{sn}\,(x;k)` solves the differential equations
100
90
101
- - `\operatorname{cn}(x;k)` solves the differential equations
91
+ .. MATH::
102
92
93
+ \frac{d^2 y}{dx^2} + (1+k^2) y - 2 k^2 y^3 = 0
94
+ \quad \text{ and } \quad
95
+ \left(\frac{dy}{dx}\right)^2 = (1-y^2) (1-k^2 y^2).
103
96
104
- .. math::
97
+ - `\operatorname{cn}(x;k)` solves the differential equations
105
98
106
- \frac{d^2 y}{dx^2} + (1-2k^2) y + 2 k^2 y^3 = 0,
99
+ .. MATH::
107
100
108
- and `\left(\frac{dy}{dx}\right)^2 = (1-y^2)(1-k^2 + k^2 y^2)`.
101
+ \frac{d^2 y}{dx^2} + (1-2k^2) y + 2 k^2 y^3 = 0
102
+ \quad \text{ and } \quad
103
+ \left(\frac{dy}{dx}\right)^2 = (1-y^2)(1-k^2 + k^2 y^2).
109
104
110
- - `\operatorname{dn}(x;k)` solves the differential equations
105
+ - `\operatorname{dn}(x;k)` solves the differential equations
111
106
112
- .. math ::
107
+ .. MATH ::
113
108
114
- \frac{d^2 y}{dx^2} - (2 - k^2) y + 2 y^3 = 0,
115
-
116
- and ` \left(\frac{dy}{dx}\right)^2= y^2 (1 - k^2 - y^2)` .
109
+ \frac{d^2 y}{dx^2} - (2 - k^2) y + 2 y^3 = 0
110
+ \quad \text{ and } \quad
111
+ \left(\frac{dy}{dx}\right)^2 = y^2 (1 - k^2 - y^2).
117
112
118
113
If `K(m)` denotes the complete elliptic integral of the
119
114
first kind (named ``elliptic_kc`` in Sage), the elliptic functions
120
115
`\operatorname{sn}(x|m)` and `\operatorname{cn}(x|m)` have real periods
121
116
`4K(m)`, whereas `\operatorname{dn}(x|m)` has a period
122
- `2K(m)`. The limit `m\rightarrow 0` gives
117
+ `2K(m)`. The limit `m \rightarrow 0` gives
123
118
`K(0) = \pi/2` and trigonometric functions:
124
119
`\operatorname{sn}(x|0) = \sin{x}`, `\operatorname{cn}(x|0) = \cos{x}`,
125
120
`\operatorname{dn}(x|0) = 1`. The limit `m \rightarrow 1` gives
130
125
131
126
REFERENCES:
132
127
133
- - http://en. wikipedia.org/wiki/ Jacobi's_elliptic_functions
128
+ - : wikipedia:` Jacobi's_elliptic_functions`
134
129
135
- - A. Khare, U. Sukhatme, "Cyclic Identities Involving
136
- Jacobi Elliptic Functions", Math ArXiv, math-ph/0201004
130
+ .. [KhaSuk04] A. Khare and U. Sukhatme. "Cyclic Identities Involving
131
+ Jacobi Elliptic Functions". :arxiv:` math-ph/0201004`
137
132
138
133
AUTHORS:
139
134
140
135
- David Joyner (2006): initial version
141
136
142
- - Eviatar Bach (2013): complete rewrite, new numerical evaluation, and addition
143
- of the Jacobi amplitude function
137
+ - Eviatar Bach (2013): complete rewrite, new numerical evaluation, and
138
+ addition of the Jacobi amplitude function
144
139
"""
145
140
146
141
#*****************************************************************************
172
167
173
168
174
169
class Jacobi (BuiltinFunction ):
170
+ """
171
+ Base class for the Jacobi elliptic functions.
172
+ """
175
173
def __init__ (self , kind ):
176
174
r"""
177
- Base class for the Jacobi elliptic functions
175
+ Initialize ``self``.
178
176
179
177
EXAMPLES::
180
178
@@ -354,24 +352,24 @@ def _eval_(self, x, m):
354
352
return csch (x )
355
353
return
356
354
357
- def _evalf_ (self , x , m , parent ):
355
+ def _evalf_ (self , x , m , parent , algorithm = None ):
358
356
r"""
359
357
TESTS::
360
358
361
359
sage: jacobi_sn(3, 4).n(100)
362
360
-0.33260000892770027112809652714 + 1.7077912301715219199143891076e-33*I
363
361
sage: jacobi_dn(I, I).n()
364
362
0.874189950651018 + 0.667346865048825*I
365
- """
363
+ """
366
364
from mpmath import ellipfun
367
365
return utils .call (ellipfun , self .kind , x , m , parent = parent )
368
366
369
367
def _derivative_ (self , x , m , diff_param ):
370
368
r"""
371
369
TESTS:
372
370
373
- sn, cn, and dn are analytic for all real x , so we can check that the
374
- derivatives are correct by computing the series::
371
+ sn, cn, and dn are analytic for all real ``x`` , so we can check
372
+ that the derivatives are correct by computing the series::
375
373
376
374
sage: from mpmath import almosteq
377
375
sage: a = 0.9327542442482303
@@ -532,9 +530,12 @@ def _print_latex_(self, x, m):
532
530
533
531
534
532
class InverseJacobi (BuiltinFunction ):
533
+ r"""
534
+ Base class for the inverse Jacobi elliptic functions.
535
+ """
535
536
def __init__ (self , kind ):
536
537
r"""
537
- Base class for the inverse Jacobi elliptic functions
538
+ Initialize ``self``.
538
539
539
540
EXAMPLES::
540
541
@@ -718,7 +719,7 @@ def _eval_(self, x, m):
718
719
return Integer (0 )
719
720
return
720
721
721
- def _evalf_ (self , x , m , parent ):
722
+ def _evalf_ (self , x , m , parent , algorithm = None ):
722
723
r"""
723
724
TESTS::
724
725
@@ -727,15 +728,14 @@ def _evalf_(self, x, m, parent):
727
728
sage: inverse_jacobi_cd(3, 4).n(100)
728
729
-0.67214752201235862490069823239 + 2.1565156474996432354386749988*I
729
730
"""
730
- return utils .call (inverse_jacobi_f , self .kind , x , m ,
731
- parent = parent )
731
+ return utils .call (inverse_jacobi_f , self .kind , x , m , parent = parent )
732
732
733
733
def _derivative_ (self , x , m , diff_param ):
734
734
r"""
735
735
TESTS:
736
736
737
- Check that dy/dx * dx/dy == 1, where y = jacobi_pq(x, m) and
738
- x = inverse_jacobi_pq(y, m)::
737
+ Check that `` dy/dx * dx/dy == 1`` , where `` y = jacobi_pq(x, m)`` and
738
+ `` x = inverse_jacobi_pq(y, m)`` ::
739
739
740
740
sage: from mpmath import almosteq
741
741
sage: a = 0.130103220857094
@@ -932,15 +932,15 @@ def _print_latex_(self, x, m):
932
932
933
933
def jacobi (kind , z , m , ** kwargs ):
934
934
r"""
935
- The 12 Jacobi elliptic functions
935
+ The 12 Jacobi elliptic functions.
936
936
937
937
INPUT:
938
938
939
939
- ``kind`` -- a string of the form ``'pq'``, where ``p``, ``q`` are in
940
940
``c``, ``d``, ``n``, ``s``
941
941
- ``z`` -- a complex number
942
- - ``m`` -- a complex number. Note that `m= k^2`, where `k` is the elliptic
943
- modulus.
942
+ - ``m`` -- a complex number; note that `m = k^2`, where `k` is
943
+ the elliptic modulus
944
944
945
945
EXAMPLES::
946
946
@@ -985,11 +985,12 @@ def jacobi(kind, z, m, **kwargs):
985
985
"'ds', 'dc', 'sn', 'sd', 'sc', 'cn', 'cd', 'cs'." )
986
986
987
987
def inverse_jacobi (kind , x , m , ** kwargs ):
988
- """
988
+ r """
989
989
The inverses of the 12 Jacobi elliptic functions. They have the property
990
990
that
991
991
992
- .. math::
992
+ .. MATH::
993
+
993
994
\operatorname{pq}(\operatorname{arcpq}(x|m)|m) =
994
995
\operatorname{pq}(\operatorname{pq}^{-1}(x|m)|m) = x.
995
996
@@ -998,8 +999,8 @@ def inverse_jacobi(kind, x, m, **kwargs):
998
999
- ``kind`` -- a string of the form ``'pq'``, where ``p``, ``q`` are in
999
1000
``c``, ``d``, ``n``, ``s``
1000
1001
- ``x`` -- a real number
1001
- - ``m`` -- a real number. Note that `m= k^2`, where `k` is the elliptic
1002
- modulus.
1002
+ - ``m`` -- a real number; note that `m = k^2`, where `k` is the elliptic
1003
+ modulus
1003
1004
1004
1005
EXAMPLES::
1005
1006
@@ -1062,8 +1063,8 @@ def inverse_jacobi(kind, x, m, **kwargs):
1062
1063
class JacobiAmplitude (BuiltinFunction ):
1063
1064
r"""
1064
1065
The Jacobi amplitude function
1065
- `\operatorname{am}(x|m)= \int_0^x \operatorname{dn}(t|m) dt`. For
1066
- `-K(m) \leq x \leq K(m)`, `F(\operatorname{am}(x|m)|m)=x.`
1066
+ `\operatorname{am}(x|m) = \int_0^x \operatorname{dn}(t|m) dt` for
1067
+ `-K(m) \leq x \leq K(m)`, `F(\operatorname{am}(x|m)|m) = x`.
1067
1068
"""
1068
1069
def __init__ (self ):
1069
1070
r"""
@@ -1100,7 +1101,7 @@ def _eval_(self, x, m):
1100
1101
return Integer (0 )
1101
1102
return
1102
1103
1103
- def _evalf_ (self , x , m , parent ):
1104
+ def _evalf_ (self , x , m , parent , algorithm = None ):
1104
1105
r"""
1105
1106
TESTS::
1106
1107
@@ -1149,17 +1150,16 @@ def _print_latex_(self, x, m):
1149
1150
1150
1151
1151
1152
def inverse_jacobi_f (kind , x , m ):
1152
- """
1153
+ r """
1153
1154
Internal function for numerical evaluation of a continous complex branch
1154
- of each inverse Jacobi function, as described in [Tee ]_. Only accepts real
1155
- arguments.
1155
+ of each inverse Jacobi function, as described in [Tee97 ]_. Only accepts
1156
+ real arguments.
1156
1157
1157
1158
REFERENCES:
1158
1159
1159
- .. [Tee] Tee, Garry J. "Continuous branches of inverses of the 12 Jacobi
1160
- elliptic functions for real argument". 1997.
1161
- https://researchspace.auckland.ac.nz/bitstream/handle/2292/5042/\
1162
- 390.pdf.
1160
+ .. [Tee97] Tee, Garry J. "Continuous branches of inverses of the 12 Jacobi
1161
+ elliptic functions for real argument". 1997.
1162
+ https://researchspace.auckland.ac.nz/bitstream/handle/2292/5042/390.pdf.
1163
1163
1164
1164
TESTS::
1165
1165
@@ -1287,7 +1287,6 @@ def inverse_jacobi_f(kind, x, m):
1287
1287
1288
1288
sage: chop(ellipfun('ds', inverse_jacobi_f('ds', 4, 0.25), 0.25))
1289
1289
mpf('4.0')
1290
-
1291
1290
"""
1292
1291
from mpmath import mp
1293
1292
@@ -1626,16 +1625,15 @@ def inverse_jacobi_f(kind, x, m):
1626
1625
1627
1626
1628
1627
def jacobi_am_f (x , m ):
1629
- """
1628
+ r """
1630
1629
Internal function for numeric evaluation of the Jacobi amplitude function
1631
- for real arguments. Procedure described in [Ehrhardt ]_.
1630
+ for real arguments. Procedure described in [Ehrhardt13 ]_.
1632
1631
1633
1632
REFERENCES:
1634
1633
1635
- .. [Ehrhardt] Ehrhardt, Wolfgang. "The AMath and DAMath Special Functions:
1636
- Reference Manual and Implementation Notes, Version 1.3".
1637
- 2013. http://www.wolfgang-ehrhardt.de/specialfunctions.pdf.
1638
-
1634
+ .. [Ehrhardt13] Ehrhardt, Wolfgang. "The AMath and DAMath Special
1635
+ Functions: Reference Manual and Implementation Notes, Version 1.3".
1636
+ 2013. http://www.wolfgang-ehrhardt.de/specialfunctions.pdf.
1639
1637
1640
1638
TESTS::
1641
1639
@@ -1707,3 +1705,4 @@ def jacobi_am_f(x, m):
1707
1705
return ctx .atan2 (snz , cnz ) + npi
1708
1706
finally :
1709
1707
ctx .prec = prec
1708
+
0 commit comments