2
$\begingroup$

I have many expressions of the form $c_1/\epsilon, c_2/\epsilon \dots ,c_n/\epsilon$ where $n$ is a large number and I also have expressions of the form $b_1\epsilon, b_2\epsilon, \dots ,b_m \epsilon$ where $m$ is also very large. $c_i$ and $b_i$ are just $\epsilon$-independent variables or numbers.

I would like to put the terms in which $\epsilon$ appears in the numerator to zero without affecting the terms in which $\epsilon$ appears in the denominator. Is there a way to automate this in Mathematica? Probably the answer is yes and the solution is very simple but I have not found the correct syntax yet.

   expr/.eps->0

gives rise to errors because of producing indeterminate forms, as expected.

Thanks!

$\endgroup$
8
  • 1
    $\begingroup$ Would something like (Numerator[expr] /. eps -> 0)/Denominator[expr] work? $\endgroup$ Oct 27, 2017 at 11:46
  • $\begingroup$ (b1 \[Epsilon])/n1 + k1/\[Epsilon] + (b2 \[Epsilon])/n2 + k2/\[Epsilon] /. Power[\[Epsilon], -1] :> 0 ?? $\endgroup$
    – Ali Hashmi
    Oct 27, 2017 at 11:49
  • $\begingroup$ @J.M That gave me a 1/0 error again :/ $\endgroup$
    – CAF
    Oct 27, 2017 at 11:54
  • $\begingroup$ @AliHashmi This works except it gets rid of the denominator terms instead. If I replace -1 with +1 it gives me an error. $\endgroup$
    – CAF
    Oct 27, 2017 at 11:55
  • $\begingroup$ Could you post an example expression, then? It's hard to give a useful suggestion if other people can only guess at what your expressions look like. $\endgroup$ Oct 27, 2017 at 11:57

4 Answers 4

2
$\begingroup$
expr = 
  {(256 m2)/(ϵ M (-1 + b x) (1 + b x)), (256 ϵ m1)/(M^3 (-1 + b x) (1 + b x))};

Replace[#,Times[PatternSequence[___, Verbatim[ϵ]]] -> 0, {1}] & /@ expr
(* {(256 m2)/(M (-1 + b x) (1 + b x) ϵ), 0} *) 
$\endgroup$
1
  • $\begingroup$ I made an edit. since the attribute of Times is Orderless we do not need OrderlessPatternSequence and therefore PatternSequence will suffice $\endgroup$
    – Ali Hashmi
    Oct 27, 2017 at 13:07
1
$\begingroup$

It would be nice to obtain a more direct route but the following simple trick gets the job done:

   expr/.{1/eps->x};
   %/.{eps->0}
   %/.{x->1/eps}
$\endgroup$
1
$\begingroup$

You could use @DanielLichtblau's solution from the comments:

Normal @ Series[{b1 ϵ, b2 ϵ, c1/ϵ, b3 ϵ, c2/ϵ, c3/ϵ}, {ϵ, 0, 0}]

{0, 0, c1/ϵ, 0, c2/ϵ, c3/ϵ}

$\endgroup$
0
$\begingroup$

If the input expression expr only contains terms of the form 1/eps and eps, then you can use Coefficient:

Dot[Coefficient[expr, eps, {-1, 0}], {1/eps, 1}]
$\endgroup$

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.