On Aug 25, 12:50 pm, "William Stein" <[EMAIL PROTECTED]> wrote: > 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> > > 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
Awesome. Thanks for making all this happen. I'm really excited about where Sage is going. I've only been watching for a couple weeks now, but I think I chose a fun time to find out about it. Is the syntax for this stuff set in stone? I'm not sure I like the equality inside the subs call. Equality is reflexive, but substitution is a one way operation. What about a dictionary, sage: (a +2*b).subs({a+b:x}), or even just a single equal sign, like keyword args, sage: (a+2*b).subs(a+b=x). The double equals would work too, but now is probably a better time for discussion than later. JM --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---