# Collecting Like Terms

Posted 10 years ago
2420 Views
|
|
1 Total Likes
|
 I have an expression of a single variable (x) and several constants and I would like to manipulate the expression so that it looks like the sum of unique functions of x.The initial expression is:(1/(2 \[Pi]))csc(Subscript[\[Delta], c]) (1/s^2sin(Subscript[\[Delta], c]) (erf(s (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t])))+1) exp(-s^2 (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t]))^2) ((s (2-Subscript[\[Sigma], N]) (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t])))/Sqrt[\[Pi]]+1/2 Subscript[\[Sigma], N] Sqrt[Subscript[T, W]/Subscript[T, \[Infinity]]]) ((2-Subscript[\[Sigma], N]) (s^2 (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t]))^2+1/2)+1/2 Sqrt[\[Pi]] s Subscript[\[Sigma], N] Sqrt[Subscript[T, W]/Subscript[T, \[Infinity]]] (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t])))+1/(Sqrt[\[Pi]] s)Subscript[\[Sigma], T] cos(Subscript[\[Delta], c]) (cos(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])-cos(x) sin(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t])) (Sqrt[\[Pi]] s (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t])) (erf(s (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t])))+1)+exp(-s^2 (sin(Subscript[\[Delta], c]) cos(Subscript[\[Alpha], t])+cos(x) cos(Subscript[\[Delta], c]) sin(Subscript[\[Alpha], t]))^2)))^^ This expression is the contents of the attached notebook.Ultimately, the integral of this expression in terms of x is a quantity I want to compute, so I want to rearrange this expression to be the sum of a sequence of constants of integration multiplied by unique functions of x. By unique functions, I mean that the functions are not just different by a constant multiple; they would be separate entries in an integral table. If I were to use the Expand command, this expression would have 66 terms in it, but there should be roughly 10-20 unique functions.In my previous experience with these sorts of equations (components of aerodynamic forces and moments in rarefied flows), I was able to get away with manually specifying what the unique functions of x were. I used the Expand command to look at all the terms, then wrapped it with the Collect command. The code line looked something like this:Collect[ Expand[ expr ], list_of_patterns ]I attempted to generalize this method with:Collect[ expr, _[x] ]but that collected the expression into only the powers of cos(x) and didn't understand that I wanted collect the terms that looked like cos(x)*erf( a+b cos(x) ).I tried looking through forum, etc online for similiar problems, but no luck. Any guidance on how to collect the unique functions of x for an expression such as the one above would be greatly appreciated.
Sort By:
Posted 10 years ago
 Cases may do what you want.https://reference.wolfram.com/mathematica/ref/Cases.html
Community posts can be styled and formatted using the Markdown syntax.