Hi, On Tue, Feb 24, 2009 at 08:50:46AM -0500, Jeremy Jay wrote:
Hmm I guess it makes sense in that regard, but it is certainly non-intuitive.
In every CAS I know of substitution (and pattern matching) operates on the internal representation of expressions, not on their mathematical meaning. For example, in M.........a (version 5.1): In[1]:= x^4 + 1/(16*y^4); In[2]:= InputForm[% /. a_^2 :> a] Out[3]//InputForm= x^4 + 1/(16*y^4) In[4]:= InputForm[x^4 + 1/(16*y^4) /. 1 -> q] Out[5]//InputForm= x^4 + 1/(16*y^4) Not quite intuitive, is it?
Printing the poly shows exactly what I want to replace and not the interal representation.
cout << tree << poly << endl; prints the internal representation.
Might I suggest someone update the tutorial with a statement like "Numeric literals are strongly discouraged in the left side of a substitution, and will not produce the desired effect."
That's kind of vague, because it's not quite clear what `desired effect' exactly is. Best regards, Alexei