Representation of holonomic functions in SymPy¶
Class DifferentialOperator is used to represent the annihilator
but we create differential operators easily using the function
DifferentialOperators(). Class HolonomicFunction represents a holonomic function.
Let’s explain this with an example:
Take
for instance, the differential equation satisfied by it
is
. By definition we conclude it is a holonomic
function. The general solution of this ODE is
but to get
we need to
provide initial conditions i.e.
.
To represent the same in this module one needs to provide the differential
equation in the form of annihilator. Basically a differential operator is an
operator on functions that differentiates them. So
where
denotes n times differentiation of
with
respect to x.
So the differential equation can also be written as
or
.
The part left of
is the annihilator i.e.
.
So this is how one will represent
as a Holonomic Function:
>>> from sympy.holonomic import DifferentialOperators, HolonomicFunction
>>> from sympy.abc import x
>>> from sympy import ZZ
>>> R, D = DifferentialOperators(ZZ.old_poly_ring(x), 'D')
>>> HolonomicFunction(D**2 + 1, x, 0, [0, 1])
HolonomicFunction((1) + (1)*D**2, x, 0, [0, 1])
The polynomial coefficients will be members of the ring ZZ[x] in the example.
The D operator returned by the function DifferentialOperators() can
be used to create annihilators just like SymPy expressions.
We currently use the older implementations of rings in SymPy for priority mechanism.