Created
September 24, 2018 16:36
-
-
Save acwoss/8ad92c350cff8ed1b509b2a760eb4ef0 to your computer and use it in GitHub Desktop.
HatefulRundownPaint created by acwoss - https://repl.it/@acwoss/HatefulRundownPaint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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