Hello,

On Wed, Dec 9, 2009 at 12:44 PM, Nick Alexander <ncalexan...@gmail.com> wrote:
> Implementing a particular symbolic function is not outlandishly
> difficult, thanks to the tireless work of Burcin Erocal and Mike
> Hansen.  (Apologies to any contributers I have forgotten.)
>
> You need to subclass sage.symbolic.function.SFunction.  I don't see
> many examples, so here is a minimal one:
>
> from sage.symbolic.function import SFunction
> from sage.rings.all import RealField
>
> class bessel_J_class(SFunction):
>     def __init__(self, *args, **kwds):
>         kwds['nargs'] = 2
>         kwds['evalf_func'] = self._evalf_func_
>         SFunction.__init__(self, "bessel_J", *args, **kwds)
>
>     def _evalf_func_(self, *args, **kwds):
>         prec = kwds['prec']
>         vals = [ arg.n(prec) for arg in args ]
>         v = bessel_J(*vals)
>         return RealField(prec)(v)
>
> symbolic_bessel_J = bessel_J_class()
>
> Then the following works for me:
>
> sage: var('x')
> sage: plot(symbolic_bessel_J(0, x), (x, 0, 100))

Things have changed a tiny bit in Sage 4.3 which should make adding
these types of functions a bit easier.  See patch # 7490 for lots of
examples.

--Mike

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to