Last active
June 5, 2022 10:32
-
-
Save ShikouYamaue/506275694fd4e0895038c1ee338cdffd to your computer and use it in GitHub Desktop.
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
import math | |
def my_sin(x): | |
e = x | |
f = 1.0 | |
t = 0.0 | |
for i in range(1, 100): | |
if i % 2 == 1: | |
t += e / f | |
else: | |
t -= e / f | |
e *= x ** 2.0 | |
f *= i * 2.0 * (i * 2.0 + 1.0) | |
return t | |
def main(): | |
# 確認 | |
print('my_sin :', my_sin(2)) | |
print('math.sin :', math.sin(2)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment