Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/scipy/special/_spherical_bessel.py : 29%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from ._ufuncs import (_spherical_jn, _spherical_yn, _spherical_in,
2 _spherical_kn, _spherical_jn_d, _spherical_yn_d,
3 _spherical_in_d, _spherical_kn_d)
5def spherical_jn(n, z, derivative=False):
6 r"""Spherical Bessel function of the first kind or its derivative.
8 Defined as [1]_,
10 .. math:: j_n(z) = \sqrt{\frac{\pi}{2z}} J_{n + 1/2}(z),
12 where :math:`J_n` is the Bessel function of the first kind.
14 Parameters
15 ----------
16 n : int, array_like
17 Order of the Bessel function (n >= 0).
18 z : complex or float, array_like
19 Argument of the Bessel function.
20 derivative : bool, optional
21 If True, the value of the derivative (rather than the function
22 itself) is returned.
24 Returns
25 -------
26 jn : ndarray
28 Notes
29 -----
30 For real arguments greater than the order, the function is computed
31 using the ascending recurrence [2]_. For small real or complex
32 arguments, the definitional relation to the cylindrical Bessel function
33 of the first kind is used.
35 The derivative is computed using the relations [3]_,
37 .. math::
38 j_n'(z) = j_{n-1}(z) - \frac{n + 1}{z} j_n(z).
40 j_0'(z) = -j_1(z)
43 .. versionadded:: 0.18.0
45 References
46 ----------
47 .. [1] https://dlmf.nist.gov/10.47.E3
48 .. [2] https://dlmf.nist.gov/10.51.E1
49 .. [3] https://dlmf.nist.gov/10.51.E2
50 """
51 if derivative:
52 return _spherical_jn_d(n, z)
53 else:
54 return _spherical_jn(n, z)
57def spherical_yn(n, z, derivative=False):
58 r"""Spherical Bessel function of the second kind or its derivative.
60 Defined as [1]_,
62 .. math:: y_n(z) = \sqrt{\frac{\pi}{2z}} Y_{n + 1/2}(z),
64 where :math:`Y_n` is the Bessel function of the second kind.
66 Parameters
67 ----------
68 n : int, array_like
69 Order of the Bessel function (n >= 0).
70 z : complex or float, array_like
71 Argument of the Bessel function.
72 derivative : bool, optional
73 If True, the value of the derivative (rather than the function
74 itself) is returned.
76 Returns
77 -------
78 yn : ndarray
80 Notes
81 -----
82 For real arguments, the function is computed using the ascending
83 recurrence [2]_. For complex arguments, the definitional relation to
84 the cylindrical Bessel function of the second kind is used.
86 The derivative is computed using the relations [3]_,
88 .. math::
89 y_n' = y_{n-1} - \frac{n + 1}{z} y_n.
91 y_0' = -y_1
94 .. versionadded:: 0.18.0
96 References
97 ----------
98 .. [1] https://dlmf.nist.gov/10.47.E4
99 .. [2] https://dlmf.nist.gov/10.51.E1
100 .. [3] https://dlmf.nist.gov/10.51.E2
101 """
102 if derivative:
103 return _spherical_yn_d(n, z)
104 else:
105 return _spherical_yn(n, z)
108def spherical_in(n, z, derivative=False):
109 r"""Modified spherical Bessel function of the first kind or its derivative.
111 Defined as [1]_,
113 .. math:: i_n(z) = \sqrt{\frac{\pi}{2z}} I_{n + 1/2}(z),
115 where :math:`I_n` is the modified Bessel function of the first kind.
117 Parameters
118 ----------
119 n : int, array_like
120 Order of the Bessel function (n >= 0).
121 z : complex or float, array_like
122 Argument of the Bessel function.
123 derivative : bool, optional
124 If True, the value of the derivative (rather than the function
125 itself) is returned.
127 Returns
128 -------
129 in : ndarray
131 Notes
132 -----
133 The function is computed using its definitional relation to the
134 modified cylindrical Bessel function of the first kind.
136 The derivative is computed using the relations [2]_,
138 .. math::
139 i_n' = i_{n-1} - \frac{n + 1}{z} i_n.
141 i_1' = i_0
144 .. versionadded:: 0.18.0
146 References
147 ----------
148 .. [1] https://dlmf.nist.gov/10.47.E7
149 .. [2] https://dlmf.nist.gov/10.51.E5
150 """
151 if derivative:
152 return _spherical_in_d(n, z)
153 else:
154 return _spherical_in(n, z)
157def spherical_kn(n, z, derivative=False):
158 r"""Modified spherical Bessel function of the second kind or its derivative.
160 Defined as [1]_,
162 .. math:: k_n(z) = \sqrt{\frac{\pi}{2z}} K_{n + 1/2}(z),
164 where :math:`K_n` is the modified Bessel function of the second kind.
166 Parameters
167 ----------
168 n : int, array_like
169 Order of the Bessel function (n >= 0).
170 z : complex or float, array_like
171 Argument of the Bessel function.
172 derivative : bool, optional
173 If True, the value of the derivative (rather than the function
174 itself) is returned.
176 Returns
177 -------
178 kn : ndarray
180 Notes
181 -----
182 The function is computed using its definitional relation to the
183 modified cylindrical Bessel function of the second kind.
185 The derivative is computed using the relations [2]_,
187 .. math::
188 k_n' = -k_{n-1} - \frac{n + 1}{z} k_n.
190 k_0' = -k_1
193 .. versionadded:: 0.18.0
195 References
196 ----------
197 .. [1] https://dlmf.nist.gov/10.47.E9
198 .. [2] https://dlmf.nist.gov/10.51.E5
199 """
200 if derivative:
201 return _spherical_kn_d(n, z)
202 else:
203 return _spherical_kn(n, z)