# Get the common denominator?

Posted 1 year ago
1658 Views
|
9 Replies
|
1 Total Likes
|
 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
9 Replies
Sort By:
Posted 1 year ago
 How about using Denominator to extract the denominators in each sublist,http://reference.wolfram.com/language/ref/Denominator.htmluse LCM to find the least common denominator,http://reference.wolfram.com/language/ref/LCM.htmland use it to convert the sublist elements to the same denominator?
Posted 1 year ago
 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
Posted 1 year ago
 Sry i didn't get it. Could you help me in more detail ? Thanks a lot Zharou Fisher
Posted 1 year ago
 Try: makeCommonDenominators /@ MyCoeffs 
Posted 1 year ago
 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 regardsZharou Fisher
Posted 1 year ago
 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 regardsZharou Fisher
Posted 1 year ago
 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 regardsZharou 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}}