3

If I have expression like

a1/x +a2/x^2 + a3/x^3 

I want to return 1/x^3. In general case,

a1/x +a2/x^2 + a3/x^3 + a4/x^4 .....

I will have 1/x^n

Edit:

If I want to print the parameter together, what do I need to do? like an/x^n?

Saesun Kim
  • 1,810
  • 13
  • 24
  • 1
    have you looked at documentation for Exponent? It seems you can get what you want using the code below or a variant thereof (depending on how you want to handle coefficients). `In[1901]:= x^Exponent[a/x + b/x^2 + c/x^3, x, Min]

    Out[1901]= 1/x^3`

    – Daniel Lichtblau Apr 07 '16 at 15:08

2 Answers2

5
exp=a1/x + a2/x^2 + a3/x^3;   
v=Min@Cases[exp, Power[_, x_?NumberQ] :> x, -1];
Cases[exp, Times[x_, Power[_, v]], -1]
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78
5

You can get all the informations you want in a list, Then to pick the min. It will be the first. The largest is at the end.

expr = a1/x + a2/x^2 + a3/x^3 + a4 x^5 + x^6;
r = {Coefficient[#, x, Exponent[#, x]], #, Exponent[#, x]} & /@ (List @@ expr)

Mathematica graphics

To get the answer you want, now simply pull the second entry in the first cell

 r[[1, 2]]/r[[1, 1]]

Mathematica graphics

Nasser
  • 143,286
  • 11
  • 154
  • 359