Skip to content

Commit

Permalink
trig funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gonkee committed Aug 28, 2019
1 parent e7a31cb commit 01ee747
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions math functions (python)/gonkee_trig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import math

def my_sin(theta):
theta = math.fmod(theta + math.pi, 2 * math.pi) - math.pi
result = 0
termsign = 1
power = 1

for i in range(10):
result += (math.pow(theta, power) / math.factorial(power)) * termsign
termsign *= -1
power += 2
return result

def my_cos(theta):
theta = math.fmod(theta + math.pi, 2 * math.pi) - math.pi
result = 0
termsign = 1
power = 0

for i in range(10):
result += (math.pow(theta, power) / math.factorial(power)) * termsign
termsign *= -1
power += 2
return result

def my_tan(theta):
return my_sin(theta) / my_cos(theta)

print(my_sin(101))
print(math.sin(101))

print(my_cos(101))
print(math.cos(101))

print(my_tan(101))
print(math.tan(101))

0 comments on commit 01ee747

Please sign in to comment.