On Tue, 8 Dec 2009 21:57:30 -0800
Robert Bradshaw <rober...@math.washington.edu> wrote:

<snip>
> > On Wed, Dec 9, 2009 at 12:44 PM, Nick Alexander  
> > <ncalexan...@gmail.com> wrote:
<snip>
> >> 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))

This is also #1158 on trac:

http://trac.sagemath.org/sage_trac/ticket/1158

<snip>
> Any thoughts on making a symbolic decorator, so one could do
> something like
> 
> @sage.symbolic.function.symbolic
> def my_func(x, n):
>      if x < 0: return 0
>      else: return exp(-1/x^n)
> 
> ?

Great idea! I opened a ticket:

http://trac.sagemath.org/sage_trac/ticket/7636

I'll implement this first chance I get.


Cheers,
Burcin

-- 
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