Get the common denominator?

Hello everybody,

I need your help in doing the same Denominator.

My Input:

b[i_, s_] := 
 Integrate[
  Product[Piecewise[{{1, p == i}}, (p + \[Tau])/(p - i)], {p, 0, s}], {\[Tau], 0, 1}]
MyCoeffs = Table[b[i, s], {s, 0, 4}, {i, 0, s}]

My Output:

{{1}, {3/2, -(1/2)}, {23/12, -(4/3), 5/12}, {55/24, -(59/24), 37/24, -(3/8)}, {1901/720, -(1387/360), 109/30, -(637/360), 251/720}}

Now the Problem is that Mathematica don’t let it on the same Denominator. I want to have the same Denominator in each list.

In the end i want to have this

{{1},{3/2,-(1/2)},{23/12, -(16/12), 5/12}, {55/24, -(59/24), 37/24, -(9/24)}, {1901/720, -(2774/720), 2616/720, -(1274/720), 251/720}}

Thanks for your help 

Kind Regards

Zharou Fisher

How about using Denominator to extract the denominators in each sublist,

use LCM to find the least common denominator,

and use it to convert the sublist elements to the same denominator?

A little function to do this follows:

makeCommonDenominators[fractions_] := Module[{comden, numers},
  comden = LCM @@ Denominator /@ fractions;
  numers = fractions*comden;
  (HoldForm[#1/zzz] /. zzz -> comden) & /@ numers
  ]

To get the original reduced fractions back you can use

ReleaseHold /@ fractions

I hope this helps

Sry i didn’t get it.
Could you help me in more detail ?

Thanks a lot

Zharou Fisher

Try:

makeCommonDenominators /@ MyCoeffs

Thank you all for helping.

My Problem is solved. But i have a question what does this zzz mean. I didn’t get it.

Would be nice if anybody could explain it.

Kind regards

Zharou Fisher

Thank you all for helping.

My Problem is solved. But i have a question what does this zzz mean. I didn’t get it.

Would be nice if anybody could explain it.

Kind regards

Zharou Fisher

My Problem isn’t solved sry for that reply. i got an error.

I have a problem instead.

If i do

EndCoeffs = makeCommonDenominators /@ MyCoeffs

and i want the Denominator i do

Denominator[EndCoeffs]

but all i get is:

{{1},{1,1},{1,1,1},{1,1,1,1}}

I hope someone can help me.

Kind regards

Zharou Fisher

Initializations:

b[i_, s_] := 
Integrate[
Product[Piecewise[{{1, p == i}}, (p + \[Tau])/(p - i)], {p, 0, 
s}], {\[Tau], 0, 1}]
makeCommonDenominators[fractions_] := Module[{comden, numers},
comden = LCM @@ Denominator /@ fractions;
numers = fractions*comden;
(HoldForm[#1/zzz] /. zzz -> comden) & /@ numers]
myCoeffs = Table[b[i, s], {s, 0, 4}, {i, 0, s}];
makeCommonDenominators /@ myCoeffs;

and denominators:

In[12]:= Apply[LCM, Denominator /@ Release /@ myCoeffs, {1}]
Out[12]= {1, 2, 12, 24, 720}

What about the following code?

b[i_, s_] := 
 Integrate[
  Product[Piecewise[{{1, p == i}}, (p + \[Tau])/(p - i)], {p, 0, 
    s}], {\[Tau], 0, 1}]
myCoeffs = Table[b[i, s], {s, 0, 4}, {i, 0, s}];

f[l_] := Module[{lcm},
  lcm = LCM @@@ Denominator /@ l;
  l*lcm/Defer /@ lcm]

In[7]:= f[myCoeffs]

Out[7]= {{1/1}, {3/2, -(1/2)}, {23/12, -(16/12), 5/12}, {55/
  24, -(59/24), 37/24, -(9/24)}, {1901/720, -(2774/720), 2616/
  720, -(1274/720), 251/720}}