Expand {lazy.symbolic} | R Documentation |
Expand Expressions by Distributing a Multiplicative Factor
Expand(expr, all = 0, method = 1:2, simplify = 1, verify = 1, debug = 0)
expr |
A vector or list of symbolic expressions |
all |
= 1 to apply Expand repeatedly |
method |
= 1 to expand a*(...) |
simplify |
= 0 to skip the simplification of the result |
verify |
= 0 not to check the result by |
debug |
= 1 to print intermediate result |
This function expands a single occurence of
a*(b+c)
and (a+b)*c
to
a*b+a*c
and a*c+b*c
, resp.,
where a
is a single multiplicative factor and
b
and c
are additive terms.
Matrix multiplications such as %*% and %@% can be used.
Repeated use may expand it further.
Expanded expression
Expand(c("a*(b+c)","-(b+c)*a"))
Expand(c("a/(b*c)","-(b*c)/a"))
Expand("(a+b)*(F(x)-G(y))")
Expand(.Last.value)
Expand("-a*(b-c)*(d+e)")
Expand(.Last.value)
Expand( "((+a*(b-c*d)*e+f)*g)*h - (((+a*b-c*d)*e+f)*g)*h" )
Expand(.Last.value)
Expand("-t(A)%*%(B-C)%*%D")
Expand("-inv(A)%*%(A-B)")
Expand("-inv(A)%*%(A-B)", simplify=0)
Expand("-(A-B)%*%(C-D)+E")
Expand("-(A-B)%*%(C-D)+E", all=1)