MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Taking LCM in a polynomial expression

  • To: mathgroup at
  • Subject: [mg95354] Re: Taking LCM in a polynomial expression
  • From: dh <dh at>
  • Date: Fri, 16 Jan 2009 06:10:14 -0500 (EST)
  • References: <gkn5pa$iob$>

Hi Srikanth,

the magic word to get a common denominator is: Together. E.g.:

Together[num1/den1 + num2/den1]

The second question is tougher. Mathematica orders increasingly by 

default. You therefore have to prevent this by e.g. HoldForm. Try:

a2 x^2 + a1 x + a0


HoldForm[a2 x^2 + a1 x + a0]

Next question is how to get the polynomial inside HoldForm. Assume

p=a0 + a1 x + a2 x^2

a polynomial in default ordering. We may get its coefficients with 

CoefficientList. The function Reverse reverses the coefficients list

cof=Reverse@CoefficientList[p, x]

the powers of x in our ordering:

pow=Table[x^i, {i, 2, 0, -1}]

The polynomial term in a list:

pol= cof pow

Now we insert pol into HoldForm by substitution and change List into Plus:

HoldForm[dummy]/.dummy->pol /. List->Plus

All together:

p=a0 + a1 x + a2 x^2;

cof=Reverse@CoefficientList[p, x];

pow=Table[x^i, {i, 2, 0, -1}];

pol= cof pow;

HoldForm[dummy]/.dummy->pol /. List->Plus

this gives:

a2 x^2+a1 x+a0

hope this helps, Daniel

Srikanth wrote:

> Hi

> I have a symbolic matrix that I invert. When I take each individual

> entry of the resulting matrix, I get an expression of the form:

> num1/den1 + num2/den1 + .... + num_n/den1

> where den1 is the determinant of the matrix. I'd like to get an

> expression of the form:

> Num/Den.


> I tried using Simplify (as well as multiplying the matrix by its

> determinant), but it doesn't seem to help. Any suggestions?


> On a related note, the final Num is a polynomial in two variables -

> say x,y. I'd like to arrange it in decreasing powers of x - like f1(y)

> x^n + f2(y) x^n-1... + constant. What function should use? Is there

> any way to both in a single step?


> Thanks a lot

> Srikanth


  • Prev by Date: Re: Problem in generating a DO cycle (mathematica 6.0)
  • Next by Date: HowTo: Lookup Special Character names
  • Previous by thread: Re: Taking LCM in a polynomial expression
  • Next by thread: Taking LCM in a polynomial expression