9.1.16 Substituting a subexpression by another expression
The
algsubs
command replaces subexpressions of an expression, rather than just replace variables.
algsubs
takes two arguments:
expr
1
=
expr
2
, an equation between two expressions.
expr
, another expression.
algsubs(
expr
1
=
expr
2
,
expr
)
returns the last expression
expr
with
expr
1
replaced by
expr
2
.
Examples
algsubs
(
x
^2=
u
,1+
x
^2+
x
^4)
u
2
+
u
+1
algsubs
(
a
*
b
/
c
=
d
,2*
a
*
b
^2/
c
)
2*
b
*
d
algsubs
(2
a
=
p
^2-
q
^2,
algsubs
(2
c
=
p
^2+
q
^2,
c
^2-
a
^2))
p
2
q
2