1
$\begingroup$

It could be a duplicate question. However I could not find much after a huge searching. I have a huge expression in mathematica involving many Zetas. I want not to evaluate the even Zetas which Mathematica does automatically.

This question has been raised before in a slightly different context in here:

Stop the Zeta function from evaluating

However I would like to know if there is any better way to do this.

Code:

exp= c2*Zeta[2]+c3*Zeta[3]+c4*Zeta[4]+c5*Zeta[5];

The expected output would be the same i.e.

c2*Zeta[2]+c3*Zeta[3]+c4*Zeta[4]+c5*Zeta[5]

but Mathematica does

(c2 Pi^2)/6 + (c4 Pi^4)/90 + c3 Zeta[3] + c5 Zeta[5]

Using the Inactive option:

Block[{Zeta = Inactive[Zeta]},c2*Zeta[2] + c3*Zeta[3] + c4*Zeta[4] + c5*Zeta[5]];

c2 Inactive[Zeta][2] + c3 Inactive[Zeta][3] + c4 Inactive[Zeta][4] + c5 Inactive[Zeta][5]

which when I Activate/Replace again gives the same problem. I am not using notebook interface where this solution 'works', I am using mathematica from terminal.

$\endgroup$
2
  • 2
    $\begingroup$ Use zeta instead of Zeta. $\endgroup$ Commented Nov 19, 2018 at 16:13
  • $\begingroup$ Okay. this already occurred to me :) I can always do that to avoid these kind of things and save time. I was expecting some inbuilt solution which I don't know of. $\endgroup$
    – BabaYaga
    Commented Nov 19, 2018 at 16:16

1 Answer 1

1
$\begingroup$

You can use the following code

Unprotect[Zeta]; Zeta[n_] := "Zeta"[n] /; EvenQ[n];

to do what you want on a global level. For example

ex = c2*Zeta[2] + c3*Zeta[3] + c4*Zeta[4] + c5*Zeta[5]

returns an expression that prints the same.

Later, when you want the actual values of the even Zetas use this

ex /. {"Zeta"[n_] :> Sum[1/k^n, {k, Infinity}]} // InputForm

which returns

(c2*Pi^2)/6 + (c4*Pi^4)/90 + c3*Zeta[3] + c5*Zeta[5]
$\endgroup$
2
  • $\begingroup$ But if I save or print the expression, it will show c3 Zeta[3] + c5 Zeta[5] + c2 Inactive[Zeta][2] + c4 Inactive[Zeta][4] instead of c3 Zeta[3] + c5 Zeta[5] + c2 Zeta[2] + c4 Zeta[4]. However its helpful to know the global setting. $\endgroup$
    – BabaYaga
    Commented Mar 15, 2019 at 15:53
  • 1
    $\begingroup$ @Boogeyman I have changed to "Zeta" instead and it should print the way you want. Of course, there are way to make Mathematica change the way it prints expressions. That is one possiblity. $\endgroup$
    – Somos
    Commented Mar 15, 2019 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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