[Date Index] [Thread Index] [Author Index]
Re: Collecting like terms after TrigReduce
Use Collect expr = c1*Cos[w*t] + s1*Sin[2 w*t] + a1 + c2*Cos[2 w*t] + c3*Cos[w*t] + s2*Sin[w*t] + c4*Cos[w*t] + a2 + c4*Cos[2 w*t] + s3 Sin[2 w*t]; Collect[expr, DeleteCases[Variables[expr], _?AtomQ]] a1 + a2 + (c1 + c3 + c4)*Cos[t*w] + (c2 + c4)*Cos[2*t*w] + (s1 + s3)*Sin[2*t*w] + s2*Sin[t*w] Bob Hanlon ---- Geico Caveman <spammers-go-here at spam.invalid> wrote: ============= I have a large expression that is expressed (after TrigReduce) as a series of the form: c1*cos(wt) + s1*sin(2wt) + a1+c2*cos(2 wt) + c3* cos(wt) + s2*sin(wt) + c4*cos(wt) + a2+c4*cos(2wt) + s3 sin(2wt) (This is just an illustrative example. The precise number of terms is larger and the number of each kind, impossible to know ahead of the calculation.) Is there any way (for compactness reasons alone) to force Mathematica to put this in a standard form: (a1+a2) + (c1+c3) cos(wt) + (c2 + c4)cos (2wt) + s2 sin(wt) + (s1+s3) sin(2wt) ? Using Simplify is not an option since that gets rid of the higher harmonic terms (which I want).