Learn R Programming

freealg (version 1.1-8)

subs: Substitution

Description

Substitute symbols in a freealg object for numbers or other freealg objects

Usage

subs(S, ...)
subsu(S1,S2,r)

Value

Returns a freealg object.

Arguments

S,S1,S2

Objects of class freealg

r

Integer specifying symbol to substitute (\(a=1,b=2\) etc)

...

named arguments corresponding to variables to substitute

Author

Robin K. S. Hankin

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.

Examples

Run this code
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())

Run the code above in your browser using DataLab