# How do I solve this integral in Mathematica?

I am trying to solve this integral in Mathematica $$I=\int_{0}^{1} d x e^{iax} K_{0}\left(\sqrt{\left[q x(1-x)+m\right] b}\right)$$ where $$a$$, $$b$$, $$m$$, and $$q$$ are real positive constants.

I want to solve it in the limit for small argument of $$K_0$$ i.e.
$$K_0(x) \rightarrow -\ln{\frac{x}{2}} +$$ finite terms.

So $$I=-\int_{0}^{1} d x e^{iax} \ln\left(\frac{1}{2}\sqrt{\left[q x(1-x)+m\right] b}\right)$$

What I should obtain is this $$I\approx\frac{1}{2}\ln{\frac{4}{mb}}$$ but what I obtain is some complex functions. I have tried to use PrincipalValue->True but it doesn't evaluated the integral. Any suggestions on how to fix it?

Edit: $$K_0$$ is a modified Bessel function of the second kind. I am just using this

Integrate[Exp[I*a*x]*Log[Sqrt[(b (m + q (1 - x) x))]/2], {x, 0, 1}]


Edit: Say I want to evaluate

Integrate[Cos[a*x]*Log[Sqrt[(b (m + q (1 - x) x))]/2], {x, 0, 1}]


instead for non-zero $$a$$, $$b$$, $$m$$, and $$q$$. Mathematica does not give an answer for this, any help?

• People here generally like users to post code as Mathematica code instead of just 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 meta Q&A helpful Dec 16 '20 at 18:15
• For completeness, what is $K_0$? Dec 16 '20 at 18:15
• Are you able to retrieve your expected result with q=0 ? Dec 16 '20 at 18:20
• No, because I get a complex answer Dec 16 '20 at 18:35
• Except for special values of a, I don't see why the result will have a non-zero imaginary part. E.g., Block[{a = 1, m = 1, b = 1, q = 1}, NIntegrate[Exp[I*a*x]*Log[Sqrt[(b (m + q (1 - x) x))]/2], {x, 0, 1}] ] Dec 16 '20 at 18:42

For the revised integral, if you assume that the parameters are positive rather than just non-zero,

\$Version

(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)

Clear["Global*"]

Assuming[{a > 0, b > 0, m > 0, q > 0},
int = Integrate[Cos[a*x]*Log[Sqrt[(b (m + q (1 - x) x))]/2], {x, 0, 1}] //
ComplexExpand[#, TargetFunctions -> {Re, Im}] & // FullSimplify]

(* (1/(2 a))(Log[(b m)/4] Sin[a] +
2 Cos[a/2] ((-CosIntegral[1/2 a (-1 + Sqrt[1 + (4 m)/q])] +
CosIntegral[1/2 a (1 + Sqrt[1 + (4 m)/q])]) Sin[
1/2 a Sqrt[1 + (4 m)/q]] -
Cos[1/2 a Sqrt[
1 + (4 m)/q]] (SinIntegral[1/2 a (1 + Sqrt[1 + (4 m)/q])] +
SinIntegral[1/2 (a - a Sqrt[1 + (4 m)/q])]))) *)


The result for integral I is

(I/(2*a))*(1 - E^(I*a))*Log[(b*m)/4] - (1/a)*
E^((I*a)/2)*((-I)*Pi*Sin[(a*Sqrt[4*m + q])/(2*Sqrt[q])] +
(CosIntegral[(a/2)*(1 - Sqrt[4*m + q]/Sqrt[q])] -
CosIntegral[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])])*
Sin[(a*Sqrt[4*m + q])/(2*Sqrt[q])] +
(SinIntegral[(a/2)*(1 - Sqrt[4*m + q]/Sqrt[q])] +
SinIntegral[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])])*
Cos[(a*Sqrt[4*m + q])/(2*Sqrt[q])])


You can easily workout the real and imaginary parts of this.

Edit: OK, May be not so easy, but the real part is

(1/(2*a))*((CosIntegral[(a/2)*(Sqrt[4*m + q]/Sqrt[q] - 1)] -
CosIntegral[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])])*
Sin[(a/2)*(1 - Sqrt[4*m + q]/Sqrt[q])] +
(CosIntegral[(-(a/2))*(1 + Sqrt[4*m + q]/Sqrt[q])] -
CosIntegral[(a/2)*(1 - Sqrt[4*m + q]/Sqrt[q])])*
Sin[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])] -
2*Cos[a/2]*Cos[(a*Sqrt[4*m + q])/(2*
Sqrt[q])]*(SinIntegral[(a/2)*(1 - Sqrt[4*m + q]/Sqrt[q])] +
SinIntegral[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])])) + (Sin[a]/a)*
Log[Sqrt[b*m]/2]


and the imaginary part

(1/(2*a))*((-Cos[a/2 + (a*Sqrt[4*m + q])/(2*Sqrt[q])])*
CosIntegral[-((a*(Sqrt[q] + Sqrt[4*m + q]))/(2*Sqrt[q]))] +
Cos[a/2 + (a*Sqrt[4*m + q])/(2*Sqrt[q])]*
CosIntegral[a*(1/2 - Sqrt[4*m + q]/(2*Sqrt[q]))] -
Cos[a/2 - (a*Sqrt[4*m + q])/(2*Sqrt[q])]*
CosIntegral[(a/2)*(-1 + Sqrt[4*m + q]/Sqrt[q])] +
Cos[a/2 - (a*Sqrt[4*m + q])/(2*Sqrt[q])]*
CosIntegral[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])] +
4*Cos[a/4]*Cos[(a*Sqrt[4*m + q])/(2*Sqrt[q])]*Sin[a/4]*
SinIntegral[(a/2)*(-1 + Sqrt[4*m + q]/Sqrt[q])] -
4*Cos[a/4]*Cos[(a*Sqrt[4*m + q])/(2*Sqrt[q])]*Sin[a/4]*
SinIntegral[(a/2)*(1 + Sqrt[4*m + q]/Sqrt[q])]) + (Log[(b*m)/4]*
Sin[a/2]^2)/a


A way to calculate these integrals is: find the derivative of the integrand with respect to q, then integrate it with respect to x as definite integral, and finally find again the antiderivative with respect to q. In the end you have still to determine the integration constant.

Some hints. Since you have that E^I a x term, you only get a real result for a == 0.

Plot the integrand, do numerical integration and compare with expection. It differs.

For q == 0 and a == 0 , you get the expected result, numerical and analytical.

Manipulate[{Plot[
Evaluate@
Through[{Re,
Im}[-E^(I a x) Log[1/2 Sqrt[(q x (1 - x) + m) b]]]], {x, 0, 1},
PlotStyle -> {Blue, Red}, ImageSize -> 400],
NIntegrate[-E^(I a x) Log[1/2 Sqrt[(q x (1 - x) + m) b]], {x, 0,
1}], 1./2 Log[4/(m b)]}, {{a, 1}, 0, 4}, {{b, 1}, 0, 5}, {{m, 1},
0, 4}, {{q, 1}, 0, 5}]
`