0
$\begingroup$

How might I override the value of the Greek letter PI within various builtin language functions in the Wolfram language? Specifically and without having to reinvent the wheel or code equivalent functions from complete scratch, I wish to replace with more useful and even perhaps more accurate values the well-worn and overworked value of 3.14159... that is used in various Fourrier transforms and other, sundry functions.

Why you might ask. Why not would then be my reply. Working with the same figures as other historic peoples knew might cast off some of the ignorance from our contemporary perspectives and fragmented understandings. Oh, and then there is the spectacular and infamous contender and rival to proper entitlement as these number-letter things go: 3.1446055.

I might draft a workbook to illustrate the importance to musicology and music of being able to use divergent values of PI. Yet in truth, many fields of research and study, industry, and even contemporary culture use PI in innumerable calculations ever day. All stand to potentially gain from alternate PI values.

F.

$\endgroup$
8
  • $\begingroup$ There are a handful of algorithms for relatively accurate approximations (more accurate approximation usually means more difficult algorithm). Have you not found anything on Google? $\endgroup$
    – ktm
    Commented Dec 5, 2018 at 3:13
  • 4
    $\begingroup$ Pi is exactly $\pi$. SetAccuracy[Pi, d] will give d digits of $\pi$. Which functions do not use the exact value of Pi, subject to, of course, Mathematica's normal rules of precision propagation (e.g. 1. * Pi and 1.`100 * Pi? $\endgroup$
    – Michael E2
    Commented Dec 5, 2018 at 3:13
  • 2
    $\begingroup$ How about \[DoubledPi], which has no built-in meanings? Unicode F749. $\endgroup$ Commented Dec 5, 2018 at 3:35
  • 3
    $\begingroup$ Block may be of utility, though no assurances it will cover the bases, e.g. Block[{Pi = 10}, Area[Disk[{0, 0}, 2]]] would return 40 vs the expected 4 Pi $\endgroup$
    – ciao
    Commented Dec 5, 2018 at 7:08
  • 4
    $\begingroup$ @FrancisfromResponseBase Please keep your tone civil. This is not Reddit, Tumblr, or Twitter. Your question can easily be found on this site or the documentation and if someone from the community thinks it should be closed, it is his right to vote for that. If you disagree, then you can discuss this, but "your puerile censor.." or "do you enjoy preventing people from learning" is not how you will interact with people here. $\endgroup$
    – halirutan
    Commented Dec 6, 2018 at 11:13

1 Answer 1

6
$\begingroup$

Beside using Block as ciao suggests in his comment to the question, you can also play with the attribute Protected.

Thus,

Attributes[Pi]

{Constant, Protected, ReadProtected}

Unprotect[Pi];
Pi = 42;
Protect[Pi];
Area[Disk[]]
Tan[Pi/4]

42
Tan[21/2]

To restore Pi to its special symbolic status, you should execute

Unprotect[Pi];
Pi =.
Protect[Pi/4];

Then

Area[Disk[]]
Tan[Pi/4]

will once again act normally in evaluations, giving

π
1

$\endgroup$
1
  • $\begingroup$ My total respect, and I thank you for completely changing my impression of you! Awesome answer! $\endgroup$ Commented Dec 6, 2018 at 21:05

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