Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to integrate the following function with Legendre polynomial and Gamma function. I am open to suggestions.

(* assumptions = {s > 0, α > 0} *)

Φ[s_, x_, α_] := (-1)^s Sqrt[(s α)/Gamma[1 + 2*s]] 
                 LegendreP[s, s, Tanh[α x]]

a1 =  Integrate[x Φ[s, x, α]^2, {x, -∞, ∞}]
share|improve this question
Please provide a Mathematica code instead of a LaTeX one. – Öskå Sep 2 '13 at 14:45
Integrate::idiv: "Integral of x\ LegendreP[s,s,Tanh[x\[Alpha]]]^2 does not converge on {-[Infinity],[Infinity]}." You probably have an error in the function definition or in the boundary conditions. – Sektor Sep 2 '13 at 15:49
Table[Integrate[x \[Phi][s, x, a]^2, {x, -\[Infinity], \[Infinity]}, Assumptions -> a > 0], {s, 20}] yields {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}. – Artes Sep 2 '13 at 16:32
Integrate[Evaluate[(-1)^s Sqrt[(s a)/Gamma[1 + 2*s]] LegendreP[s, s, Tanh[a x]] /. {a -> 2, s -> 5}], {x, -\[Infinity], \[Infinity]}] your method call you are calling function you are passing symbols, Shall you not pass values ? – Rorschach Sep 2 '13 at 19:08
up vote 4 down vote accepted

If you evaluate the square of the function Φ[s, x, α] you get the following:

 FullSimplify[( Sqrt[(s \[Alpha])/Gamma[1 + 2*s]]
   LegendreP[s, s, Tanh[\[Alpha] x]])^2, {\[Alpha] > 0, s > 0}]

(*   (s \[Alpha] LegendreP[s, s, Tanh[x \[Alpha]]]^2)/Gamma[1 + 2 s] *)

Thus, you only need to think of how to integrate the LegendreP[s, s, Tanh[\[Alpha] x]])^2. When looking at this function it becomes clear that the cases with integer and real values of s are different. Namely, if s is integer, the Legendre polynomials you need are even. Check this:

    Plot[{LegendreP[1, 1, Tanh[x ]], LegendreP[2, 2, Tanh[x ]], 
  LegendreP[3, 3, Tanh[x ]]}, {x, -2, 2}, PlotRange -> All, 
 PlotStyle -> {Red, Blue, Green}]

enter image description here
Here I plotted the LegendreP[3, 3, Tanh[x ]] function itself, not its square, just to make all three lines visible together. It is clear in this case that LegendreP[s, s, Tanh[\[Alpha] x]])^2 is also even, while your integrand, x*LegendreP[s, s, Tanh[x \[Alpha]]]^2 is odd. The integral is, therefore, zero.

The different story would be with the real s values. Check this:

    Plot[{LegendreP[0.1, 0.1, Tanh[x ]]^2, 
  LegendreP[0.4, 0.4, 2, Tanh[x ]]^2, 
  LegendreP[0.92, 0.92, Tanh[x ]]^2}, {x, -4, 4}, PlotRange -> All, 
 PlotStyle -> {Red, Blue, Green}]

enter image description here It is quite clearly visible that the curves are neither even, not odd. Have a look especially at the green one, the most manifested. Check also this:

 Plot[{LegendreP[s, s, Tanh[x ]]^2, 
   x*LegendreP[s, s, Tanh[x ]]^2}, {x, -4, 4}, 
  PlotStyle -> {Red, Blue}], {{s, 1.026}, 0, 2}]

enter image description here Here, as you see, the red line shows the behavior of the Legendre squared, while the blue one is that multiplied by x.
In addition they seem to increase with x. Indeed,

 Limit[LegendreP[0.92, 0.92, Tanh[x ]]^2, x -> Infinity]

(*  \[Infinity]  *)

This looks correct, but I would recommend you to check this last statement at some textbook on Legendre polynomials (like, e.g. Abramovitz and Stigun

The outcome is that for such s values the integral is infinity.

share|improve this answer
the values of s is a positive integer. – David H Sep 3 '13 at 10:25
@Herman Then the result is zero. – Alexei Boulbitch Sep 4 '13 at 7:06
@ Alexei would it be possible to get a closed form for the following integral?a3 = Integrate[-[ImaginaryI] x [Phi][s, x, [Alpha]] [Phi]1[s, x, [Alpha]], {x, -[Infinity], [Infinity]}, Assumptions -> [Alpha] > 0, s > 0] – David H Sep 5 '13 at 11:35
@Herman Something is missing in the expression you have written here. I cannot understand, what function do you need to integrate. – Alexei Boulbitch Sep 6 '13 at 11:41

Heman, I did not get what function did you ask about in your comment.Probably it is due to a non-Mathematica code. However, it seems that it is either a square of your Phi function (described in your original question), of some combinations of several such functions.

I think this integral can hardly be expected to be calculated analytically because of its unusual argument. Nevertheless, before giving up I would advice you to check the tables of integral of Prudnikov, Brychkov, Marichev. At least two volumes of their collection are on the integration of special functions. May be some variables change may be of use, such that you make some more convenient thing under the Legendre polynomial, but with the penalty of some weight appearing in front of it. Anyway, if you succeed, it will be the place where science transforms into art.

The question is what do you need it for? Will an approximate function also do?

If yes, I can offer a simple workaround. I do it within the example of the square of the Legendre function, and you may proceed by analogy with the function you need.

This determines the integral numerically in the form of a list {s, Log[Int]}. I calculate the Log of the integral, since it otherwise grows too rapidly:

lst = Table[{s, 
      LegendreP[s, s, 
       Tanh[x]]^2, {x, -\[Infinity], \[Infinity]}]]}, {s, 1, 10}];

Note that the parameter alfa plays, evidently, no role. You can verify this by the replacement x->afa*x, which I did.

rnd[expr_] := expr /. x_Real :> Round[x, 0.001];

The following fits the numerical table by a simple function of s: f(s)=a+b*s^c

 ft = Fit[lst, {1, s^c}, s];
   ListPlot[lst, Frame -> True, 
    FrameLabel -> {Style["s (integer only values)", 16], 
      Style["Log{\!\(\*SubsuperscriptBox[\(\[Integral]\), \(-\
\[Infinity]\), \(\[Infinity]\)]\)\!\(\*SubsuperscriptBox[\(P\), \
\(s\), \(s\)]\)[tanh(x)]\[DifferentialD]x}", 16]}],
   Plot[ft, {s, 1, 10}, PlotStyle -> Red, Frame -> True]
   }, Epilog -> Inset[Framed[Column[{
       PointLegend[{Blue}, {Style["   Numeric values of integral", 
       LineLegend[{Red}, {Row[{Style["Fit with ", 12], 
           Style["f(c)\[TildeTilde]", 12, Italic], 
           Style[rnd[ft], 12, Italic]}]}]
       }], RoundingRadius -> 5, Background -> LightYellow], 
    Scaled[{0.35, 0.8}]]],
 {{c, 1.5, Dynamic@Row[{"c= ", c}]}, 1, 3}]

That's how it should look like: enter image description here, Play a bit with the slider to choose the best value. Have fun.

share|improve this answer
Alexei, I reopened this question -- why don't you move your question edit to an answer now? By the way, in the future if you have something useful to add to a closed question please comment or, if necessary, flag the post and explain. – Mr.Wizard Sep 11 '13 at 0:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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