# How to integrate product of BesselJ and BesselY with different orders?

I need help with analytic solution for the following integral

$Assumptions = n ∈ Integers && a ∈ Reals && b ∈ Reals && k ∈ Reals && r ∈ Reals && b > a && a > 0 && b > 0 && k > 0 && r > 0 && n >= 0 Integrate[BesselJ[n - 1, k*r]*BesselY[n, k*r], {r, a, b}]  As suggested by @Akku14 in How to find analytical solution for integral from product of Bessel functions of second kind with different order? I use Mathematica 8.0.1 to find solutions for different orders of Bessel functions. A comparison of analytic integration result with numeric one reveals the problem: tmpVal = {a -> 0.2, b -> 0.4, k -> 1.8}; {N[Integrate[BesselJ[2, k*r]*BesselY[3, k*r], {r, a, b}] /.tmpVal], NIntegrate[BesselJ[2, k*r]*BesselY[3, k*r] /. tmpVal, {r, a /. tmpVal,b /. tmpVal}]} (*{-0.125636, -0.248211}*)  • For what it's worth, this is fixed in version 9. Someone else might be able to give a workaround for version 8 Mar 17, 2017 at 13:50 • I need an analytic solution. The comparison with numeric solution was done in order to show problem in analytic solution returned by Mathematica 8.0.1. Usage of Mathematica 9.0.1 does not solve the problem, since it returns Integrate[BesselJ[2, k*r]*BesselY[3, k*r], {r, a, b}] in unevaluated form. Mar 17, 2017 at 14:49 ## 1 Answer First define assumptions: $Assumptions =
n ∈ Integers && a ∈ Reals && b ∈ Reals &&
k ∈ Reals && r ∈ Reals && b > a && a > 0 && b > 0 &&
k > 0 && r > 0 && n >= 0 && s ∈ Integers;


Transform integrand using recursion formula (http : // functions.wolfram.com/03.01 .17 .0001 .01) in order to lift order of BesselJ to positive numbers:

ex = Expand[
BesselJ[n - 1, k*r]*BesselY[n, k*r] /.
HoldPattern[
BesselJ[\[Nu]_, z_]] :> ((2 (\[Nu] + 1)) BesselJ[\[Nu] + 1, z])/z -
BesselJ[\[Nu] + 2, z]]


As a result we receive 2 summands:

(2 n BesselJ[n, k r] BesselY[n, k r])/(k r) -
BesselJ[1 + n, k r] BesselY[n, k r]


Integrating each summand using approach shown by Akku14, and defining workaround rules for this integrals we receive:

iJnYnr := Integrate[
z_.*BesselJ[n_, k_*r_]*BesselY[n_, k_*r_]/r_, {r_, a_, b_}] :>
RuleCondition[
z*(1/(2 Sqrt[\[Pi]]))(MeijerG[{{1/2}, {-(1/2), 1}}, {{0, 0,
n}, {-n, -(1/2)}}, a k, 1/2] -
MeijerG[{{1/2}, {-(1/2), 1}}, {{0, 0, n}, {-n, -(1/2)}}, b k, 1/2]),
Refine[FreeQ[z, r] && k ∈ Reals && r ∈ Reals && k > 0 &&
r > 0 && n >= 0 && n ∈ Integers && a ∈ Reals &&
b ∈ Reals && a > 0 && b > 0 && b > a]];

iJn1Yn := Integrate[
z_.*BesselJ[1 + n_, k_*r_]*BesselY[n_, k_*r_], {r_, a_, b_}] :>
RuleCondition[
z*(1/(2 Sqrt[\[Pi]]))(-a MeijerG[{{1/2, 1/2}, {0}}, {{1/2,
1/2 + n}, {-(1/2), -(1/2), -(1/2) - n}}, a k, 1/2] +
b MeijerG[{{1/2, 1/2}, {0}}, {{1/2,
1/2 + n}, {-(1/2), -(1/2), -(1/2) - n}}, b k, 1/2]),
Refine[FreeQ[z, r] && k ∈ Reals && r ∈ Reals && k > 0 &&
r > 0 && n >= 0 && n ∈ Integers && a ∈ Reals &&
b ∈ Reals && a > 0 && b > 0 && b > a]];


Using defined rules on expanded integrand

solut = ReleaseHold[Hold@Integrate[#, {r, a, b}] /. {iJnYnr, iJn1Yn}] & /@ ex


we obtain solution:

(1/(k Sqrt[\[Pi]]))
n (MeijerG[{{1/2}, {-(1/2), 1}}, {{0, 0, n}, {-(1/2), -n}}, a k, 1/2] -
MeijerG[{{1/2}, {-(1/2), 1}}, {{0, 0, n}, {-(1/2), -n}}, b k, 1/2]) - (1/(
2 Sqrt[\[Pi]]))(-a MeijerG[{{1/2, 1/2}, {0}}, {{1/2,
1/2 + n}, {-(1/2), -(1/2), -(1/2) - n}}, a k, 1/2] +
b MeijerG[{{1/2, 1/2}, {0}}, {{1/2,
1/2 + n}, {-(1/2), -(1/2), -(1/2) - n}}, b k, 1/2])


Comparison with numeric integration now shows correct result for arbitrary parameters:

tmpVal = {a -> 0.2, b -> 0.4, k -> 1.8}; nRule =
n -> 1; {N[solut /. nRule /. tmpVal],
NIntegrate[
BesselJ[n - 1, k*r]*BesselY[n, k*r] /. nRule /. tmpVal, {r, a /. tmpVal,
b /. tmpVal}]}

(*{-0.264519, -0.264519}*)


Be especially carefull about obtained fragile solution. Application of FunctionExpand and therefore FullSimplify to this solution may lead to non-numeric results. Define the the workaround rule for the integral in question:

iJn1mYn :=
Integrate[z_. BesselJ[n - 1, k_*r_]*BesselY[n, k_*r_], {r_, a_, b_}] :>
RuleCondition[
z*1/(k Sqrt[\[Pi]])
n (MeijerG[{{1/2}, {-(1/2), 1}}, {{0, 0, n}, {-(1/2), -n}}, a k, 1/2] -
MeijerG[{{1/2}, {-(1/2), 1}}, {{0, 0, n}, {-(1/2), -n}}, b k, 1/2]) -
1/(2 Sqrt[\[Pi]]) (-a MeijerG[{{1/2, 1/2}, {0}}, {{1/2,
1/2 + n}, {-(1/2), -(1/2), -(1/2) - n}}, a k, 1/2] +
b MeijerG[{{1/2, 1/2}, {0}}, {{1/2,
1/2 + n}, {-(1/2), -(1/2), -(1/2) - n}}, b k, 1/2]),
Refine[FreeQ[z, r] && k ∈ Reals && r ∈ Reals && k > 0 &&
r > 0 && n >= 0 && n ∈ Integers && a ∈ Reals &&
b ∈ Reals && a > 0 && b > 0 && b > a]]


P.S. I'm newbie in pattern matching, so this rule probably will not fit to every expression resembling integral in question. Any comments about workaround rules will be appreciated.