Consider the evaluation of the integral of 1/r between -1 and 1, in Mathematica.

Let us go back to the integral of f(r) between -1 and 1. From the symmetry of the figure it may be apparent that f(r) is an odd function, and the area under the curve (or the integral) should go to zero.

If we try to use Mathematica to integrate it with

We say, hmmm. Why don't we simply try to substitute the limits in the indefinite integral:

This gives the expected answer of zero.

- The function f(r) = 1/r has a discontinuity at r = 0.
- The indefinite integral of 1/r is simply log(r), which is real for positive "r", and is complex for -ve "r", and goes to negative infinity as r approaches zero.
- One might be tempted to think that getting definite integrals is easy if one knows the indefinite integral
- Not so fast. Discontinuties can complicate things!

Let us go back to the integral of f(r) between -1 and 1. From the symmetry of the figure it may be apparent that f(r) is an odd function, and the area under the curve (or the integral) should go to zero.

If we try to use Mathematica to integrate it with

**Integrate[f,{r,-1,1}]**, it complains that the integral does not converge.We say, hmmm. Why don't we simply try to substitute the limits in the indefinite integral:

The answer makes sense since Log[1] = 0, and Log[-1] = i * pi, but is clearly not the correct answer?

The reason for this is that the First Fundamental Theorem of Calculus requires the antiderivative to be continuous over the range of integration, and from the second plot above, it is clear that this condition is violated.

So how do we figure this thing out? We could isolate the discontinuity by integrating close to zero (using "epsilon"), and perhaps take the limit later.

## 3 comments:

Consider wrapping that last step in a Limit as epsilon->0. Otherwise there does not seem to be any hint given to Mathematica that you are assuming epsilon is small.

Yeah, the last statement would give you an answer with epsilon as a parameter. As you say, one would have to take the limit to evaluate the integral. That is essentially what I meant by the last line "We could isolate the discontinuity by integrating close to zero (using "epsilon"), and

perhaps take the limit later."I am so grateful for your post.Really looking forward to read more. Cool.

Mathematica

Post a Comment