# how to use Expand command efficiently

Recently I got in a problem and I will try to explain with a simple example. I have an expression which reads :

y = (10 + 2*x )/x;


Now I want to substitute 1/x -> 0 . Now if I substitute directly in this expression the result is zero i.e.

y = (10 + 2*x )/x;
y /. {1/x -> 0};
Print[y];


Answer = 0 which should not be.

So I have to expand before substituting i.e.

y = (10 + 2*x )/x;
y1=Expand[y,x];
y1 /. {1/x -> 0};
Print[y1];


which gives me the correct answer = 2.

My question is, is there any efficient way (or another way) to do this work. This is because in case of 'y' has a very large expression or coefficient of 1/x is very complicated, Expand command is taking very very long time.

• What about taking the limit x->Infinity ? – Mher Jun 1 '16 at 12:37
• Hi @Mher Safaryan , if you are suggesting not to use Expand and just to use y /. {x ->Infinity} , it won't work. The problem will be the same no? Previously it gave 0, now it will give Infinity. – Boogeyman Jun 1 '16 at 12:43
• Why it is infinity ? it's just 2 for your example. Just try this (* Limit[y, {x -> Infinity}] *) – Mher Jun 1 '16 at 12:50
• I believe that @Mher was suggesting that you use Limit[y, x -> Infinity], which does yield 2. So does First@Collect[y, x] or Coefficient[y, x, 0]. The last may be best, depending on your goal. – bbgodfrey Jun 1 '16 at 13:04
• okay both are working .. thank you both. – Boogeyman Jun 1 '16 at 13:27

If you want to substitute 1/x->0 in in expressions then take the limit x->Infinity:
y = (10+2*x)/x;

First@Collect[y, x]