@ -1,3 +1,13 @@
import math
from src.main.py.logarithmic_and_expo_and_root_calculations import potentiate
def pi_approx_leibniz(precision):
result = 0
for i in range(precision):
num = potentiate(-1, i)
denom = 2*i + 1
result += num/denom
return result * 4
def rad2deg(radNumber):
return (radNumber * 180) / math.pi
@ -9,6 +9,12 @@ class MyTestCase(unittest.TestCase):
def tearDown(self):
pass
def test_pi_precision_1000000_should_be_3_point_141592(self):
delta = pi_approx_leibniz(1000000) - 3.141592
if delta < 0:
delta *= -1
self.assertLess(delta, 0.01)
def test_rad_2_to_deg_should_be_114_point_59(self):
delta = rad2deg(2) - 114.59