Computing Variational Derivatives
Allow me to start with a definition. Given a function $u = u(x)$, a function $L$ of $x, u$, and all derivatives of $u$; and
$I = \int L(x,u,u_x u_{xx}, \ldots)dx$
the variational derivative of $I$ is defined as
$\frac{\delta I}{\delta u} := \frac{\partial L}{\partial u} - \frac{d}{dx} \frac{\partial L}{\partial u_x} + \frac{d^2}{dx^2} \frac{\partial L}{\partial u_{xx}} - \cdots$
For example, with $L=u^3 + u_x^2/2$ we have $\frac{\delta I}{\delta u} = 3u^2 - u_{xx}$.
From my poking around I suspect that Sage doesn't have the option of computing the variational derivative of an integral operator. However, I'd like to write some code that does this. Does anyone have any suggestions on how to go about doing this?
One issue is that if you define a function
sage: u = function('u', x)
you can take derivatives of u
with respect to x
, of course, but not with respect to u
.
sage: u.derivative(u) # this should be equal to 1
Traceback (click to the left of this block for traceback)
...
TypeError: argument symb must be a symbol
sage: u_x = u.derivative(x)
sage: L = u_x^2/2
sage: L.derivative(u_x) # this should be equal to u_x
Traceback (click to the left of this block for traceback)
...
TypeError: argument symb must be a symbol
My thoughts include doing some string parsing so I can take the necessary derivatives with respect to $u,u_x,u_{xx},\ldots$ but that's starting to sound a bit messy. Any suggestions on how to cleanly go about doing this in Sage would be greatly appreciated!
I don't have any ideas, but it sounds interesting :)
Well, I have some ideas of my own on how to implement this but it involves string parsing which I don't consider an elegant approach. Just looking for some ideas. :)
I have no nice answers either, but support would definitely be worth adding. There are ways to hack around it in any given case, but they're not pretty. I think there was a related thread a while back: http://www.mail-archive.com/sage-devel@googlegroups.com/msg22657.html
Thanks for the reference. That conversation happened in 2009. I wonder what came of it...hrm.
I was also looking for a solution to this problem. I notice that there is a very old trac request http://trac.sagemath.org/sage_trac/ticket/6466 which has not been acted on in 19 months.