Browse Source

refactoring: Made the piApproxLeibniz function use the already implemented functions for basic addition, multiplication and division

remotes/origin/feature/feature-trigonometry
fdai7764 11 months ago
parent
commit
6767e8a3f3
  1. 8
      src/main/py/trigonometry.py

8
src/main/py/trigonometry.py

@ -1,15 +1,15 @@
import math
from src.main.py.logarithmic_and_expo_and_root_calculations import potentiate
from src.main.py.primitive_calculations import *
def pi_approx_leibniz(precision):
if precision < 0:
return -1
result = 0
for i in range(precision):
num = potentiate(-1, i)
denom = 2*i + 1
result += num/denom
return result * 4
denom = add(1, multiply(2,i))
result = add(result, divide(num, denom))
return multiply(result, 4)
def rad2deg(radNumber):
return (radNumber * 180) / math.pi
Loading…
Cancel
Save