When evaluating the same integral using indefinite integration (method 1) or definite integration (method 2) I get different answers: method 1 = 0 and method 2 = 10*Pi*I. Method 2 is the correct answer, however I need the result in the form of a function so I need correct answer for method 1. Any ideas on what the problem is?




contour = z0 + r Exp[I theta];

f = (z - 3)^2*(z^3 + 1);

integrand = ((D[f, z] / f ) /. z -> contour)*D[contour, theta];

indefintegral = Integrate[integrand, theta];

defintegral = (indefintegral /. {r->5, z0 -> 0, theta -> 2*Pi})- 
(indefintegral /. {r -> 5, z0-> 0, theta -> 0})


r = 5;

z0 = 3;

contour = z0 + r*Exp[I theta];

f = (z - 3)^2*(z^3 + 1);

integrand = ((D[f, z] / f ) /. z -> contour)*D[contour, theta];

defintegral = Integrate[integrand, {theta, 0, 2*Pi}]

closed as off-topic by Daniel Lichtblau, Michael E2, MarcoB, Henrik Schumacher, halirutan Jun 20 '18 at 1:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Daniel Lichtblau, Michael E2, Henrik Schumacher, halirutan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ Your indefinite integral expression may have discontinuities, in which case substituting the limits in the indefinite integral expression gives incorrect results, which are avoided by the definite integral calculation. This is discussed in the "Possible Issues" subsection of the Integrate docs. See also: Definite and Indefinite integral give different results for piecewise function. $\endgroup$ – MarcoB Jun 19 '18 at 15:55
  • $\begingroup$ If you do the subsittution for r and z0 into indefintegral, then plot the real and imaginary parts over theta, you will see the latter has discontinuities. Basically this is what `@MarcoB surmised. $\endgroup$ – Daniel Lichtblau Jun 19 '18 at 16:14
  • $\begingroup$ Possible duplicate of Definite and Indefinite integral give different results for piecewise function $\endgroup$ – MarcoB Jun 19 '18 at 18:00
  • $\begingroup$ OK, perhaps, but I plotted the real and imaginary parts of the integrand (from method 1) using values r=5 and z0 = 0. As expected, it is easily visually seen the real part will integrate to 0 while imaginary part integrates to a positive number. No obvious discontinuity in real part. Further, this is a simple application of the argument principle in complex analysis. The integrand itself contains only a polynomial in the denominator, so it has 5 poles that are interior to the contour (a circle of radius 5). The integrand must be holomorphic on the contour of integration. Am I wrong? $\endgroup$ – Karl Jun 20 '18 at 1:43
  • $\begingroup$ Ok I'am not very strong in contour integration,but we can easily visually seen: Plot[indefintegral /. {r -> 5, z0 -> 0} // Im, {theta, 0, 2 Pi}] obvious discontinuity in imaginary parts. $\endgroup$ – Mariusz Iwaniuk Jun 20 '18 at 8:32