When I test the symbolic integration along a contour, I want to let the answer to be the residue of the integrand. Here is the code:


It gets the result:

1.0365*10^-11 + 5.03064*10^-12 I

Obviously it's wrong, but when I use numerical integration:


Then the result is :

-3.9896 + 8.15845 I

which is right, because:

N[2 Pi I Residue[Sin[x]/(x - (1 + I)), {x, 1 + I}]]

which the result is:

-3.9896 + 8.15845 I

Here is the problem: 1. Can this be repeated in other version of Mathematica? 2. Is this a bug?

  • 2
    $\begingroup$ It's not a bug. You should not feed machine precision numbers to Integrate. This will happen AFAIK in all versions, and the solution to use exact numbers (1/100 instead of 0.01) will also work and will result in a symbolic solution coherent with what NIntegrate returns. (related: mathematica.stackexchange.com/questions/38457/… ) $\endgroup$ – Peltio Apr 23 '18 at 5:03
  • $\begingroup$ @Peltio: You are not right: in the case under consideration Integrate should switch to NIntegrate and perform the right numeric answer. Compare with Integrate[x^2,{x,0,1.0}]. $\endgroup$ – user64494 Apr 23 '18 at 5:06
  • $\begingroup$ Is this a new functionality introduced in which version? $\endgroup$ – Peltio Apr 23 '18 at 5:07
  • $\begingroup$ @Peltio: Integrate[x^2,{x,0,1.0}] performs 0.333333 at least since version 7.0. The same with Integrate[x^2 + y, {x, 0, 1.0}, {y, 0, 1}] and many others. The question you refer to is another cup of tea: pay your attention to "Try not to supply machine numbers to integrals over infinite domains ". $\endgroup$ – user64494 Apr 23 '18 at 5:14
  • 1
    $\begingroup$ @user64494 well, Integrate[x^2,{x,0,1.0}] giving 0.333333 does not contradict my claim. Most integrals do come out right even with machine precision numbers. This contour integral though, does not, even if the contour is finite (I guess it's it being so darn close to the singularity the problem, here). Glad to know they fixed something from version 7 on. They evidently did not fix everything :-) $\endgroup$ – Peltio Apr 23 '18 at 7:34

There is a workaround in version 11.3:

j = Integrate[Sin[x]/(x - (1 + I)), {x, 1 + I - 1/100, 1 + I - 1/100*I, 
1 + I + 1/100, 1 + I + 1/100*I, 1 + I - 1/100}]//FullSimplify

2 I [Pi] Sin[1 + I]


-3.9896 + 8.15845 I


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.