Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am not sure whether your overall goal is worth pursuing. From the surface, it looks like MyFunc is becoming a clone of sage.symbolic.expression.Expression. Additionally, Sage has a deprecation policy: old code must be supported for at least twelve months with deprecation warnings before Sage can break it. For most purposes, I suggest keeping Sage up to date and continually testing whether your code is using a deprecated interface.

Just for reference, your example can be done in Sage as follows:

Using a symbolic function:

sage: func(x) = function('func', x)
sage: func
x |--> func(x)
sage: func(3)
func(3)
sage: func.differentiate(x)
x |--> D[0](func)(x)
sage: func.differentiate(x)(3)
D[0](func)(3)

Using a concrete function:

sage: func(x) = sinh(x) * sqrt(x)
sage: func
x |--> sqrt(x)*sinh(x)
sage: func(3)
sqrt(3)*sinh(3)
sage: RR(func(3))
17.3514683581443
sage: func.differentiate(x)
x |--> sqrt(x)*cosh(x) + 1/2*sinh(x)/sqrt(x)
sage: RR(func.differentiate(x)(3))
20.3296134831414

As far as I know, the above functionality has been around for a while without any changes, so I would not be too concerned about the stability of Sage's interface.