QQ 1274510382 Wechat JNZ_aming 商业互捧 QQ群538250800 技术搞事 QQ群599020441 技术合作 QQ群152889761 加入我们 QQ群649347320 纪年科技aming 网络安全 ,深度学习,嵌入式,机器强化,生物智能,生命科学。
import math
n
= int(input('input order n(odd number): '))
x
= eval(input('input x: '))
exact_sol
= math
.sin(x
)
s
= 0
flag
= 1
for i
in range(1, n
+1, 2):
s
+= flag
* math
.pow(x
, i
)/math
.factorial(i
)
flag
= -flag
number_sol
= s
print('exact solution sin(%s)=%s' % (x
, exact_sol
))
print('numerical solution = %s' % number_sol
)