Search code examples
mathwolfram-mathematicaequationalgebrasimplify

How to simplify or rearrange an equation to a specific form in mathematica


I have an equation:

Y[u_, v_, w_]:=(sin[u] + v*cos[u]*sin[u - w] - v*sin[w]) 

Which needs to be expressed in a specific form:

Y[u_, v_, w_]:=(a*sin[u] + b*sin[2*u] + c*cos[2*u] + d*v*sin[w])

From doing this by hand, I happen to know that:

a=1
b=(v*cos[w]/2)
c=-(v*sin[w]/2)
d=-(3/2)

This particular example is easy to do by hand with trig identities, but for more complicated equations, mathematica could be very useful if the final form of the equation is known. Is there some specific solver function, or a way to use Solve to do this?

For my particular application with a more complicated equation, I have found a few coefficients of the final form by hand, but others are very long and I would like to use mathematica to both check, and finish the rearrangement.


Solution

  • Trying to get Mathematica to put an expression into exactly the form you want is often very difficult to do.

    You might consider this method of checking your calculations

    In[1]:= expr = (Sin[u] + v*Cos[u]*Sin[u - w] - v*Sin[w]);
      { Integrate[expr*Sin[u], {u, 0, 2 Pi}]/Pi,
        Integrate[expr*Sin[2*u], {u, 0, 2 Pi}]/Pi,
        Integrate[expr*Cos[2*u], {u, 0, 2 Pi}]/Pi,
        Integrate[expr*v*Sin[w], {w, 0, 2 Pi}]/Pi}
    
    Out[1]= {1, 1/2 v Cos[w], -(1/2) v Sin[w], -v^2 (1 + Cos[u]^2)}
    

    What that is doing is the equivalent of finding the Fourier transform of your expression for a single frequency u, or w in the case of d. In your example it correctly finds the values of a, b and c, but fails in finding d. Unfortunately I can't see at the moment exactly why it is failing for d, but perhaps someone with a clear head can point out what the error is.

    Be careful with this, as you see, don't just assume the result will always be correct. I am worried for your much more complicated actual problem this may not give you what you are looking for.