泰勒公式求 e的x次方

  • Post author:
  • Post category:其他


# _*_ coding:utf-8 _*_

import numpy as np

def jie(i):
    s = 1
    for j in range(1, i+1):
        s = s * j
    return s


x = int(input("请输入x="))
n = int(input("请输入n="))
s = 1
for i in range(1, n+1):
    s = s+np.power(x, i)/jie(i)
print(s)

e^x=1+x+x^2/2!+x^3/3!+…..+x^n/n!

input()默认输入的是字符,需要转化否则出错



版权声明:本文为u013589137原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。