On Mon, Aug 25, 2008 at 9:59 PM, Tim Lahey <[EMAIL PROTECTED]> wrote:
>
> On Aug 26, 2008, at 12:37 AM, William Stein wrote:
>
>> Well I really hope that you implement a bunch of stuff for inclusion in
>> Sage!
>> So far we have very very very few developers working on symbolic
>> differential equations stuff in Sage.  (I.e., none, as far as I know.)
>
> Besides the code I already posted, I have written other variational calculus
> code. However, I need to work with things on a term-by-term basis so I need
> access to the expression tree which I couldn't find out how to work with
> based upon the Sage documentation (e.g., commands like Maple's op allow one
> to
> pull apart the symbolic expression term by term).

Yep, it's not there in the current system.

> Plus, based upon how integration and differentiation is currently
> implemented (as I understand it), I'd have to drop into Maxima to do
> that manipulation.

Yep, which you shouldn't have to do.

>
> That Euler-Lagrange code is simple example. It consists basically
> of:
>
> 1) Replacing all functions specified with placeholder symbols.
> 2) Differentiation with respect to those symbols.
> 3) Reversing the replacement.
> 4) Differentiation of one expression with respect to time.
>
> Since you don't know the number of functions in advance, you
> need to programmatically create the replacement list and reverse
> subs list. Both Maple and Maxima can do it fairly simply. Based upon
> how Sage works, I'm not exactly clear on how to do step 1 which is
> this Maple code:
>
>        # create a list of indices from 1 to the number of variables
>        # used in the formulation
>        num_list := [seq(i,i=1..nops(variables))]:
>
>        # Define a list of generalized velocity and position variables
>        qv_name := map2(cat,qv,num_list):
>        q_name := map2(cat,q,num_list):
>
>        # Equate the time derivatives of the system variable to the
>        # generalized velocities and also define the reverse mapping
>        vel_var := map(diff,variables,t):
>        qv_subs := zip(equate,vel_var,qv_name):
>        qv_unsubs := zip(equate,qv_name,vel_var):
>
>        # Equate the generalized positions to the system variables
>        # and define the reverse mapping
>        q_subs := zip(equate,variables,q_name):
>        q_unsubs := zip(equate,q_name,variables):
>
> Can I programmatically create a symbolic variable name and use
> that to replace a symbolic function name? If it's possible, I probably
> can code the rest in Sage fairly quickly. Then, I'll just be waiting
> on some of the expression manipulation tools.

Sounds good.  Unfortunately I don't understand precisely what
you're asking for.  Do you want to do this?

sage: x = var('x', ns=1)
sage: from sage.symbolic.function import function
sage: foo = function('foo',1)
sage: expr = foo(x)^2 + foo(x)-1
sage: expr
foo(x) + foo(x)^2 - 1
sage: y = var('y')
sage: expr.subs(foo(x)==y)
y^2 + y - 1

This *already* works in the new pynac symbolics.  I just typed it in.

Of course, I'm skipping the "programatically" part...

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to