Hide keyboard shortcuts

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) 

4 

5def spherical_jn(n, z, derivative=False): 

6 r"""Spherical Bessel function of the first kind or its derivative. 

7 

8 Defined as [1]_, 

9 

10 .. math:: j_n(z) = \sqrt{\frac{\pi}{2z}} J_{n + 1/2}(z), 

11 

12 where :math:`J_n` is the Bessel function of the first kind. 

13 

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. 

23 

24 Returns 

25 ------- 

26 jn : ndarray 

27 

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. 

34 

35 The derivative is computed using the relations [3]_, 

36 

37 .. math:: 

38 j_n'(z) = j_{n-1}(z) - \frac{n + 1}{z} j_n(z). 

39 

40 j_0'(z) = -j_1(z) 

41 

42 

43 .. versionadded:: 0.18.0 

44 

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) 

55 

56 

57def spherical_yn(n, z, derivative=False): 

58 r"""Spherical Bessel function of the second kind or its derivative. 

59 

60 Defined as [1]_, 

61 

62 .. math:: y_n(z) = \sqrt{\frac{\pi}{2z}} Y_{n + 1/2}(z), 

63 

64 where :math:`Y_n` is the Bessel function of the second kind. 

65 

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. 

75 

76 Returns 

77 ------- 

78 yn : ndarray 

79 

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. 

85 

86 The derivative is computed using the relations [3]_, 

87 

88 .. math:: 

89 y_n' = y_{n-1} - \frac{n + 1}{z} y_n. 

90 

91 y_0' = -y_1 

92 

93 

94 .. versionadded:: 0.18.0 

95 

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) 

106 

107 

108def spherical_in(n, z, derivative=False): 

109 r"""Modified spherical Bessel function of the first kind or its derivative. 

110 

111 Defined as [1]_, 

112 

113 .. math:: i_n(z) = \sqrt{\frac{\pi}{2z}} I_{n + 1/2}(z), 

114 

115 where :math:`I_n` is the modified Bessel function of the first kind. 

116 

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. 

126 

127 Returns 

128 ------- 

129 in : ndarray 

130 

131 Notes 

132 ----- 

133 The function is computed using its definitional relation to the 

134 modified cylindrical Bessel function of the first kind. 

135 

136 The derivative is computed using the relations [2]_, 

137 

138 .. math:: 

139 i_n' = i_{n-1} - \frac{n + 1}{z} i_n. 

140 

141 i_1' = i_0 

142 

143 

144 .. versionadded:: 0.18.0 

145 

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) 

155 

156 

157def spherical_kn(n, z, derivative=False): 

158 r"""Modified spherical Bessel function of the second kind or its derivative. 

159 

160 Defined as [1]_, 

161 

162 .. math:: k_n(z) = \sqrt{\frac{\pi}{2z}} K_{n + 1/2}(z), 

163 

164 where :math:`K_n` is the modified Bessel function of the second kind. 

165 

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. 

175 

176 Returns 

177 ------- 

178 kn : ndarray 

179 

180 Notes 

181 ----- 

182 The function is computed using its definitional relation to the 

183 modified cylindrical Bessel function of the second kind. 

184 

185 The derivative is computed using the relations [2]_, 

186 

187 .. math:: 

188 k_n' = -k_{n-1} - \frac{n + 1}{z} k_n. 

189 

190 k_0' = -k_1 

191 

192 

193 .. versionadded:: 0.18.0 

194 

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)