I want to write a function that takes a single floating-point parameter x and returns the value of the function e(to the power of x) . Using the Taylor series expansion to compute the return value, using a loop that terminates when the partial sum SN+1 of Eq. (2) is equal to SN.

我想写一个函数,它接受一个浮点参数x并返回函数e的值(对于x的幂)。使用泰勒级数展开来计算返回值,使用一个循环,当部分和SN+1(2)等于SN时终止。

Dont know how to make to the power of so i'm putting in a link to the Wikipedia article for the Taylor Series.

我不知道该怎么做,所以我把维基百科的文章链接到泰勒系列。

3 个解决方案

#1


7

Imho there is no need to implement what is already there.

Imho没有必要去实现已经存在的东西。

import math

math.exp(x) # equivalent to e ^ x

but if you insist, there is the pow function also:

但如果你坚持,也有pow功能:

import math

math.pow(x, y) # equivalent to x ^ y

更多相关文章

  1. 字体图标的引入和通过媒体查询改变导航样式
  2. HTML样式和常用选择器
  3. 字体图标的引用和自定义样式/媒体查询的使用
  4. 数据库的CURD操作、PDO本质与原理的学习
  5. CSS之伪类选择器和简单盒子简单案例
  6. 伪类选择器与盒模型常用属性
  7. 伪类选择器-结构伪类、根据位置选择匹配
  8. 7.4——常用标签与应用场景之表格与单元格
  9. css伪类选择器和盒模型

随机推荐

  1. 如何用 Map 对象创建 Set 对象
  2. redis集群教程(一)
  3. Arrays.sort() 你应该知道的事
  4. Java线程之线程的同步与锁
  5. redis之Sentinel
  6. Java线程之线程的交互
  7. clone 方法是如何工作的
  8. redis之发布与订阅
  9. Java线程之线程的调度-休眠
  10. Java 的版本历史与特性