# How to numerically integrate this integral

I am unable to do this definite integral in Mathematica 9.
Is there any command so that I can get the numerical value of the above integration?

Code:

A1 = (A*2^2*Sin[theta]*Cos[theta])/((1 - (2^2*Cos[theta]^2)^2))
A3 = NIntegrate[A1, {theta, 0, (Pi/2)}]

• You have to give a value for A in order to evaluate A1 or A3 numerically. – Jason B. Nov 5 '14 at 8:02
• You could just take the A outside the integrand, and have your answer as a function of A, but then you have to deal with the fact that A1 diverges when theta=Pi/3. – Jason B. Nov 5 '14 at 8:07
• @Jason B thank you so much sir – ARIJIT Nov 5 '14 at 8:11
• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Nov 5 '14 at 8:11
• To closevoters: The problem is not that one cannot integrate numerically functions involving symbolic constants, therefore you have no reason to close it. – Artes Nov 6 '14 at 8:48

Besides trivial observations that one cannot evaluate numerically integrals involving symbolic constants there are more interesting aspects of the problem at hand. First one should realize that a standard numeric approach is not appropriate for this kind of problems, since the integrand involves singular points (zero in the denominator) thus it is not convergent and therfore numeric integration produces large errors. So this is not a satisfactory answer:

A NIntegrate[(4  Sin[θ] Cos[θ])/((1 - (2^2 Cos[θ]^2)^2)), {θ, 0, π/2}]

NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of
the following: singularity, value of the integration is 0, highly oscillatory integrand,
or WorkingPrecision too small. >>

NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive
bisections in  θ near {θ} = {1.04922}.
NIntegrate obtained 1.2201346660089964 and 1.3407904317156392 for the integral
and error estimates. >>

1.22013 A


As we'll see a correct answer is very different however one finds it within the error estimate.

## General symbolic integral

We can find that the symbolic integral (in the Riemann sense) is not convergent in the given range:

Integrate[( 4 A Sin[θ] Cos[θ])/((1 - (2^2 Cos[θ]^2)^2)), {θ, 0, π/2}]

Integrate::idiv :"Integral of (Cos[θ]\Sin[θ])/(1-16\Cos[θ]^4)
does not converge on {0,π/2}."


We find the range where denominator does not vanish

Reduce[ 1 - 16 Cos[θ]^4 != 0 && Pi/2 > θ > 0, θ]

0 < θ < π/3 || π/3 < θ < π/2


Now we can find the symbolic integral assuming e.g. that the lower limit of integration is larger than π/3 (we should also assume an appropriate upper bound):

int[A_, B_] =
Integrate[( 4 A Cos[θ] Sin[θ])/( 1 - 16 Cos[θ]^4), {θ, B, π/2},
Assumptions -> 1 > A > 0 && π/3 < B < π/2]

1/4 A Log[-1 - 2/(1 + 2 Cos[2 B])]


We should compare numerical and symbolic results (see e.g. Symbolic integration error), e.g.:

NIntegrate[(4  Cos[θ] Sin[θ])/( 1 - 16 Cos[θ]^4), {θ, (4 π)/9, π/2}]

0.0606024

int[1, (4 π)/9]

 1/4 Log[-1 - 2/(1 - 2 Cos[π/9])]

N @ %

0.0606024


So we have a reliable symbolic result.

## Solution

A recommended approach is to calculate the given integral in a principal value sense, there is the appropriate option in the Integrate function:

Integrate[( 4 A Cos[θ] Sin[θ])/(1 - 16 Cos[θ]^4), {θ, 0, π/2},
PrincipalValue -> True]

1/4 A Log[5/3]


now we can define an adequate numeric function:

nint[A_?NumericQ, B_?NumericQ] :=
N @ Integrate[( 4 A Cos[θ] Sin[θ])/(1 - 16 Cos[θ]^4), {θ, 0, B},
PrincipalValue -> True]


e.g.

nint[ 1, π/2]

0.127706


Therefore a "numerical" answer to the question is 0.127706 A.

## Solution 2

Another approach would integrate numerically the integrand separately for the both sides of the singularity, a rough approach is

nint2[δ_?NumericQ] /; 0 < δ < π/6 :=
A NIntegrate[(4  Sin[θ] Cos[θ])/((1 - (2^2 Cos[θ]^2)^2)), {θ, 0, π/3 - δ}]
+ A NIntegrate[(4  Sin[θ] Cos[θ])/((1 - (2^2 Cos[θ]^2)^2)), {θ, π/3 + δ, π/2}]


Let's check how it works for a small value of δ

 nint2[0.0005]

0.127418 A


This approaches quite satisfactory to the real value, if we need higher acurracy one would increase the default WorkingPrecision.

• thank you so much for ur kind help – ARIJIT Nov 7 '14 at 10:12

As pointed out by Artes, this integral has meaning only under Cauchy principal value. Luckily, NIntegrate has this strategy (explained here):

NIntegrate[(4 Cos[\[Theta]] Sin[\[Theta]])/(1 - 16 Cos[\[Theta]]^4), {\[Theta], 0, \[Pi]/3, \[Pi]/2}, Method -> "PrincipalValue"]


0.127706

Note that the position of the sigularity has to be specified in the interval. Mathematica will automaticly take advantege of the fact that the integral cancels in the vicinity of the sigularity.