Functions#

All functions support the methods documented below, inherited from sympy.core.function.Function.

class sympy.core.function.Function(*args)[source]

Base class for applied mathematical functions.

It also serves as a constructor for undefined function classes.

See the Writing Custom Functions guide for details on how to subclass Function and what methods can be defined.

Examples

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 a Symbol. Alternatively, you can use a Symbol with assumptions for the function name and the function will inherit the name and assumptions associated with the Symbol:

>>> 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()[source]

Returns the method as the 2-tuple (base, exponent).

fdiff(argindex=1)[source]

Returns the first derivative of the function.

classmethod is_singular(a)[source]

Tests whether the argument is an essential singularity or a branch point, or the functions is non-holomorphic.

Contents#