2
$\begingroup$

I'm an avid tauist (tauday.com) and I don't like the fact that Mathematica displays equations with $\pi$ instead of $\tau=2\pi$. I know that I can "force" it to display $\tau$ by e.g. Sum[ArcTan[1/n^2],{n,1,Infinity}] /. [Pi] -> [Tau]/2 (with backslashes) but writing "/. [Pi] -> [Tau]/2" (with backslashes) at the end of everything is very annoying.

Is there a command which would have the effect of applying "replace every $\pi$ with $\tau/2$" to a whole notebook so that I can write it just once and then never again?

$\endgroup$

1 Answer 1

6
$\begingroup$

Use $Post.

$Post = (# /. π -> τ/2) &;
$\endgroup$
7
  • 1
    $\begingroup$ You will need a few more things such as Unprotect[\[Tau]]; N[\[Tau], prec : _ : MachinePrecision] := N[2 Pi, prec]; SetAttributes[\[Tau], {Constant, Protected}]; (*Protect[\[Tau]];*) $\endgroup$
    – Bob Hanlon
    Commented Mar 28, 2023 at 17:47
  • 1
    $\begingroup$ @BobHanlon What exactly does that accomplish $\endgroup$
    – Vestoo
    Commented Mar 28, 2023 at 18:52
  • 1
    $\begingroup$ Once you have replaced Pi by tau you need a way to convert it to a numeric value when you are looking for a number. Without this, Sin[1.1*\[Tau]] // N won't return a numeric value. There are other things needed to get it to act just like Pi behaves. $\endgroup$
    – Bob Hanlon
    Commented Mar 28, 2023 at 19:58
  • $\begingroup$ @BobHanlon I defined t:=2 Pi and when I write Sin[1.1t]//N, it gives ≈0.5877, which is the correct numeric value. Am I missing something? $\endgroup$
    – Vestoo
    Commented Mar 29, 2023 at 15:32
  • 1
    $\begingroup$ $Post = (# /. {\[Pi] -> \[Tau]/2, str_String?(StringContainsQ[#, "\[Pi]"] &) :> ToString[ToExpression[str] /. \[Pi] -> \[Tau]/2, TraditionalForm]}) &; $\endgroup$
    – Bob Hanlon
    Commented Mar 29, 2023 at 16:28

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.