I occasionally use e.g. expr := 1+a^2; eval( expr, 2=-1 ); to convert expr to 1+1/a. I realised recently that this can be dangerous: expr2 := 1+x+3*y; eval(expr2, 1=2); produces (rather suprisingly) 4+2x+3y. Investigating, pulling apart expr2 with op reveals the structure as being a sum of 3 terms, the last being a product. "ToInert" shows essentially the same. "dismantle" however shows expr 2 as being a single sum of the form 1.1 + 1.x + 3.y. So it is essentially the dismantle version that eval searches and replaces all the 1's by 2's. My question is whether there is some good reason for this. It would seem to me (without knowing much about the theory of computer algebra) that eval (and subs) should work on the operands as revealed by op or ToInert. Certainly it would lead to more logical results in cases like my example. I realise btw that the desired effect can be obtained by using ToInert, then subs then FromInert. Is there though a single command that does this? I'd be grateful for any insight as to why these things are as they are. Toby

Please Wait...