Esempio n. 1
0
def sin(x):
    if abs(x) >= 2 * pi():
        x -= 2 * pi() * (x // (2 * pi()))
    max_n = 1000
    min_diff = 1e-6
    sin_x = 0
    stop = False
    n = 0
    while not stop:
        new_term = (-1)**n * x**(2 * n + 1) / factorial(2 * n + 1)
        sin_x += new_term
        if n == max_n or abs(new_term) < min_diff:
            stop = True
        n += 1
    return sin_x
Esempio n. 2
0
 def test_pi(self):
     '''Test computation of pi'''
     my_pi = pi(1)
     assert np.isclose(my_pi, np.pi, atol=1e-12)
Esempio n. 3
0
 def test_pi(self):
     """Test computation of pi"""
     my_pi = pi(2)
     assert np.isclose(my_pi, np.pi, atol=1e-12)