On Tue, 22 Nov 2011 09:41:56 -0800 (PST)
kcrisman <kcris...@gmail.com> wrote:

> 
> > > I don't think it exists,  The symbolic functionality in Sage is
> > > supposed to make it "easy" for users to define a new symbolic
> > > function at runtime, including how that function gets simplified.
> > >  This is supposed to not involve any C++ coding with Pynac.   So
> > > it _should_ be easy to add what you suggest.  Maybe Burcin can
> > > pipe up.
> >
> > Here is a symbolic function which wraps RR.nth_root():
> >
> > from sage.symbolic.function import BuiltinFunction, is_inexact
> > from sage.symbolic.expression import Expression
> > from sage.structure.coerce import parent
> >
> > class RealNthRoot(BuiltinFunction):
> >     def __init__(self):
> >         BuiltinFunction.__init__(self, "real_nth_root", nargs=2)
> >
> >     def _eval_(self, base, exp):
> >         if (not isinstance(base, Expression) and is_inexact(base))
> > or \ (not isinstance(exp, Expression) and is_inexact(exp)):
> >             self._evalf_(base, exp, parent=parent(base))
> >
> >     def _evalf_(self, base, exp, parent=None):
> >         if isinstance(base, float):
> >             return RR(base).nth_root(exp)
> >         try:
> >             return base.nth_root(exp)
> >         except AttributeError:
> >             return base**(1/exp)
> >         return parent(base)**parent(exp)
> >
> > The code is also here:
> >
> > http://sage.math.washington.edu/home/burcin/real_nth_root.py
> >
> > I can plot this without trouble:
> >
> > sage: attach real_nth_root.py
> > sage: real_nth_root = RealNthRoot()
> > sage: v = real_nth_root(x, 3)
> > sage: plot(v, (x, -1, 1))
> > <firefox displays the plot>
> 
> Maybe this would be the best solution.  If you put this on a ticket
> with patch I'll try to make sure this gets reviewed properly at Sage
> Days 35.5.

Thanks! I attached a patch to #12074. Still needs documentation and
tests.

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


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