# Nonelementary integral

1. Mar 26, 2012

### nawidgc

I have a function namely cos(x)/x^2 which I need to integrate in the
limits of x = -1 to x = +1.

If we plot the integrand (attched xls file, integrand plotted for different number of sampling points), you can see that the integrand is positive all the time inside the limits of integration. Also note that the integrand is singular in the given limit at x=0.

Now since this integral is not a simple one to handle, I resorted to
Mathematica for solving it. Strangely, Mathematica returns a value of
negative 2.97 for the integral (I only remember the first two digits
after decimal point). Question is, when the integrand is positive all
the time, how can the integral be negative. When I try some online
integration tools for this function, they return with message that
this integral is likely to be a nonelementary kind. I know funny
things do happen at the singularities but the answer from Mathematica
does not make sense to me. Does anyone have any comments on this?

gcd.

PS. I tried to evaluate the integral with Trapezoid rule (see yellow box in attached xls file) and the answer returned does make sense.

#### Attached Files:

• ###### question1.xls
File size:
40.5 KB
Views:
73
2. Mar 26, 2012

### JJacquelin

Hi !
the integral doesn't converge for x tending to 0.
The response of WolframAlpha is correct.

#### Attached Files:

• ###### Photo1.jpg
File size:
22 KB
Views:
82
3. Mar 26, 2012

### nawidgc

I am surprised to see the message from WolframAlpha for with Mathematica I could get -2.97 as the answer.

In any case (divergent integral as you say or negative area under the curve as I found), my point is if you look at the curve of cos(x)/x^2, you can see a definite area under it. I don't understand why wouldn't this integral converge or return a positive value.

4. Mar 26, 2012

### chiro

Hey nawidgc and welcome to the forums.

You can't just evaluate this integral the way you have because you have a singularity at x = 0. If you try and integrate it normally then you are going to get a nonsensical answer.

Basically the reason in a nutshell is that at x = 0 you'll get a vertical asymptote. If you don't understand go to Wolfram Alpha and graph your function.

5. Mar 26, 2012

### Robert1986

I don't know what is going on with Mathematica.

However, why would you expect to get a finite number out of this integral? Would you ever try to integrate .5/x^2 over this interval? I hope not. The integrand blows up at zero so you get an integral that does not converge.

Also, 0 is not a singular point of the function. The function is not defined at x=0. An example of a singular point would be something like x=0 for the function f(x) = |x|.

You have also made an error in you excel file. In the column labeled "x^2" you actually have 1/x^2 so then when you divide cosx by 1/x^2 in column D you are really getting cosx * x^2. I changed col D to B*C and the graph and the trapezoid integral changed to what it should be.

6. Mar 26, 2012

### Robert1986

It will "converge" in your excel file (even if you correct it as I did), but this is just a reflection of the fact that you are not sampling the function at x=0, which is where the bad stuff happens. If you change the value in A12 to 0, then the trapezoidal estimation blows up, as it should.

7. Mar 26, 2012

### chiro

I didn't say singular, I said singularity. I'll quote what I said:

http://en.wikipedia.org/wiki/Mathematical_singularity

8. Mar 26, 2012

### nawidgc

Thanks Robert! Yes, I did make a blunder and my sincere apologies for the confusion.
And yes, the integral does not converge if you do sample at x=0.

But if I am interested only in the area under the curve (assuming that the integral converges if you skip x=0 sample), should it matter whether I sample at x=0 or not?

9. Mar 26, 2012

### chiro

It would help us if you gave us some context for your question.

If it is for example related to a physical problem of some sort, then it would to tell us what variables and quantities (like velocity, displacement, etc) are involved and the context in which they are involved.

10. Mar 26, 2012

### Robert1986

11. Mar 26, 2012

### chiro

Sorry, my mistake! :) [But you gotta admit, it was a big coincidence!]

12. Mar 26, 2012

### nawidgc

Let me at the outset admit that the function cos(x)/x^2 does not arise from a physical problem. I have chosen it to verify a different numerical method to integrate a function arising out of physical problem.

I am trying to solve a Boundary Integral Equation (BIE) for acoustic scattering in 2D. The function that needs to be integrated in the BIE is hypersingular (of the 1/x^2 form where x is the distance between two points). One of my function from the BIE looks like
(n_1 \cdot n_2)/x^2 where n_1 and n_2 are the normals at the two points. At singularity when the two points are one and the same, the dot product of these two normals equals 1. So my function (n_1 \cdot n_2)/x^2 looks essentially the same as cos(x)/x^2 at singularity (at x=0, cos(0)=1 and n_1 \cdot n_q =1). I therefore thought I should try simpler (:uhh:) function like cos(x)/x^2 in Mathematica.

gcd.

13. Mar 26, 2012

### Robert1986

Yes, it was, especially when I actually did misquote the OP. So, I guess I deserved to get called out on that by someone. :)

14. Mar 26, 2012

### chiro

I'm just wondering if you could 'censor' some area of distance to give a zero contribution, kind of like how it's done in ElectroMagnetism. For example in a faraday cage the field inside the 'cage' is zero (or something like that) but outside it's according to the formula.

The interpretation of this is that you basically make your function you are trying to integrate equal to zero in some small region [-e,e] where e is a small number and outside of that the function is still the same.

You would have to think about the effect this would have on your answer, but I imagine that at some point the effect would end up changing once you got within e units of the element itself.

Alternatively you could substitute the zero function in [-e,e] with some other custom function that doesn't diverge like say a Gaussian function or something else.

This way you split the integration into two parts [-e,e] and the rest of the real line your function is defined on and this way you get a result that doesn't blow up and also something that is more representative of your actual system.

Personally I'd imagine that once you get so close in terms of distance that the behaviour of the function actually changes, maybe even like the faraday example listed above [just a thought!].

15. Mar 26, 2012

### JJacquelin

Big mistake ! This is not true in case of x close to 0.
The "area unter it" becomes very big, even for very small distance between two values of x.
Examples :

#### Attached Files:

• ###### Integrals.JPG
File size:
7.6 KB
Views:
87
16. Mar 27, 2012

The integral "clearly" diverges, as previously stated. you should really have made a better drawning.

Oh, and perhaps you actually meant

$$\int_{-\infty}^{\infty} \frac{1 - \cos x}{x^2} \, \mathrm{d}x$$ ?
A clever transformation, turns this integral into

$$\int_{-\infty}^{\infty} \frac{\sin x}{x} \, \mathrm{d}x$$

Which can easilly be evaluated

17. Mar 27, 2012

### micromass

Staff Emeritus
Easily be evaluated?? I don't think it is a very elementary integral...