Hi,

On Mon, Jul 20, 2009 at 4:37 PM, Golam Mortuza
Hossain<gmhoss...@gmail.com> wrote:
> On Sun, Jul 19, 2009 at 3:11 PM, William Stein<wst...@gmail.com> wrote:
>> At first glance doing this sounds like a really good idea.  How hard
>> would it be for you to make a mock-up prototype of this to more
>> clearly demonstrate it?   I'm definitely not opposed.
>
> OK, here is a prototype implementation.
>
> This is based on the principle that we stop applying chain rule
> when we hit a symbolic function and whose derivative isn't defined
> in sage/pynac.
> Notes: This is not the fastest implementation but my current priority
> is to get my work done even if it takes bit longer rather than not
> able to do at all.


I am back again on this issue :-) I just completed a native c++
implementation of "diff" format derivative in pynac.

This is around 15 times faster than my original prototype implementation.
This is even faster than pynac D derivative. Here are the output
from my sage session:

------
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: 89.9 µs per loop
sage: timeit('f(x).diff(x,100)')
125 loops, best of 3: 2.68 ms per loop

sage: from sage.symbolic.pynac import set_diff_derivative_level
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: 83.9 µs per loop
sage: timeit('f(x).diff(x,100)')
625 loops, best of 3: 513 µs per loop
------

This implementation also supports applying chain-rule (where
 make sense) on-demand.
------
sage: g(x) = function('g',x)
sage: f(g(x)).diff(x)
diff(f(g(x)), x, 1)

sage: set_diff_derivative_level(2)
sage: f(g(x)).diff(x)
diff(f(g(x)), g(x), 1)*diff(g(x), x, 1)

sage: f(x+x^2).diff(x)
diff(f(x^2 + x), x, 1)
-------
This would be useful for example in computing symbolic
functional derivative.

BTW, what is the final decision on the default derivative format
in Sage?

Note: As you can see this implementation ensures both
formats can happily co-exist with each other and user
can switch between the different formats in run-time.

However, we need to make a decision on the default
format as symbolic integration algorithm would depend
on the derivative format.

Cheers,
Golam

--~--~---------~--~----~------------~-------~--~----~
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
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to