12

Four fours is a famous puzzle (made trivial with logarithms). For this puzzle, we take inspiration from Glen O's challenge from a few years back. The rules here are slightly different, but the goal is the same. Your goal is to approximate $\pi$ to the highest accuracy (per operation) as possible, using only four fours and the following operations:

  • The classic arithmetic operations: $+,-,\times,\div$
  • Exponentiation and log-base as binary operations: $\log_a b$ and $a^b$. You may only take logs of positive real numbers.
  • The root function as a binary operator $\sqrt[b]{a}$.
  • Unary operations: $(\cdot)!$ for integer arguments only (so you can't use $\frac12!$ to get $\sqrt{\pi}/2$), unary negation $-$, the square root $\sqrt{\cdot}$, and floor/ceiling for rounding down/up: $\lfloor\cdot\rfloor$ and $\lceil \cdot\rceil$.

Any other operations are not allowed, including double factorials and decimal points. In addition, you can do the following with no penalty:

  • Parentheses (for grouping purposes only, no binomial coefficients etc.)
  • Concatenation of 4's. That is, you can use 44 as a single number without costing an operation. You cannot concatenate things that are not fours, e.g. you can't concatenate $\sqrt{4}$ and $4!$ to get 224.
  • You do not have to use all four fours (e.g. msh210's answer of $\lfloor 4\rfloor$ is allowed).

Your score is equal to the number of digits of accuracy per operation used. That is, if you got the approximation $A$ by using $n$ operations, your score is $$ \frac{-\log_{10}|\pi - A|}{n} $$ To avoid division by 0, you must use at least one operation.


As an example, if you submit $\sqrt{(44 - 4!)/4} = \sqrt{5}\approx 2.24$, that has 4 operations, so your score would be:$$ \frac{-\log_{10} |\pi - \sqrt{5}|}4 \approx 0.01438... $$

10 Answers10

9

Three fours, five operations, score 1.0413

$$ \sqrt[4!]{4!}+\sqrt{4} \approx 3.141586 $$

Also five operations but too cute not to include, score 0.7539:

$$ \sqrt[4]{44\sqrt{\sqrt{4!}}} \approx 3.141423 $$

Four operations, score 0.7059:

$$ \sqrt4^\sqrt{\log_4{44}} \approx 3.143093 $$

The best three-operation expression has already been posted in another answer.

For completeness sake, two, score 0.4245:

$$ \left\lceil \log_4{44} \right\rceil = 3.0 $$

and one, score 0.3852:

$$ \log_4{44} \approx 2.729716. $$

This doesn’t seem to be the type of question that calls for spoiler hiding, correct me if I’m wrong.

Roman Odaisky
  • 1,072
  • 7
  • 15
6

$$\frac{44}{\left\lfloor\sqrt{\sqrt{(4+4)!}}\right\rfloor}$$

is equal to

the common approximation $22/7$

and scores

$$\frac{-\log_{10}\left(\frac{22}7-\pi\right)}6$$

which is $\approx0.4830$.


Edit: Better yet is

$$\sqrt{\frac{44-4}4}$$

which scores

$$\frac{-\log_{10}\left(\sqrt{10}-\pi\right)}3$$

, or $\approx0.5614$.

msh210
  • 12,844
  • 2
  • 49
  • 120
  • Nice. But how did you score it- how many operations did you charge yourself? I count 4, but I think you may have calculated score with 3. And maybe the charge is 5? – Damila May 05 '20 at 04:17
  • @Damila, it looks like six operations to me. I think that's how I computed the score, but if I messed up then please let me know. – msh210 May 05 '20 at 04:25
  • 1
    @Damila he did score it correctly – Ankit May 05 '20 at 04:37
  • I missed the round down symbols. Well done! – Damila May 05 '20 at 12:00
5

Okay, I'll start us off with the obvious:

$\lfloor4\rfloor$ scores $\approx0.0663$.

Surely that can be improved on….

msh210
  • 12,844
  • 2
  • 49
  • 120
5

Now I've got it ! Just finished generating all possible solutions for a given number of operations. Had to discard some answers because of float overflow so I hope big numbers means lower score.

Best scores up to 5 operations were found by Roman Odaisky and zixuan. Here's a solution for 6 operations :

$\sqrt[4!]4!+4-\sqrt 4 = 3.14158644$

with a score of 0.86778360, but it's still less than the best 5-operation answer.

Program crashed pretty hard at 7 operations though.

Here's the source code.

Old answer

I had an idea how to brute force the whole thing : concatenation is free, so why not use it to its full potential ? With $log_a$ or $\sqrt[b]a$, you'll get only 1 operation so a higher score, and with as many fours you want you might get to $\pi$.

I just realized while writing this that you need four fours or less, so my scores don't qualify.

I used python for precision (tried C++ first but FP64 isn't enough), and used a nested loop to generate numbers of concatenated fours $a$ and $b$, computed $log_b a$ and its score and returned the best score and values (it's $O(n^2)$ so I didn't push it too hard, took 5 minutes) so the best answer for $a$ and $b$ $< 10^{2000}$ is :

$A = 3.141596697042137$ with a score of $5.393247671097606$ for :

$log_b a$ with $a$ being 1680 concatenated fours and $b$ being 535 concatenated fours.

I'll try going at it later by brute forcing all possible operations though, with a acceptable amount of fours.

Sarah
  • 51
  • 3
3

This isn't legal, but

$\sqrt{4} \times \arccos(4-4) = \pi$

with a score of $+\infty$

shoover
  • 5,201
  • 22
  • 29
3

3.160964... in 4 operations, score 0.42820978

$\log_{4}(4(4!-4)) $

Steve
  • 3,865
  • 11
  • 34
2

Got it down to 3.14 but it uses sin again: Score: 1.38767676535

4+sin444 = 3.13991521562

Ok this is extremely close with 2 ops. (3.18): Score: 0.71908465944

ln(4!)=3.17805383035

I'm not sure if this is legal cuz it uses sin: Score: 0.49654277813

4+sin(4)=3.24319750469

Very close approximation (3.1): Score: 0.44995372319

4-log(4+4)=3.09691001301

Really simple one lol works surprisingly well: Score: 0.42447963952

4 - 4/4 = 3

Extremely close (3.16) but 4 operations Score: 0.42108608415

sqrt(4+4+sqrt4)=3.16227766017

This one is really close (3.18) but uses more operations: Score: 0.33056528095

sqrt4 + (4+4)th root(4)=3.189207115

Heres one with just one operation: Score: 0.29569382019

log(4444)= 3.64777405027

Ankit
  • 1,255
  • 5
  • 22
2

$\sqrt[4]{4!*4} \approx 3.13016916015$

Only used $4-\frac{4}{4}$ operations and $4-\frac{4}{4}$ $4$s. Score:

$0.64740035441$

Please allow this answer. I took $4$ hours to find this answer (or a very long time).

new Q Open Wid
  • 2,468
  • 9
  • 28
1

If this is legal:

4/ (4!th root of 44)

Equals

3.416

With 3 operations

Division, factorial, root. Parentheses not necessary, added for clarity without full mathematical notation.

For a score of 0.187

Damila
  • 964
  • 6
  • 10
  • I didn't say roots were allowed, but this and one other answer are very creative. I'll allow it. –  May 05 '20 at 04:32
  • I have another answer. Posted as a different answer. Got it down to 3.18 – Damila May 05 '20 at 05:05
1

Second answer, got it to 3.18 with 5 operations:

4 - SQRT(4*4/4!) = 3.1835

Score = 0.276

Damila
  • 964
  • 6
  • 10