功能#
所有函数都支持下面记录的方法,继承自 sympy.core.function.Function
.
- class sympy.core.function.Function(*args)[源代码]
应用数学函数的基类。
它还充当未定义函数类的构造函数。
See the Writing Custom Functions guide for details on how to subclass
Function
and what methods can be defined.实例
Undefined Functions
To create an undefined function, pass a string of the function name to
Function
.>>> from sympy import Function, Symbol >>> x = Symbol('x') >>> f = Function('f') >>> g = Function('g')(x) >>> f f >>> f(x) f(x) >>> g g(x) >>> f(x).diff(x) Derivative(f(x), x) >>> g.diff(x) Derivative(g(x), x)
Assumptions can be passed to
Function
the same as with aSymbol
. Alternatively, you can use aSymbol
with assumptions for the function name and the function will inherit the name and assumptions associated with theSymbol
:>>> f_real = Function('f', real=True) >>> f_real(x).is_real True >>> f_real_inherit = Function(Symbol('f', real=True)) >>> f_real_inherit(x).is_real True
Note that assumptions on a function are unrelated to the assumptions on the variables it is called on. If you want to add a relationship, subclass
Function
and define custom assumptions handler methods. See the Assumptions section of the Writing Custom Functions guide for more details.Custom Function Subclasses
The Writing Custom Functions guide has several Complete Examples of how to subclass
Function
to create a custom function.- as_base_exp()[源代码]
将方法作为2元组(基、指数)返回。
- fdiff(argindex=1)[源代码]
返回函数的一阶导数。
- classmethod is_singular(a)[源代码]
测试参数是本质奇点还是分支点,或者函数是非全纯的。