Hi,
On Sun, Apr 26, 2009 at 7:43 PM, Tim Lahey <[email protected]> wrote:
> I do it from a mathematical perspective. The code to do the variation
> itself is....
Thanks Tim. I played around further with current Sage to see what
stuffs need to be improved in implementing functional derivative in Sage.
I followed the mathematical definition that you did in maple. In Physics,
one takes the test-function to be Dirac delta (that's the only difference).
I tried with the following simple implementation
-------------------------
def fdiff(L, q):
"""
Functional Derivative
"""
var('epsilon');
f(t) = function('dirac_delta',t) # Test function
return diff(L.substitute(q=q+epsilon*f(t)), epsilon).substitute(epsilon=0)
# Example usage:
# Time and Position
var('t'); q(t) = function('q',t)
# Lagrangian for Simple Pendulum
L = (diff(q(t),t))^2/2 - q(t)^2/2
# Action
S = integrate(L, t)
# Euler-Lagrange equation directly follows from variation of action
fdiff(S,q)
--------------------------
In fact, above 'works' in current sage but only after misusing
current "substitute" method.
To implement proper functional derivative in current Sage,
following stuffs need some work
(1) Improved "substitute()":
Currently, "substitute" works, if keyword is a symbolic variable.
It doesn't seem to work when keyword is a symbolic function. Does
anyone know whether there are other ways in Sage to substitute
a symbolic function by a symbolic expression?
(2) dirac_delta(x):
I am planning to use Sage to compute Poisson brackets where
I need functional derivative (with Dirac delta as test-function).
Maxima seems to have implemented Dirac delta (for Laplace
transform). Does anyone working in implementing Dirac delta
in Sage? (or in pynac?)
I am planning to start working on the above two. However, I
will prefer to avoid any effort duplication.
Thanks,
Golam
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---