If I want to replace, say, a with a1 + a2 in an expression, I can write

expr /. a -> a1 + a2

But what about the opposite?

In some cases it might just be a matter of inverting things, such as the following substitutions

$\qquad \phi=\varphi_{1}+\varphi_{2},\quad \delta=\varphi_{1}-\varphi_{2}$

which can be inverted by solving for $\varphi_1,\, \varphi_2$ and then just using /.

But what about something more complex like this:

Sin[a + c] + Sin[c](Cos[b + c]a + Sin[Cos[a + c] + a*b]) + Log[a + b + c]

Let's say that I want to replace every instance of the expression a + b + c with S, and leave unchanged all the other expressions in which a, b or c appear but not in the form a + b + c.

How should I do this?

  • $\begingroup$ See 3822 and links in Mr.Wizard's answer. Is that what you need? $\endgroup$ – Kuba Jan 29 '19 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.