
Some π-ography for Pi day - ViralBShah
https://julialang.org/blog/2018/03/pifonts
======
3pt14159
For obvious reasons, I'm going to love today. There are so many fun things
with pi.

1\. It's roughly equal to ln(6) ^ (ln(5) ^ (ln(4) ^ (ln(3) ^ ln(2))))

2\. It's not exactly hard to figure out whether pi ^ e is greater than e ^ pi
(years ago I did it sans calculator on a test in a fast but brutish way), but
there are some pretty terse, beautiful solutions that can be elusive.

3\. Aside from the whole e^(pi * i) - 1 = 0 just looking too crazy to be true,
I also love how it includes the basics tools of mathematics / philosophy.
Subtraction (or addition if re-arranged), Multiplication (or division if re-
arranged), exponentiation, true / 1, false / 0, equality, geometric ratio (pi)
which can be thought of as representing the physical world, a growth ratio (e)
which can be though of as representing life, and a number (i) literally name
after an aspect of human thought / imagination.

~~~
52-6F-62
That's fun. I'm recently working my way back through my fundamentals prepping
for some future hopeful coursework and had to play with number 1.

    
    
        #include "stdio.h"
        #include "math.h"
    
        long double ln ( long double n ) {
          return log(n) / log(M_E);
        }
    
        long double pi ( void ) {
            return pow(ln(6), pow(ln(5), pow(ln(4), pow(ln(3), ln(2)))));
        }
    
        int main( void ) {
          printf("%LE\n", pi());
          return 0;
        }
    
    

Or in JS

    
    
        function ln(n) {
          return Math.log(n) / Math.log(Math.E);
        }
    
        function pi() {
          return (ln(6) ** (ln(5) ** (ln(4) ** (ln(3) ** (ln(2))))));
        }
    

If anybody else wants to toy with it.

Getting older and working outside of the fields that employ a lot of certain
technicals doesn't leave as much time for exploration as one would like.

~~~
jwilk
Both log() in C and Math.log() in JS are natural logarithms, so there's no
need to define your own ln() functions.

~~~
3pt14159
If I ever make a programming language the log function will take two
parameters, value and base. It's too confusing when engineers, mathematicians,
and computer scientists all use different implicit bases.

~~~
52-6F-62
I had to do a double take for that reason. They're 100% correct, but I assumed
what I'd learned from math.

Whenever I otherwise work with logarithms in programming I choose to work
explicitly to at least save myself confusion. By default I assumed
log()/Math.log() referred to common logarithms.

I usually end up re-implementing the log function with 2 values, as with _ln
/logE_ above, but substituting the constant.

    
    
       long double logn( long double n, long double x )
       {
         return log(x) / log (n);
       }
    

But, yes, all my above code could be shorter.

I haven't worked with any explicitly scientific languages like Mathlab— do any
languages take a more traditionally mathematical approach? Or any libraries
that have taken that torch up?

~~~
jwilk
For common cases of n=2 and n=10, consider using dedicated functions log2()
and log10(), because they are more precise. For example:

    
    
      log(1E42)/log(10) == 42 - 7.105427357601002e-15
    
      log10(1E42) == 42.0

~~~
52-6F-62
Noted. It’s more for other cases. While doing any algebra coursework I usually
(loosely) confirm my thoughts by running them in a repl with said functions to
at least keep me on track— so _logn_ usually serves uncommon bases. My
thinking that way might not make much sense, but I start to explain it in
other comments.

Anyway— thanks, I appreciate the insights. That’s the reason I like this forum

------
simonbyrne
The author of this post is the creator of the Julia visualization package
Luxor.jl
([https://github.com/JuliaGraphics/Luxor.jl](https://github.com/JuliaGraphics/Luxor.jl)).
One thing I like about it is the nice turtle graphics feature
([http://juliagraphics.github.io/Luxor.jl/stable/turtle.html](http://juliagraphics.github.io/Luxor.jl/stable/turtle.html)).

------
tim_hutton
Is anyone else a bit sick of these 'pi days'? Every year we get the same old
shtick.

Pleasingly, under the one true date format [0] there are no pi days. (Well
there are, but long past the heat death of the Universe.)

[0] [https://xkcd.com/1179/](https://xkcd.com/1179/)

~~~
kej
You might appreciate one of my favorite Pi Day related comics, then:
[http://www.qwantz.com/index.php?comic=955](http://www.qwantz.com/index.php?comic=955)

~~~
tim_hutton
The value on pi approximation day (22/7) is closer to pi than the value on pi
day (3.14).

