# symbolic integration of product of hankel function and trignometric function

I want to perform the following integration.

my function is : r*cos(r)hankel(0,kr) i want to integrate from 0->pi , and want to get the expression in terms of k. I used this command

Integrate[r*cos[r]*HankelH2[0,k*r],{r,0,pi}]. The integral is not performed. Please suggest some solution. Thanks in advance

• 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! – Michael E2 Nov 1 '14 at 12:45
• Hi, I edited the code to format it properly. I left cos as is. It should be Cos, but I could be sure whether it was a simple typo, or an error. Do you have a reason to think it is known how to write the integral in terms Mathematica functions? – Michael E2 Nov 1 '14 at 12:47
• int[k_?NumericQ] := NIntegrate[r*Cos[r] HankelH2[0, k*r], {r, 0, Pi}] gives you a way to represent the function via numerical approximation. – Michael E2 Nov 1 '14 at 12:49
• There is no closed form solution for Integrate[BesselJ[0, k r] Cos[r], r] which what causes this to fail. There is a analytical solution for k=1. k = 1; Integrate[r*Cos[r]*HankelH2[0, k*r], r] gives 1/4 (2 r^2 HypergeometricPFQ[{1/4, 3/4}, {1/2, 1/2, 2}, -r^2]- I Sqrt[2] MeijerG[{{1, 5/4, 7/4}, {1/2}}, {{1, 1}, {0, 1/2, 3/2, 3/2}}, r, 1/2]) might also be better to ask this on the math group. – Nasser Nov 1 '14 at 14:17
• @Nasser Thank you very much for your replies. Actually i can not put the value k=1, because I want to solve the result of integral (which should be in terms of k) to find roots of equation i.e. the values of k. – Minshawi737 Nov 1 '14 at 14:37

To expand on my comment and to include the purpose finding roots

ClearAll[int, intjac];

int[k_?NumericQ, opts : OptionsPattern[NIntegrate]] :=
NIntegrate[r*Cos[r] HankelH2[0, k*r], {r, 0, Pi}, opts];

intjac[k0_?NumericQ, opts : OptionsPattern[NIntegrate]] :=
Block[{k}, {{NIntegrate[D[r*Cos[r] HankelH2[0, k*r], k] /. k -> k0, {r, 0, Pi}, opts]}}];


The Jacobian intjac is passed to FindRoot to use in Newton's method. This can sometimes help speed convergence. In this case both the function and the Jacobian are moderately expensive numerical integrations. It happens to help reduced the time by half in the test case below. Note: The Jacobian has to have a matrix value; hence the {{}} to turn the derivative into a 1 x 1 matrix.

I would suggest using a finite AccuracyGoal. The default for NIntegrate is Infinity and NIntegrate will complain (NIntegrate::slwcon and NIntegrate::ncvb) when FindRoot drives k near a root. At a root, by definition, the integral is zero, and it's impossible to achieve any PrecisionGoal in computing a value of zero. Setting a finite accuracy goal prevents NIntegrate from refining the integration further than it can at MachinePrecision. For a higher AccuracyGoal, the WorkingPrecision would have to be increased.

(sol = FindRoot[int[k, AccuracyGoal -> 15], {k, -0.01}, Jacobian -> intjac[k]]) // AbsoluteTiming
int[k, AccuracyGoal -> 15] /. sol
(*
{0.447269, {k -> -3.19371*10^-20 - 0.520674 I}}
2.74622*10^-20 + 8.32667*10^-17 I
*)

(sol = FindRoot[int[k, AccuracyGoal -> 15], {k, -0.01}]) // AbsoluteTiming
int[k, AccuracyGoal -> 15] /. sol
(*
{0.821435, {k -> 1.38324*10^-18 - 0.520674 I}}
-1.18942*10^-18 + 8.32667*10^-17 I
*)