# Is there a way to know which symbolic expression Mathematica used?

Take the following symbolic sum:

Sum[(-1)^n/Factorial[2*n]*(Pi/2)^(2*n)*n, {n, 1, Infinity}]


Mathematica answers me: $$- \frac{\pi}{4}$$

It is great, I have an exact expression for this complicated sum. But I would like to know how mathematica knows this result.

Is there a way to ask him which function he used to compute it ?

You can use a Wolfram|Alpha query and then look at the Series Representation results.

In Mathematica, the easiest way to do this is start your input with == and it will change it to a spikey input symbol.

==Sum[(-1)^n/Factorial[2*n]*(Pi/2)^(2*n)*n, {n, 1, Infinity}]


In general, symbolic sums are evaluated by using a combination of internal methods and it is usually difficult to give insight into the evaluation process.

However, this sum is evaluated by using a representation in terms of HypergeometricPFQ (strictly speaking, this is a Hypergeometric0F1).

This may be seen by using the (undocumented) Method option setting "InactivePFQ" as shown below.


In:= Sum[(-1)^n/Factorial[2*n]*(Pi/2)^(2*n)*n, {n, 1, Infinity},
Method -> "InactivePFQ"] // InputForm

Out//InputForm=
-(Pi^2*Inactive[HypergeometricPFQ][{}, {3/2}, -Pi^2/16])/8

In:= Activate[%] // FullSimplify // InputForm

Out//InputForm=
-Pi/4

In:= N[%]

Out= -0.785398

In:= NSum[(-1)^n/Factorial[2*n]*(Pi/2)^(2*n)*n, {n, 1, Infinity}]

Out= -0.785398



The representation in terms of HypergeometricPFQ can be understood by defining a sequence corresponding to the first argument of Sum as follows (the sequence has been shifted so that it starts at 0, rather than 1).

a[n_] = (-1)^n/Factorial[2*n]*(Pi/2)^(2*n)*n /. {n -> n + 1};



The factor of-Pi^2/8 in the answer from Sum is the zeroth term of this sequence.


In:= a // InputForm

Out//InputForm=
-Pi^2/8



The arguments of HypergeometricPFQ in this case can be understood by computing the ratio of the adjacent terms of a[n].

In:= DiscreteRatio[a[n], n] // InputForm

Out//InputForm=
-Pi^2/(8*(1 + n)*(3 + 2*n))

In:=
Simplify[% == -(Pi^2/16)*(1/((n + 1)*(n + 3/2)))]

Out= True



The factor of (n+1) in the denominator of the above comes from the definition of Hypergoemetric0F1 and can be ignored.

Hope this helps in understanding the result from Sum.