2
$\begingroup$

I have to do an integral, like this

NIntegrate[1/Sqrt[(Energy - ℏ ω)^2 - Δ^2], {Energy, Δ, Δ + ℏ ω}]

How can I insert these singularities -Δ + ℏ ω, Δ + ℏ ω

$\endgroup$
  • 1
    $\begingroup$ Do you mean E to be the value 2.718... ? If you don't, change it to an undefined symbol. NIntegrate requires numbers. After changing E to some other integration variable, Integrate will work, although you will need to give assumptions concerning the other variables. $\endgroup$ – Bill Watts Nov 28 '17 at 19:10
  • $\begingroup$ No I use E here for aesthetic reasons it was a typo E means generic variable of integration $\endgroup$ – Giuliano-Francesco Timossi Nov 29 '17 at 9:40
  • $\begingroup$ Do you want a numerical solution ? If so give values for all symbols except the variable of integration. if you want an analytical solution try Integrate. $\endgroup$ – Lotus Nov 29 '17 at 10:56
1
$\begingroup$

First, one of the singularities is already an end point, and nothing needs to be done about it. Assuming the symbols have numeric values, then one might check if the other singularity is in the interval of integration:

If[Δ < -Δ + ℏ ω < Δ + ℏ ω,
 NIntegrate[1/Sqrt[(Energy - ℏ ω)^2 - Δ^2], {Energy, Δ, -Δ + ℏ ω, Δ + ℏ ω}],
 NIntegrate[1/Sqrt[(Energy - ℏ ω)^2 - Δ^2], {Energy, Δ, Δ + ℏ ω}]]

A one-liner that should work is

NIntegrate[
 1/Sqrt[(Energy - ℏ ω)^2 - Δ^2], {Energy, Δ, Clip[-Δ + ℏ ω, {Δ, Δ + ℏ ω}], Δ + ℏ ω}]

Example with made-up numbers:

Block[{Δ = 1, ℏ = 1, ω = 2},
 Print[{Energy, Δ, Clip[-Δ + ℏ ω, {Δ, Δ + ℏ ω}], Δ + ℏ ω}];
 NIntegrate[
  1/Sqrt[(Energy - ℏ ω)^2 - Δ^2], {Energy, Δ, Clip[-Δ + ℏ ω, {Δ, Δ + ℏ ω}], Δ + ℏ ω}]
 ]
{Energy,1,1,3}
(* 0. - 3.14159 I  *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.