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};

Answer = 0 which should not be.

So I have to expand before substituting i.e.

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

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.

  • 1
    $\begingroup$ What about taking the limit x->Infinity ? $\endgroup$ – Mher Jun 1 '16 at 12:37
  • $\begingroup$ 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. $\endgroup$ – Boogeyman Jun 1 '16 at 12:43
  • 2
    $\begingroup$ Why it is infinity ? it's just 2 for your example. Just try this (* Limit[y, {x -> Infinity}] *) $\endgroup$ – Mher Jun 1 '16 at 12:50
  • 2
    $\begingroup$ 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. $\endgroup$ – bbgodfrey Jun 1 '16 at 13:04
  • $\begingroup$ okay both are working .. thank you both. $\endgroup$ – 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;
Limit[y, x->Infinity]

Other ways of doing that is the followings (see bbgodfrey's comment):

First@Collect[y, x]
Coefficient[y, x, 0]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.