subs {freealg} | R Documentation |
Substitution
Description
Substitute symbols in a freealg
object for numbers or other
freealg
objects
Usage
subs(S, ...)
subsu(S1,S2,r)
Arguments
S , S1 , S2 |
Objects of class |
r |
Integer specifying symbol to substitute ( |
... |
named arguments corresponding to variables to substitute |
Details
Function subs()
substitutes variables for freealg
objects
(coerced if necessary) using natural R idiom. Observe that this type
of substitution is sensitive to order:
> subs("ax",a="1+x",x="1+a") free algebra element algebraically equal to + 2 + 3*a + 1*aa > subs("ax",x="1+a",a="1+x") free algebra element algebraically equal to + 2 + 3*x + 1*xx
Functions subsu()
is a lower-level formal function, not really
intended for the end-user. Function subsu()
takes S1
and
substitutes occurrences of symbol r
with S2
.
No equivalent to mvp::subvec()
is currently implemented.
Value
Returns a freealg
object.
Note
Function subs()
is one place in the package where the use of
letters
is effectively hard-wired in. Idiom such as
subs("abccc",b="1+3x")
is very nice, but identifies “b” with 2. Note that argument
r
of subsu()
is canonically an integer but a single
character is interpreted as a letter
. See also the note
at freealg.Rd
.
Author(s)
Robin K. S. Hankin
Examples
subs("abccc",b="1+3x")
subs("aaaa",a="1+x") # binomial
subs("abA",b=31)
subs("1+a",a="A") # can substitute for an inverse
subs("A",a="1+x") # inverses are not substituted for
## Sequential substitution works:
subs("abccc",b="1+3x",x="1+d+2e")
subs(rfalg(),a=rfalg())