Ticket #20812: functional.py.patch

File functional.py.patch, 871 bytes (added by dgulotta, 5 years ago)
  • sage/calculus/functional.py

    old new  
    3232
    3333from calculus import SR
    3434from sage.symbolic.expression import Expression
     35from sage.misc.derivative import derivative_parse
     36from sage.structure.element import get_coercion_model
    3537
    3638def simplify(f):
    3739    r"""
     
    130132        return f.derivative(*args, **kwds)
    131133    except AttributeError:
    132134        pass
     135    try:
     136        elts = [e for e in derivative_parse(args) if e is not None]
     137        elts.append(f)
     138        cm = get_coercion_model()
     139        return cm.common_parent(*elts)(f).derivative(*args, **kwds)
     140    except (AttributeError, TypeError):
     141        pass
    133142    if not isinstance(f, Expression):
    134143        f = SR(f)
    135144    return f.derivative(*args, **kwds)