Group Abstract Group Abstract

Message Boards Message Boards

How to combine variables automatically?

Posted 12 years ago
POSTED BY: Aaron Clair
Posted 12 years ago

I'm not certain this will do everything you are hoping for, but perhaps it will help

In[1]:= 2 + x^2 - 4 y + C[1] + C[2] + C[3] /. C[1] + C[2] + C[3] -> C[4]

Out[1]= 2 + x^2 - 4 y + C[4]

In[2]:= 2 + x^2 - 4 y + C[1] + C[2] + C[3] + C[5] + C[8] /. Plus[C[__]] -> C[i]

Out[2]= 2 + x^2 - 4 y + 5 C[i]

where the 5 or the i in 5 C[ i ] has perhaps no great significance.

Be careful to check each time you do something like this. I was actually surprised when it worked on the first try.

POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard