# [Maxima] Simplification

Stavros Macrakis macrakis at alum.mit.edu
Mon Aug 2 09:34:31 CDT 2010

```Subst is strictly a *syntactic* substitution.  It does not 'know' that x^4 =
(x^2)^2 or that x+y+z = (x+y)+z = (x+z)+y = x+(y+z).

Thus, the second argument of subst must be a 'subtree' of the third argument
to match, and associative operators in Maxima are n-ary -- that is, x+y+z =
"+"(x,y,z). So subst(t,x+y,(x+y)*a) => t*a

ratsubst is a somewhat more 'semantic' substitution, at least for
polynomials.  Thus for example ratsubst(y,x^2-1,x^4-1) => y^2+2*y.

For your last case, try rootscontract.  Radcan tries to rewrite expressions
in a canonical form which in general exposes many separate roots, while
rootscontract combines roots.

-s

On Mon, Aug 2, 2010 at 10:13, mok-kong shen <mok-kong.shen at t-online.de>wrote:

>
> (1) subst(t,x+y,y+c+x) gives y+x+c, not t+c. On the
> other hand, subst(u,x+y,y+x) does give u.
>
> (2) subst(x,y^2,y^4+y^2) gives y^4+x instead of x^2+x.
>
> sqrt(y^4+y^2+1) a correct but complicated expression
> -%i*sqrt(-y^2+y-1)*sqrt(y^2+y+1).
>
> How could I get the desired form of the results?
>
> Thanks in advance.
>
> M. K. Shen
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20100802/a002acf0/attachment.html>
```