Skip to content

Instantly share code, notes, and snippets.

@acwoss
Created September 24, 2018 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acwoss/8ad92c350cff8ed1b509b2a760eb4ef0 to your computer and use it in GitHub Desktop.
Save acwoss/8ad92c350cff8ed1b509b2a760eb4ef0 to your computer and use it in GitHub Desktop.
HatefulRundownPaint created by acwoss - https://repl.it/@acwoss/HatefulRundownPaint
from math import factorial, radians, isclose, sin
def seno(x, n=7):
x = radians(x)
def termo_geral(x, i):
return ((-1)**i / factorial(2*i+1)) * (x**(2*i+1))
def termos(x, n):
for i in range(n):
yield termo_geral(x, i)
return sum(termos(x, n))
for angle in {0, 30, 45, 60, 90, 120, 180, 230, 270, 320, 360}:
assert isclose(
seno(angle, 21),
sin(radians(angle)),
abs_tol=1e-5
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment