Skip to content

Implement diff format symbolic derivative in new symbolics #6756

@golam-m-hossain

Description

@golam-m-hossain

Implement a diff format symbolic derivative in new symbolics as the second form of abstract derivative to be avialable in Sage. See this long thread

http://groups.google.com/group/sage-devel/browse_thread/thread/ff10f99729a74eea/73308bf626ae06b3

for rationale behind it.

Implementation:

Instructions for installing these patches (sage-4.1.1)

(1) Pynac patch
(a) Get the pynac spkg

http://sage.math.washington.edu/home/burcin/pynac/pynac-0.1.8.p2.spkg

(b) Apply the pynac patch implementing diff derivative from

http://www.math.unb.ca/~ghossain/diff-derivative-pynac.patch

(c) install the patched spkg in Sage.

OR if you are feeling lazy, you can directly install my patched copy of pynac from here

http://www.math.unb.ca/~ghossain/pynac-0.1.8.p2-with-diff.spkg

(2) Sage patch:

Apply the attached patch in Sage and build the changes ("sage -b").
If everything goes smoothly then you are ready for testing.

Testing:

Above, patches will provide two new user accessible functions
(a) set_diff_derivative_level

(b) symbolic_diff

Please see the docs for usage of these functions:

It would be good to thoroughly test the following features:

(1) Substitution of the function

(2) Derivative with or without chain rule

(3) Explicit evaluation of derivative even for some situation where chain rule has been applied and derivative is specified w.r.t. an expression

(4) Symbolic n-th derivative

(5) Typesetting

Please test diff implementation against some related bugs

#6376, #6523, #6480

as new diff implementation should avoid these.

Speed Test:

sage: f(x) = function('f',x);
sage: f(x).diff(x)
D[0](f)(x)
sage: timeit('f(x).diff(x)')
625 loops, best of 3: 124 µs per loop
sage: timeit('f(x).diff(x,100)')
125 loops, best of 3: 5.58 ms per loop

sage: set_diff_derivative_level(1)
sage: f(x).diff(x)
diff(f(x), x, 1)
sage: timeit('f(x).diff(x)')
625 loops, best of 3: 116 µs per loop
sage: timeit('f(x).diff(x,100)')
625 loops, best of 3: 1.01 ms per loop

sage: set_diff_derivative_level(2)
sage: f(x).diff(x)
diff(f(x), x, 1)
sage: timeit('f(x).diff(x)')
625 loops, best of 3: 130 µs per loop
sage: timeit('f(x).diff(x,100)')
125 loops, best of 3: 1.85 ms per loop

***** This patch removes old "dummy_diff" from
"calculus/calculus" as we now have a _real_ diff.

CC: @ncalexan @mwhansen @kcrisman

Component: symbolics

Author: Golam Mortuza Hossain

Reviewer: Nick Alexander

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions