Skip to content

Instantly share code, notes, and snippets.

@ShikouYamaue
Last active June 5, 2022 10:32
Show Gist options
  • Save ShikouYamaue/506275694fd4e0895038c1ee338cdffd to your computer and use it in GitHub Desktop.
Save ShikouYamaue/506275694fd4e0895038c1ee338cdffd to your computer and use it in GitHub Desktop.
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