Student Support Forum: 'a*sin(x)+b*cos(x)' topicStudent Support Forum > General > "a*sin(x)+b*cos(x)"

 < Previous Comment Help | Reply To Comment | Reply To Topic
 Author Comment/Response Bill Simpson 10/11/12 02:15am Mathematica usually uses LeafCount to decide which of two alternatives is "simpler", smaller count means simpler. In[1]:= LeafCount[a*Sin[x]+b*Cos[x]] Out[1]= 9 In[2]:= LeafCount[Sqrt[a*b]*Sin[x+c]] Out[2]= 12 So Mathematica thinks your preferred form is more complicated. That means something more than Simplify will be needed. Here is one method you might use In[3]:= a*Sin[x]+b*Cos[x]/.a_*Sin[x_]+b_*Cos[x_]->Sqrt[a*b]*Sin[x+c] Out[3]= Sqrt[a*b]*Sin[c + x] This even works when you do not literally have a,b,x, but the same variable or constant must appear on both your x positions. In[4]:= 7*Sin[q]+3*Cos[q]/.a_*Sin[x_]+b_*Cos[x_]->Sqrt[a*b]*Sin[x+c] Out[4]= Sqrt[21]*Sin[c + q] You might want to enhance this by using the appropriate expression for c as a function of a and b. URL: ,

 Subject (listing for 'a*sin(x)+b*cos(x)') Author Date Posted a*sin(x)+b*cos(x) Qi Tang 10/10/12 11:52am Re: a*sin(x)+b*cos(x) Bill Simpson 10/11/12 02:15am
 < Previous Comment Help | Reply To Comment | Reply To Topic