scipy.special.
jnp_zeros#
- scipy.special.jnp_zeros(n, nt)[原始碼]#
計算整數階貝索函數導數 Jn’ 的零點。
計算在區間 \((0, \infty)\) 上函數 \(J_n'(x)\) 的 nt 個零點。零點會以遞增順序返回。請注意,此區間不包含 \(n > 1\) 時存在的 \(x = 0\) 處的零點。
- 參數:
- nint
貝索函數的階數
- ntint
要返回的零點數量
- 返回:
- ndarray
貝索函數的前 nt 個零點。
參考文獻
[1]Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
範例
計算 \(J_2'\) 的前四個根。
>>> from scipy.special import jnp_zeros >>> jnp_zeros(2, 4) array([ 3.05423693, 6.70613319, 9.96946782, 13.17037086])
由於
jnp_zeros
產生 \(J_n'\) 的根,因此可以用於計算 \(J_n\) 的峰值位置。繪製 \(J_2\)、\(J_2'\) 以及 \(J_2'\) 根的位置。>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.special import jn, jnp_zeros, jvp >>> j2_roots = jnp_zeros(2, 4) >>> xmax = 15 >>> x = np.linspace(0, xmax, 500) >>> fig, ax = plt.subplots() >>> ax.plot(x, jn(2, x), label=r'$J_2$') >>> ax.plot(x, jvp(2, x, 1), label=r"$J_2'$") >>> ax.hlines(0, 0, xmax, color='k') >>> ax.scatter(j2_roots, np.zeros((4, )), s=30, c='r', ... label=r"Roots of $J_2'$", zorder=5) >>> ax.set_ylim(-0.4, 0.8) >>> ax.set_xlim(0, xmax) >>> plt.legend() >>> plt.show()