def test_approx(self): x = np.arange(10, 50, 0.1) n = 5 j = sph_bessel.jn(n, x) approx_j = sph_bessel.approx_jn(n, x) #plt.plot(x, j) #plt.plot(x, approx_j) #plt.plot(x, approx_j-j) #plt.show() self.assertTrue(np.allclose(j, approx_j, atol=0.003))
def test_jn(self): n = 1234 x = 2300. right_ans = special.sph_jn(n, x)[0][-1] j = sph_bessel.jn(n, x) self.assertTrue(np.allclose(j, right_ans))
def test_j0(self): x = np.arange(1, 1000) / 10. right_ans = np.sin(x) / x sph_j0 = sph_bessel.jn(0, x) self.assertTrue(np.allclose(sph_j0, right_ans))