On Mon, Aug 25, 2008 at 4:47 AM, Burcin Erocal <[EMAIL PROTECTED]> wrote: > > On Sun, 24 Aug 2008 15:55:25 -0700 (PDT) > Jason Merrill <[EMAIL PROTECTED]> wrote: > >> >> In hopes that it may be a useful reference during the current work on >> symbolics, I wrote a toy Mathematica program for transforming a single >> higher order ODE into a system of first order ODEs. Most of the free >> numerical differential equation solvers I've seen want input in the >> form y'[x] == f(y,x), so the purpose of a program like this is to take >> more general input and turn it into something suitable for those >> routines. > <snip> > > Thank you for taking the time to write this. It is very useful indeed. > > The interface to pynac (William's modified version of GiNaC) doesn't > support pattern matching yet, though it is not hard to add this. I'll > add this functionality and try to reproduce your example in Sage once I > finish reviewing the initial pynac interface patches (#3872).
Burcin -- I did actually mostly implement pattern matching in Pynac. Some examples: sage: var('x,y,z,a,b,c,d,e,f',ns=1); S = parent(x) (x, y, z, a, b, c, d, e, f) sage: w0 = S.wild(0); w1 = S.wild(1); w2 = S.wild(2) sage: ((x+y)^a).match((x+y)^a) True sage: ((x+y)^a).match((x+y)^b) False sage: (a^2 + b^2 + (x+y)^2).subs(w0^2 == w0^3) (x + y)^3 + a^3 + b^3 sage: (a^4 + b^4 + (x+y)^4).subs(w0^2 == w0^3) (x + y)^4 + a^4 + b^4 sage: (a^2 + b^4 + (x+y)^4).subs(w0^2 == w0^3) (x + y)^4 + a^3 + b^4 sage: ((a+b+c)^2).subs(a+b==x) (a + b + c)^2 sage: ((a+b+c)^2).subs(a+b+w0==x+w0) (c + x)^2 sage: (a+2*b).subs(a+b==x) a + 2*b sage: (a+2*b).subs(a+b+w0 == x+w0) a + 2*b sage: (a+2*b).subs(a+w0*b == x) x sage: (a+2*b).subs(a+b+w0*b == x+w0*b) a + 2*b sage: (4*x^3-2*x^2+5*x-1).subs(x==a) 4*a^3 - 2*a^2 + 5*a - 1 sage: (4*x^3-2*x^2+5*x-1).subs(x^w0==a^w0) 4*a^3 - 2*a^2 + 5*x - 1 sage: (4*x^3-2*x^2+5*x-1).subs(x^w0==a^(2*w0)).subs(x==a) 4*a^6 - 2*a^4 + 5*a - 1 sage: sin(1+sin(x)).subs(sin(w0)==cos(w0)) cos(cos(x) + 1) sage: (sin(x)^2 + cos(x)^2).subs(sin(w0)^2+cos(w0)^2==1) 1 sage: (1 + sin(x)^2 + cos(x)^2).subs(sin(w0)^2+cos(w0)^2==1) sin(x)^2 + cos(x)^2 + 1 sage: (17*x + sin(x)^2 + cos(x)^2).subs(w1 + sin(w0)^2+cos(w0)^2 == w1 + 1) 17*x + 1 sage: ((x-1)*(sin(x)^2 + cos(x)^2)^2).subs(sin(w0)^2+cos(w0)^2 == 1) x - 1 > > > Cheers, > > Burcin > > > > -- William Stein Associate Professor of Mathematics University of Washington http://wstein.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---