That worked excelent! I made the following code:

from sage.symbolic.function import BuiltinFunction
class AiryAi(BuiltinFunction):
    def __init__(self):
        BuiltinFunction.__init__(self, "ai",
latex_name=r"\operatorname{Ai}")
    def _derivative_(self, x, diff_param=None): return aip(x)

class AiryAiPrime(BuiltinFunction):
    def __init__(self):
        BuiltinFunction.__init__(self, "aip",
latex_name=r"\operatorname{Ai}'")

class AiryBi(BuiltinFunction):
    def __init__(self):
        BuiltinFunction.__init__(self, "bi",
latex_name=r"\operatorname{Bi}")
    def _derivative_(self, x, diff_param=None): return bip(x)

class AiryBiPrime(BuiltinFunction):
    def __init__(self):
        BuiltinFunction.__init__(self, "bip",
latex_name=r"\operatorname{Bi}'")

ai=AiryAi()
bi=AiryBi()
aip=AiryAiPrime()
bip=AiryBiPrime()
ai(x)+bi(x)+aip(x)+bip(x)

And now stuff like
f=A1*ai(k*x)+B1*bi(k*x)
f
diff(f,x).subs(x=x0)

works exactly the way I wanted.

Thank you!

Oscar

On 6 feb, 14:32, kcrisman <[email protected]> wrote:
> > I can live with that, but I also need to be able to visualize in
> > typesetted form some complicated expressions involving the derivatives
> > of Airy functions, so I would very much prefer if diff(ai) would be
> > typesetted the same way as
>
> > aip=function('aip',x,latex_name='Ai\'')
>
> Airy functions are in 
> Maximahttp://maxima.sourceforge.net/docs/manual/en/maxima_15.html#Item_003a...
> and 
> mpmathhttp://docs.sympy.org/0.7.0/modules/mpmath/functions/bessel.html#airyai
> so we should be able to make them symbolic and evaluate them and get
> derivatives and related integrals nicely.
>
> Seehttp://hg.sagemath.org/sage-main/file/tip/sage/functions/trig.py#l305
> for a class definition you could mimic.  I don't think there is any
> other way to get custom derivatives, not on the fly, and not with
> 'function'.
>
> Though if there is, that would be very useful! It would be nice to
> have something like this work.
>
> sage: F = function('ai',x)
> sage: F
> ai(x)
> sage: G = function('aip',x)
> sage: G
> aip(x)
> sage: F._derivative = G
> ---------------------------------------------------------------------------
> AttributeError: 'sage.symbolic.expression.Expression' object attribute
> '_derivative' is read-only
> sage: F.__setattr__('_derivative',G)
> ---------------------------------------------------------------------------
> AttributeError: 'sage.symbolic.expression.Expression' object attribute
> '_derivative' is read-only
>
> - kcrisman

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to