# subs: Substitution In freealg: The Free Algebra

## Description

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

## Usage

 ```1 2``` ```subs(S, ...) subsu(S1,S2,r) ```

## 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

## Details

Function `subs()` substitutes variables for `freealg` objects (coerced if necessary) using a natural R idiom. Observe that this type of substitution is sensitive to order:

 ```1 2 3 4 5 6 7``` ```> 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.

## Author(s)

Robin K. S. Hankin

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```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()) ```

freealg documentation built on Nov. 19, 2021, 9:07 a.m.