RE: COLLECT and application of various commands to each coefficient
- To: mathgroup at smc.vnet.net
- Subject: [mg21247] RE: [mg21135] COLLECT and application of various commands to each coefficient
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Mon, 20 Dec 1999 02:28:07 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Blimbaum Jerry wrote: ------------------------------- I want to simplify a long expression using the Collect command. I notice that it allows you to apply a command to each of the coefficients, e.g. Collect[expr,{Cos[x],Sin[x]},Simplify] But Simplify here applies to both coefficients. What if I want to do different things with each coefficient, e.g. Collect[expr,{Cos[x],Sin[x]},{Collect coefficient of Cos[x] in terms of x^2,Simplify Coefficients of Sin[x]]}] Can this be done within the Collect command? ------------------------------- REPLY: The line below should help a lot. Notice I use (lhs:>rhs) instead of (lhs->rhs). If (lhs->rhs) is used any value assigned to (c1) is used in Simplify[c1]. For more on this subject down load the files at: http://www.mathsource.com/cgi-bin/msitem?0210-609 In[12]:= Collect[expr,{Cos[x],Sin[x]}]/.(c1_ Sin[x]:>Simplify[c1]Sin[x]) --------------------------------- Regards, Ted Ersek For Mathematica tips, tricks see http://www.dot.net.au/~elisha/ersek/Tricks.html