I would like to automatically extract the same factor of each term, and thus write a sum such as:
$$\frac{4 \sin (2 \pi x)}{\pi }+\frac{4 \sin (6 \pi x)}{3 \pi }+\frac{4 \sin (10 \pi x)}{5 \pi }+\frac{4 \sin (14 \pi x)}{7 \pi }$$
as
$$\frac{4}{\pi} \left( \sin(2 \pi x) + \frac{1}{3} \sin(6 \pi x) + \frac{1}{5} \sin (10 \pi x) + \frac{1}{7} \sin (14 \pi x)\right)$$
My goal is to have Mathematica find the factor (here $\frac{4}{\pi}$) automatically (not "by hand") and then perform the manipulations.
I've tried Factor
, DivideBy
, and several algebraic manipulation functions, but nothing works smoothly or fully automatically in such cases. Together
is almost appropriate, but not quite.
Here's code for the above:
(4 Sin[2 π x])/π + (4 Sin[
6 π x])/(3 π) + (4 Sin[10 π x])/(5 π) + (4 Sin[
14 π x])/(7 π) + (4 Sin[18 π x])/(9 π)
At @Nasser's request, here are a few similar made-up cases (in minimal form):
(5 E)/Sqrt[2] Cos[x] + (10 E)/(2 Sqrt[2]) Sin[2 x] + (15 E)/(3 Sqrt[2]) Cos[3 x] + (20 E)/(4 Sqrt[2]) Sin[4 x]
2/x Cos[x] + 4/x Exp[x] + 6/x Tan[x] + 8/x Cot[x]
5/Sqrt[3 x] Tan[x] + 10/Sqrt[3 x] Cot[x] + 15/Sqrt[3 x] Csc[x]
3/x Cos[x] + 6/x^2 Tan[x] + 9/x^2 Exp[x] + 12/x^3 Cot[x]
FullSimplify
? If that's not good enough, you can try to tweak theComplexityFunction
to favour smaller integers more strongly $\endgroup$