I finally got back to looking at this thread. That does work, though it breaks calling plot3d with the following format:
max_symbolic=MaxSymbolic() f(x,y)=sqrt(max_symbolic(9-x^2-y^2,0)) plot3d(f(x,y),(x,-3,3),(y,-3,3)) However plot3d(f,(-3,3),(-3,3)) works fine. So it's a fine work around. Thanks, Matt On Sep 16, 9:34 am, Burcin Erocal <bur...@erocal.org> wrote: > Hi Matt, > > On Mon, 14 Sep 2009 05:02:54 -0700 (PDT) > > MattRissler<discn...@gmail.com> wrote: > > Is it possible to have max behave as you would expect with a symbolic > > expression, i.e. wait until you evaluate it or restrict the domain to > > check what is the maximum of the two or more values. > > Below is a quick implementation of a symbolic max function. It seems > to work here: > > sage: max_symbolic = MaxSymbolic() > sage: max_symbolic(5,0) > 5 > sage: max_symbolic(x,0) > max(x, 0) > sage: max_symbolic(x,0).subs(x=5) > 5 > > Is this at all useful? Note that trying to evaluate this many times > might be very very slow. > > Cheers, > Burcin > > ---- > > from sage.symbolic.function import SFunction > > class MaxSymbolic(SFunction): > def __init__(self): > SFunction.__init__(self, 'max', eval_func=self._eval_) > > def _eval_(*args): > largs = len(args) > if largs == 0: > raise TypeError, "expected one or more arguments" > if largs == 1: > return args[0] > > res = 0 > for x in args: > try: > if hasattr(x, 'pyobject'): > pyobj = x.pyobject() > else: > pyobj = x > except TypeError: > return None > res = max(pyobj, res) > > return res --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---