Download REDUCE User`s Manual - REDUCE Computer Algebra System
Transcript
120
CHAPTER 10. SUBSTITUTION COMMANDS
sub({x=a+y,y=y+1},xˆ2+yˆ2) -> A
+ 2*A*Y + 2*Y
+ 2*Y + 1
+ 2*A*Y + 2*Y
+ 2*Y + 1
and with s := {x=a+y,y=y+1},
2
2
sub(s,xˆ2+yˆ2)
-> A
Note that the global assignments x:=a+y, etc., do not take place.
EXPRN1 can be any valid algebraic expression whose type is such that a substitution process is defined for it (e.g., scalar expressions, lists and matrices). An
error will occur if an expression of an invalid type for substitution occurs either in
EXPRN or EXPRN1.
The braces around the substitution list may also be omitted, as in:
2
10.2
2
sub(x=a+y,y=y+1,xˆ2+yˆ2)
-> A
+ 2*A*Y + 2*Y
+ 2*Y + 1
LET Rules
Unlike substitutions introduced via SUB, LET rules are global in scope and stay in
effect until replaced or CLEARed.
The simplest use of the LET statement is in the form
LET <substitution list>
where <substitution list> is a list of rules separated by commas, each of
the form:
<variable> = <expression>
or
<prefix operator>(<argument>,...,<argument>) = <expression>
or
<argument> <infix operator>,..., <argument> = <expression>
For example,
let {x => yˆ2,
h(u,v) => u - v,