1
$\begingroup$

I have an expression, and I wanted to evaluate it for a certain value of a variable. However, /. gives a calculation error, whereas manually replacing the variable with the value succeeds. Why?

$$\sum _{n=0}^{\infty } \frac{1}{(k+n)! (n-k)!}\text{/.}\, \{k\to 4\}$$ $$\sum _{n=0}^{\infty } \frac{1}{(n+4)! (n-4)!}$$

The first errors Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered. and returns Indeterminate, whereas the second yields BesselI[8, 2]. My understanding of ReplaceAll was that the two should be functionally identical. What's wrong?

(Mathematica 11.0.1.0, Windows 10, 64 bit)

$\endgroup$
  • 2
    $\begingroup$ Hi Erhannis, welcome to the Mathematica Stack Exchange. Could you post the exact code that's exhibiting the issue in copy-pasteable format? It helps a lot if we can just plug your code straight into Mathematica. Thanks! $\endgroup$ – Carl Lange Feb 2 at 8:09
2
$\begingroup$

The issue appears to be an order of precedence thing.

When you evaluate your first function $\sum _{n=0}^{\infty } \frac{1}{(k+n)! (n-k)!}$, it simplifies to $\frac{\, _1F_2(1;1-k,k+1;1)}{(-k)! k!}$.

Since it will do this simplification before replacing $k$, and since ${(-k)! k!}$ evaluates to ComplexInfinity (as does the top half of the function), you get the error message.

The trick is to do the replacement earlier:

$\sum _{n=0}^{\infty } \left(\frac{1}{(k+n)! (n-k)!}\text{/.}\, k\to 4\right)$

Which evaluates to BesselI[8, 2] as expected.

$\endgroup$
  • 3
    $\begingroup$ This kind of problem is exactly why HypergeometricPFQRegularized was introduced. Your general sum formula can be simplified to be non-singular: Sum[1/((n+k)!(n-k)!), {n,0,Infinity}] // FullSimplify gives HypergeometricPFQRegularized[{1},{1-k,1+k},1], which at k=4 gives Hypergeometric0F1Regularized[9,1], which in turn fullsimplifies to BesselI[8,2]. $\endgroup$ – Roman Feb 2 at 8:56

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.