# This complicated integral using numerical integration

I want to do the following integral

$$\int\limits_{-\pi/2}^{\pi/2}\dfrac{(k_{up}\cos\phi)\cdot(k_{down}\cos\alpha)}{k_{up}\cos\phi+k_{down}\cos\alpha}\cos{[(k_{up}\cos\phi-k_{down}\cos\alpha)x]}d\phi$$

with the following relations $k_{up}=\sqrt{E}$

$$k_{down}=\sqrt{E-\Delta}$$

$$k_{up}\sin{\phi}=k_{down}\sin{\alpha}$$

If you want you can use arbitrary positive values for $E,\Delta,x$

How should I go about doing this complicated integration. Any insights would be helpful.

• what have you tried until now? – Mauricio Fernández Jun 18 '18 at 20:45
• You seem to have an implicit relationship between some of your variables. If you would like help, you will need to explain further. – mikado Jun 18 '18 at 20:45
• I was just trying to solve it on paper and then I tried to solve it analytically on mathematica but I think that is not possible, For Nintegrate do we need to put in the values of all variables? – Indeterminate Jun 18 '18 at 20:49
• I have mentioned all the implicit relationships. What extra information do I need to provide? – Indeterminate Jun 18 '18 at 20:50
• People here generally like users to post code as Mathematica code instead of images or TeX, so they can copy-paste it. It makes it convenient for them and more likely you will get someone to help you. You may find this this meta Q&A helpful – Michael E2 Jun 19 '18 at 1:33

At first we assume parameters like: α,e,Δ,x

α = 1;
e = 2;
Δ = 1/3;
x = 1/2;
kd = Sqrt[e - Δ];
ku = kd *Sin[α]/Sin[ϕ];

(* We find a singular point ,because function is not continuous and highly oscillatory*)

point = Simplify[ϕ /. Solve[ku*Cos[ϕ] + kd Cos[α] == 0, ϕ][[1]],
C[1] ∈ Integers] /. C[1] -> 0

(*-1 *)

Plot[{(ku*Cos[ϕ]*kd Cos[α])/(ku*Cos[ϕ] + kd Cos[α])*
Cos[(ku Cos[ϕ] - kd Cos[α])*x]}, {ϕ, -Pi/2, Pi/2},
Epilog -> {Red, Line[{{point, -2}, {point, 2}}]}]

NIntegrate[(ku*Cos[ϕ]*kd Cos[α])/(ku*Cos[ϕ] + kd Cos[α])*
Cos[(ku Cos[ϕ] - kd Cos[α])*x], {ϕ, -Pi/2,point, Pi/2}, Method -> "PrincipalValue"]

(*We use PrincipalValue to calculate a integral !!! *)

(* 0.404925 *)

Using another method:

NIntegrate[(ku*Cos[ϕ]*kd Cos[α])/(ku*Cos[ϕ] + kd Cos[α])*
Cos[(ku Cos[ϕ] - kd Cos[α])*x], {ϕ, -Pi/2, Pi/2},
Exclusions -> ku*Cos[ϕ] + kd Cos[α] == 0,
WorkingPrecision -> 30, Method -> "DoubleExponential"]

## EDIT:

ClearAll["Global*"]; Remove["Global*"];
e = 2;
Δ = 1/3;
x = 1/2;
kd = Sqrt[e - Δ];

point[α_] := ϕ /. FindRoot[kd*Sin[α]/Sin[ϕ]*Cos[ϕ] + kd Cos[α] == 0,
{ϕ, -1/2, 1/2}, Method -> "Secant", WorkingPrecision -> 20,MaxIterations -> 50000];

g[α_?NumericQ] := NIntegrate[
(kd*Sin[α]/Sin[ϕ]*Cos[ϕ]*kd Cos[α])/(kd*Sin[α]/Sin[ϕ]*Cos[ϕ] + kd Cos[α])*
Cos[(kd*Sin[α]/Sin[ϕ] Cos[ϕ] - kd Cos[α])*x], {ϕ, -Pi/2, point[α], Pi/2},
Method -> "PrincipalValue", WorkingPrecision -> 20];

n = 50;(* Increase this value for smoother plot*)

ListLinePlot[Table[{α, g[α]}, {α, -Pi/2, Pi/2, 1/n}], AxesLabel -> {"α", "g[α]"}] // Quiet

• Thanks for the answer. One thing I didn't understand was why did you have to assume value of $\alpha$, why can't we vary $\phi$ and get value of $\alpha$ for each $\phi$. – Indeterminate Jun 19 '18 at 17:30
• @JashanSinghal. I edited my answer. – Mariusz Iwaniuk Jun 19 '18 at 19:09