Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return unevaluated derivative from BuiltinFunction #15021

Open
eviatarbach opened this issue Aug 7, 2013 · 2 comments
Open

Return unevaluated derivative from BuiltinFunction #15021

eviatarbach opened this issue Aug 7, 2013 · 2 comments

Comments

@eviatarbach
Copy link
Contributor

There should be a way to return an unevaluated derivative from within the _derivative_ or _tderivative_ method of a BuiltinFunction. Perhaps by returning None, like _eval_ does for remaining unevaluated. As of now returning None causes a segmentation fault.

This is important because for multivariate functions often only the derivative with respect to one variable may be known, so we want to return the unevaluated derivative if it's taken with respect to a variable in which we don't know the derivative. Right now it seems the only way to not return an evaluated derivative is to raise an exception.

CC: @burcin

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/15021

@eviatarbach eviatarbach added this to the sage-6.1 milestone Aug 7, 2013
@eviatarbach

This comment has been minimized.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@rwst rwst changed the title Return unevaluated derivative Return unevaluated derivative from BuiltinFunction Jan 31, 2015
@nbruin
Copy link
Contributor

nbruin commented Jan 31, 2015

comment:6

This issue was discussed before. We have the functionality in FDerivativeOperator, it's just not available on top level or as a method on BuiltinFunction instances:

http://permalink.gmane.org/gmane.comp.mathematics.sage.devel/58041

I thought this stuff was on trac somewhere already, but I cannot find it presently. For archival purposes:

from sage.symbolic.operators import FDerivativeOperator
class Doperator:
    def __init__(self,vars=None):
        self.vars= [] if vars is None else vars

    def __call__(self,f):
        return FDerivativeOperator(f,self.vars)

    def __getitem__(self,i):
        if isinstance(i,tuple):
            newvars=self.vars+list(i)
        else:
            newvars=self.vars+[i]
        return Doperator(newvars)

D=Doperator()

With that code one can input the form that sage prints:

sage: var('x,y')
sage: D[0](f)(x, y)/x + D[0, 1](f)(x, y)
D[0](f)(x, y)/x + D[0, 1](f)(x, y)

Input will never be in Leibnitz notation, since unevaluated functions do not have names for their parameters, just position numbers for them.

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants