diff --git a/src/main/py/trigonometry.py b/src/main/py/trigonometry.py index cd98d97..ae1aeb8 100644 --- a/src/main/py/trigonometry.py +++ b/src/main/py/trigonometry.py @@ -15,4 +15,6 @@ def rad2deg(radNumber): return (radNumber * 180) / math.pi def sin_approx_bhaskara(radNumber): - return radNumber \ No newline at end of file + num = 16 * radNumber * (math.pi - radNumber) + denom = 5 * math.pow(math.pi, 2) - 4 * radNumber * (math.pi - radNumber) + return num/denom \ No newline at end of file diff --git a/src/test/py/test_trigonometry.py b/src/test/py/test_trigonometry.py index b7324ff..8297175 100644 --- a/src/test/py/test_trigonometry.py +++ b/src/test/py/test_trigonometry.py @@ -1,5 +1,6 @@ import unittest from src.main.py.trigonometry import * +import math class MyTestCase(unittest.TestCase): @@ -39,6 +40,10 @@ class MyTestCase(unittest.TestCase): def test_sin_0_should_be_0(self): self.assertEqual(sin_approx_bhaskara(0), 0) + def test_sin_quarter_pi_should_be_point707(self): + delta = sin_approx_bhaskara(0.25*math.pi) - 0.707 + self.assertLess(delta, 0.01) + if __name__ == '__main__': unittest.main()