Would it be possible, using this, to define a symbolic Sum ? Something
like Sum(Set([1,2,3,4,5,6]))...This would be extremely useful in
LP !!!

Nathann

On Dec 9, 12:48 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> Nick Alexander 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))
>
> Is there any difference between declaring the class above and doing the
> following?
>
> symbolic_bessel_J=function('symbolic_bessel_J',nargs=2,evalf_func=bessel_J)
>
> This thread also might be useful to understand evalf:
>
> http://groups.google.com/group/sage-devel/browse_frm/thread/983cd9ca5...
>
> Thanks,
>
> Jason
>
> --
> Jason Grout

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