2
$\begingroup$

Consider the expression $$ a\sin(x)-a\sin\left(\frac{x}{a}\left(a+\frac{ay}{x}\right)\right) \label{a}\tag{1} $$ which can be rewritten as $$ \sin(x)-\sin\left(x+y\right) \label{b} \tag{2} $$ and finally as $$ -2 \sin(y/2) \cos(x+y/2) \label{c} \tag{3} $$ I have a more complicated expression, where an expression such as (\ref{a}) is embedded. I want Mathematica to apply the transformation "(\ref{b}) -> (\ref{c})" to this expression, without any further simplifications. Note that the variable names may differ and I want to inform Mathematica about "(\ref{b}) -> (\ref{c})" in the general most way. That is for example, without the prefactor $a$ in (\ref{a}) or without giving the explicit structure of the parentheses in the $\sin$ on the right hand side of (\ref{a}).

$\endgroup$
4
$\begingroup$
a Sin[x] - a Sin[x/a (a + a y/x)] // FullSimplify // TrigFactor

It works also as

g[a Sin[x] - a Sin[x/a (a + a y/x)]] /. g[a_] :> g[TrigFactor[FullSimplify[a]]]
| improve this answer | |
$\endgroup$
  • $\begingroup$ Unfortunately, that does not work if the difference of the sines is wrapped inside Exp. $\endgroup$ – HerpDerpington Mar 16 at 17:40
  • $\begingroup$ Or basically, the expression to simplify is wrapped in any other expression. $\endgroup$ – HerpDerpington Mar 16 at 18:44
  • 1
    $\begingroup$ Please. See the example attached. $\endgroup$ – Cesareo Mar 16 at 18:47
  • $\begingroup$ If g is Exp I have to explicitly use Exp on the right hand side of /., otherwise this still does not work. Furthermore, if there are other things wrapped around the Sines this still does not work, e.g.: Exp[t + a Sin[x] - a Sin[x/a (a + a y/x)]] /. Exp[x_] :> Exp[TrigFactor[ExpandAll[x]]]. I guess that's because the sines are wrapped in something because of the +. $\endgroup$ – HerpDerpington Mar 16 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.