0
|
4821 Views
|
|
1 Total Likes
View groups...
Share
GROUPS:

# How to combine variables automatically?

Posted 10 years ago
 Here is my problem: I have several variables that I know are unknown and have arbitrary values. Let's call them C, C, and C. After doing some magic with Solve[ ... ] and Reduce[ ... ] and Simplify[ ... ], I get the expression: C+C+C Now, I know two things about these variables: they have arbitrary values, but each variable is an integer. So C spans Z, C spans Z, etc. Therefore, their sum spans Z. This is quite obvious. Mathematica gives me a conditional expression like ConditionalExpression[C+C+C,C is in Integers && C is in Integers && C is in Integers] Which is swell, but I know their sum is also an arbitrary integer. How would I tell Mathematica to replace C+C+C with C, C is in integers? Or to do this for arbitrary sums of unknowns, where the properties of the result are obvious but somewhat hard to read in their full form. Thanks!
 I'm not certain this will do everything you are hoping for, but perhaps it will help In:= 2 + x^2 - 4 y + C + C + C /. C + C + C -> C Out= 2 + x^2 - 4 y + C In:= 2 + x^2 - 4 y + C + C + C + C + C /. Plus[C[__]] -> C[i] Out= 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.