Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中查找函数的倒数(可能使用Symphy)_Python_Function_Sympy - Fatal编程技术网

在Python中查找函数的倒数(可能使用Symphy)

在Python中查找函数的倒数(可能使用Symphy),python,function,sympy,Python,Function,Sympy,有没有办法在Python中找到函数的倒数?例如,如果我有函数def(x):return x**2,Python/任何Python库函数中是否有这样的函数?或者这太难了,或者对计算机来说是无法解决的?如果f(x)的倒数是i,那么为x求解f(x)-i就得到了倒数。所以 >>> from sympy import solve >>> from sympy.abc import i, x >>> solve(x**2 - i, x) [-sqrt(i

有没有办法在Python中找到函数的倒数?例如,如果我有函数
def(x):return x**2
,Python/任何Python库函数中是否有这样的函数?或者这太难了,或者对计算机来说是无法解决的?

如果
f(x)
的倒数是
i
,那么为x求解
f(x)-i
就得到了倒数。所以

>>> from sympy import solve
>>> from sympy.abc import i, x
>>> solve(x**2 - i, x)
[-sqrt(i), sqrt(i)]

因此,对于该函数,给定的
i

有两个分支,该库将计算可逆函数的数值逆: