Look at what ratsubst will do in Maxima. If you think you have a well-defined operation in mind, what does it do with substituting 1 for s^2+c^2 in the expression s^4+3*s^2*c^2+ c^4?
RJF On Sep 29, 7:38 am, Jean-Pierre Flori <jpfl...@gmail.com> wrote: > Sage has the following behavior inherited from GiNaC > (http://www.ginac.de/tutorial/Pattern-matching-and-advanced-substitutions.html) > : > > ---------------------------------------------------------------------- > | Sage Version 4.5.3, Release Date: 2010-09-04 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > sage: x,y,z = var('x,y,z') > sage: P = x+y > sage: P.subs({x+y:z}) > z > sage: P = x+y+z > sage: P.subs({x+y:z}) > x + y + z > sage: w0 = SR.wild(0) > sage: P.subs({x+y+w0:z+w0}) > 2*z > sage: P = x+y > sage: P.subs({x+y+w0:z+w0}) > z > sage: > > Of course the same thing is happening with mul objects. > I think this is somewhat misleading and should at least be explained > in the documentation. > The above url is already give in the documentation of the match > function but not in the one of subs. > Maybe this explains the warning in the documentation of the subs_expr > function. > However that warning refers to Maxima whereas : > > sage: get_systems('P.subs_expr({x+y+w0:z+w0})') > ['ginac'] > > The weird example can also be solved using a wildcard : > > sage: t = var('t') > sage: f(x,y,t) = cos(x) + sin(y) + x^2 + y^2 + t > sage: f > (x, y, t) |--> x^2 + y^2 + t + sin(y) + cos(x) > sage: f.subs_expr(x^2 + y^2 == t) > (x, y, t) |--> x^2 + y^2 + t + sin(y) + cos(x) > sage: f.subs_expr(x^2 + y^2 + w0 == t + w0) > (x, y, t) |--> 2*t + sin(y) + cos(x) > > I don't know if such a trick should be implemented in Sage, pynac, or > even in GiNaC. > At least, it should be documented. > > Best regards, -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org