Go to the first, previous, next, last section, table of contents.

### `subst`, `psubst`

`subst(rat[,varn,ratn]*)`
`psubst(rat[,var,rat]*)`
  :: Substitute ratn for varn in expression rat. (n=1,2,.... Substitution will be done successively from left to right if arguments are repeated.)

return
  rational expression
rat,ratn
  rational expression
varn
  indeterminate

- Substitutes rational expressions for specified kernels in a rational expression.
- `subst`(rat,var1,rat1,var2,rat2,...) has the same effect as `subst`(`subst`(rat,var1,rat1),var2,rat2,...).
- Note that repeated substitution is done from left to right successively. You may get different result by changing the specification order.
- Ordinary `subst()` performs substitution at all levels of a scalar algebraic expression creeping into arguments of function forms recursively. Function `psubst()` regards such a function form as an independent indeterminate, and does not attempt to apply substitution to its arguments. (The name comes after Partial SUBSTitution.)
- Since Asir does not reduce common divisors of a rational expression automatically, substitution of a rational expression to an expression may cause unexpected increase of computation time. Thus, it is often necessary to write a special function to meet the individual problem so that the denominator and the numerator do not become too large.
- The same applies to substitution by rational numbers.

    [0] subst(x^3-3*y*x^2+3*y^2*x-y^3,y,2);
    x^3-6*x^2+12*x-8
    [1] subst(@@,x,-1);
    -27
    [2] subst(x^3-3*y*x^2+3*y^2*x-y^3,y,2,x,-1);
    -27
    [3] subst(x*y^3,x,y,y,x);
    x^4
    [4] subst(x*y^3,y,x,x,y);
    y^4
    [5] subst(x*y^3,x,t,y,x,t,y);
    y*x^3
    [6] subst(x*sin(x),x,t);
    sint(t)*t
    [7] psubst(x*sin(x),x,t);
    sin(x)*t

Go to the first, previous, next, last section, table of contents.