I've got an expression like
expr = (1-x)(a+b)
that I would like to distribute / expand while keeping factors of (1-x)
intact, i.e. the result should in the above example should look like
(1-x)a + (1-x)b
I know that for the explicit example given here, Expand[expr,(a+b)]
would yield the desired result. However, I would need a solution where (a+b)
can be any arbitrary algebraic expressions that is distributed with (1-x)
being left untouched.
Is there maybe a way to define a pattern that matches my (1-x)
terms that I can than hold while distributing?
HoldForm[1-x](a+b) // Expand
? $\endgroup$(1-x)
? $\endgroup$HoldForm[]
. And while you're at it,Defer[]
too. $\endgroup$