在python中创建指数函数。
16lz
2021-01-22
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
更多相关文章
- 字体图标的引入和通过媒体查询改变导航样式
- HTML样式和常用选择器
- 字体图标的引用和自定义样式/媒体查询的使用
- 数据库的CURD操作、PDO本质与原理的学习
- CSS之伪类选择器和简单盒子简单案例
- 伪类选择器与盒模型常用属性
- 伪类选择器-结构伪类、根据位置选择匹配
- 7.4——常用标签与应用场景之表格与单元格
- css伪类选择器和盒模型