ore_algebra.analytic.function

D-Finite analytic functions

Classes

DFiniteFunction(dop, ini[, name, max_prec, …]) At the moment, this class just provides a simple caching mechanism for repeated evaluations of a D-Finite function on the real line.
RealPolApprox(pol, prec)
class ore_algebra.analytic.function.DFiniteFunction(dop, ini, name='dfinitefun', max_prec=256, max_rad=[+/- inf])

At the moment, this class just provides a simple caching mechanism for repeated evaluations of a D-Finite function on the real line. It may evolve to support evaluations on the complex plane, branch cuts, ring operations on D-Finite functions, and more. Do not expect any API stability.

TESTS:

sage: from ore_algebra import *
sage: from ore_algebra.analytic.function import DFiniteFunction
sage: from ore_algebra.analytic.path import Point
sage: from sage.rings.infinity import AnInfinity

sage: Dops, x, Dx = DifferentialOperators()

sage: f = DFiniteFunction(Dx - 1, [1], max_rad=7/8)
sage: f._disk(Point(pi, dop=Dx-1))
(7/2, 0.5000000000000000)

sage: f = DFiniteFunction(Dx^2 - x,
....:         [1/(gamma(2/3)*3^(2/3)), -1/(gamma(1/3)*3^(1/3))],
....:         name='my_Ai')
sage: f.plot((-5,5))
Graphics object consisting of 1 graphics primitive
sage: f._known_bound(RBF(RIF(1/3, 2/3)), post_transform=Dops.one())
[0.2...]
sage: f._known_bound(RBF(RIF(-1, 5.99)), post_transform=Dops.one())
[+/- ...]
sage: f._known_bound(RBF(RIF(-1, 6.01)), Dops.one())
[+/- inf]

sage: f = DFiniteFunction((x^2 + 1)*Dx^2 + 2*x*Dx, [0, 1])
sage: f.plot((0, 4))
Graphics object consisting of 1 graphics primitive
sage: f._known_bound(RBF(RIF(1,4)), Dops.one())
[1e+0 +/- 0.3...]
sage: f.approx(1, post_transform=Dx), f.approx(2, post_transform=Dx)
([0.5000000000000...], [0.2000000000000...])
sage: f._known_bound(RBF(RIF(1.1, 2.9)), post_transform=Dx)
[+/- 0.4...]
sage: f._known_bound(RBF(AnInfinity()), Dops.one())
[+/- inf]

sage: f = DFiniteFunction((x + 1)*Dx^2 + 2*x*Dx, [0, 1])
sage: f._known_bound(RBF(RIF(1,10)),Dops.one())
nan
sage: f._known_bound(RBF(AnInfinity()), Dops.one())
nan

sage: f = DFiniteFunction(Dx^2 + 2*x*Dx, [1, -2/sqrt(pi)], name='my_erfc')
sage: f._known_bound(RBF(RIF(-1/2,1/2)), post_transform=Dx^2)
[+/- inf]
sage: _ = f.approx(1/2, post_transform=Dx^2)
sage: _ = f.approx(-1/2, post_transform=Dx^2)
sage: f._known_bound(RBF(RIF(-1/2,1/2)), post_transform=Dx^2)
[+/- 1.5...]
approx(pt, prec=None, post_transform=None)

TESTS:

sage: from ore_algebra import *
sage: from ore_algebra.analytic.function import DFiniteFunction
sage: DiffOps, x, Dx = DifferentialOperators()

sage: h = DFiniteFunction(Dx^3-1, [0, 0, 1])
sage: h.approx(0, post_transform=Dx^2)
[2.0000000000000...]

sage: f = DFiniteFunction((x^2 + 1)*Dx^2 + 2*x*Dx, [0, 1], max_prec=20)
sage: f.approx(1/3, prec=10)
[0.32...]
sage: f.approx(1/3, prec=40)
[0.321750554396...]
sage: f.approx(1/3, prec=10, post_transform=Dx)
[0.9...]
sage: f.approx(1/3, prec=40, post_transform=Dx)
[0.900000000000...]
sage: f.approx(1/3, prec=10, post_transform=Dx^2)
[-0.54...]
sage: f.approx(1/3, prec=40, post_transform=Dx^2)
[-0.540000000000...]
plot(x_range, **options)

Plot this function.

The plot is intended to give an idea of the accuracy of the evaluations that led to it. However, it may not be a rigorous enclosure of the graph of the function.

EXAMPLES:

sage: from ore_algebra import *
sage: from ore_algebra.analytic.function import DFiniteFunction
sage: DiffOps, x, Dx = DifferentialOperators()

sage: f = DFiniteFunction(Dx^2 - x,
....:         [1/(gamma(2/3)*3^(2/3)), -1/(gamma(1/3)*3^(1/3))])
sage: plot(f, (-10, 5), color='black')
Graphics object consisting of 1 graphics primitive
plot_known()

TESTS:

sage: from ore_algebra import *
sage: from ore_algebra.analytic.function import DFiniteFunction
sage: DiffOps, x, Dx = DifferentialOperators()

sage: f = DFiniteFunction((x^2 + 1)*Dx^2 + 2*x*Dx, [0, 1])
sage: f(-10, 100) # long time
[-1.4711276743037345918528755717...]
sage: f.approx(5, post_transform=Dx) # long time
[0.038461538461538...]
sage: f.plot_known() # long time
Graphics object consisting of ... graphics primitives
class ore_algebra.analytic.function.RealPolApprox(pol, prec)
pol

Alias for field number 0

prec

Alias for field number 1