6
$\begingroup$

Recently I tried to check a result of integration which should be a linear combination of the Riemann $\zeta\;$-function at various arguments, the coefficients of the combination being of primary interest.

Unfortunately Mathematica have expanded all occurrences of $\zeta\;$-functions with even integer arguments.

Is there a way to prevent it from doing that?

A sample code:

 Integrate[ Log[1-x]^5/x^5, {x, 0, 1}]
$\endgroup$
9
$\begingroup$

This is even simpler (thanks to @CarlWoll):

ClearSystemCache[]; 
Block[{Zeta = Inactive[Zeta]}, 
 Integrate[Log[1 - x]^5/x^5, {x, 0, 1}]]

Mathematica graphics

Original answer:

Using the Gayley-Villegas trick:

Internal`InheritedBlock[{Zeta},
 Unprotect[Zeta];
 Zeta[a_Integer /; a > 1] /; ! TrueQ[$in] := Block[{$in = True},
   Inactive[Zeta][a]
   ];
 Protect[Zeta];
 Integrate[Log[1 - x]^5/x^5, {x, 0, 1}]
 ]

Note: The integral is actually computed in terms of limits of an expression involving PolyLog[n, 1-x] (for n = 2,3,4,5); we could do something similar for PolyLog as was done for Zeta above. However PolyLog actually evaluates to Zeta first, which is why the above works in this case. I mention it in case PolyLog does not evaluate to Zeta in a future version. And it's possible the integral will not be computed in terms of PolyLog in the future, too, I suppose. In any case, I thought some explanation of why the code happens to work in this case would be helpful. (It will certainly help me a year from now when someone asks why this doesn't work, and I won't remember a thing about it.)

$\endgroup$
  • 1
    $\begingroup$ Simpler is ClearSystemCache[]; Block[{Zeta = Inactive[Zeta]}, Integrate[Log[1 - x]^5/x^5, {x, 0, 1}]]. I tried using this Block earlier and it didn't work. When I saw your answer, I realized that the cache was interfering. $\endgroup$ – Carl Woll Apr 14 '18 at 15:50
  • $\begingroup$ @CarlWoll Ditto for me. But I didn't realize the cache was causing the problem, even though I mentioned it to the OP. (Ha-ha). Thanks. $\endgroup$ – Michael E2 Apr 14 '18 at 15:55
  • $\begingroup$ After my comment, I read the comments to the OP, and saw that! lol $\endgroup$ – Carl Woll Apr 14 '18 at 15:59
  • $\begingroup$ @MichaelE2 This is a nice suggestion, however I would like to recognise when it's superior over a simple pattern matching approach. +1. $\endgroup$ – Artes Apr 14 '18 at 16:35
  • $\begingroup$ @Artes This fiddling with the internals slows down Integrate, even worse if we inactivate PolyLog in the same way. Makes me wonder how safe it is. In fact, I got a wrong answer with one thing I tried (not shown). On the other hand, pattern matching can be made much harder if there are coefficients in the integrand that obfuscate or destroy the pattern. But done your way, it is perfectly safe. (+1 to your answer a while ago.) $\endgroup$ – Michael E2 Apr 14 '18 at 17:49
8
$\begingroup$

Mathematica is a term rewriting system and there are various ways to suppress automatic evaluation of expressions. The system doesn't evaluate Zeta for odd integer arguments (see e.g. Zeta[Range[2, 20]]). Zeta[n] yields expressions involving n-th powers of Pi, thus one of possible ways to achieve the goal would be e.g.

Integrate[Log[1 - x]^5/x^5, {x, 0, 1}] /. 
 Times[x_, Pi^n_Integer] :> x Pi^n Inactivate[Zeta[n]]/Zeta[n] //
 TraditionalForm

enter image description here

Another way is to use HoldForm[Zeta[n]] instead of Inactivate[Zeta[n]] however the latter is more universal and handy. You can use Activate (also with appropriate patterns) to evaluate the expression, e.g.

Activate[%]
-((5 Pi^2)/6) - (11 Pi^4)/18 - 30 (Zeta[3] + Zeta[5])

Nevertheless using such a replacement should be appropriately restricted to avoid possible ambiguities with expressions involving symbolic results in terms of powers of Pi.

$\endgroup$
  • 1
    $\begingroup$ For safety, you can restrict the transformation to even powers of $\pi$: Times[x_, π^n_?EvenQ] $\endgroup$ – J. M. is away Apr 13 '18 at 18:11
  • $\begingroup$ @J.M.needshelp. Right, however the OP might explain if expressions like e.g. Integrate[BesselK[0, x]^2, {x, 0, Infinity}] are subject to transform or not. $\endgroup$ – Artes Apr 13 '18 at 18:23
  • $\begingroup$ Thanks for the answer. However we are just lucky that in this special case we can recognize our function by a power of $\pi $. It may be however a more general function with a "simple" value at a special point. Is there a general way to prevent Mathematica from evaluation of some listed functions? $\endgroup$ – drer Apr 13 '18 at 19:57
  • $\begingroup$ @drer I've mentioned about pattern option in Inactivate which could be exploited. With an example at hand this could be worked out, nonetheless there is no obvious general way. $\endgroup$ – Artes Apr 13 '18 at 20:21
  • 1
    $\begingroup$ @drer Re "in this special case we can recognize our function by a power of π": It's not clear that it is because Zeta is evaluating that we have powers of π in the answer. Executing Block[{Zeta = Inactive[Zeta]}, Integrate[Log[1 - x]^5/x^5, {x, 0, 1}]] suggests that the powers of π are computed without using Zeta. If so, one cannot blame the evaluation of special functions for returning a correct answer in a certain form. $\endgroup$ – Michael E2 Apr 14 '18 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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