Skip to main content
added 36 characters in body
Source Link
Nasser
  • 150.4k
  • 12
  • 161
  • 374

Unfortunately LCM does not work with Pi in there (it only works on rational numbers). So had to remove it temporarily to apply LCM then put it back in.

So this is not very general as it assumes Pi is there. I am sure there will be better and more general method. But this is what came to mind at this moment.

expr = 4/Pi*Sin[2*Pi*x] + 4/(3*Pi)*Sin[6*Pi*x] + 4/(5*Pi)*Sin[10*Pi*x] + 4/(7*Pi)*Sin[14*Pi*x]
res = Cases[List @@ expr, any_*Sin[_] -> any*Pi];
leastCommonMultipler = LCM[Sequence @@ res];
leastCommonMultipler/Pi*(Simplify[expr /. any_ -> Pi/leastCommonMultipler*any])

Mathematica graphics

Unfortunately LCM does not work with Pi in there. So had to remove it temporarily to apply LCM then put it back in.

So this is not very general as it assumes Pi is there. I am sure there will be better and more general method. But this is what came to mind at this moment.

expr = 4/Pi*Sin[2*Pi*x] + 4/(3*Pi)*Sin[6*Pi*x] + 4/(5*Pi)*Sin[10*Pi*x] + 4/(7*Pi)*Sin[14*Pi*x]
res = Cases[List @@ expr, any_*Sin[_] -> any*Pi];
leastCommonMultipler = LCM[Sequence @@ res];
leastCommonMultipler/Pi*(Simplify[expr /. any_ -> Pi/leastCommonMultipler*any])

Mathematica graphics

Unfortunately LCM does not work with Pi in there (it only works on rational numbers). So had to remove it temporarily to apply LCM then put it back in.

So this is not very general as it assumes Pi is there. I am sure there will be better and more general method. But this is what came to mind at this moment.

expr = 4/Pi*Sin[2*Pi*x] + 4/(3*Pi)*Sin[6*Pi*x] + 4/(5*Pi)*Sin[10*Pi*x] + 4/(7*Pi)*Sin[14*Pi*x]
res = Cases[List @@ expr, any_*Sin[_] -> any*Pi];
leastCommonMultipler = LCM[Sequence @@ res];
leastCommonMultipler/Pi*(Simplify[expr /. any_ -> Pi/leastCommonMultipler*any])

Mathematica graphics

Source Link
Nasser
  • 150.4k
  • 12
  • 161
  • 374

Unfortunately LCM does not work with Pi in there. So had to remove it temporarily to apply LCM then put it back in.

So this is not very general as it assumes Pi is there. I am sure there will be better and more general method. But this is what came to mind at this moment.

expr = 4/Pi*Sin[2*Pi*x] + 4/(3*Pi)*Sin[6*Pi*x] + 4/(5*Pi)*Sin[10*Pi*x] + 4/(7*Pi)*Sin[14*Pi*x]
res = Cases[List @@ expr, any_*Sin[_] -> any*Pi];
leastCommonMultipler = LCM[Sequence @@ res];
leastCommonMultipler/Pi*(Simplify[expr /. any_ -> Pi/leastCommonMultipler*any])

Mathematica graphics