13
$\begingroup$

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... $$

$\endgroup$
7
  • 2
    $\begingroup$ It would be more appropriate to post this here, as the problem would probably get closed for 'lack of context' on Math SE. $\endgroup$
    – Toby Mak
    Commented May 5, 2020 at 12:25
  • $\begingroup$ If anyone can get $\log_2 (\sqrt{8} + 6) \approx 3.1422$ in $4$ operations, you would get a score of approximately $0.812$. $\endgroup$
    – Toby Mak
    Commented May 5, 2020 at 12:27
  • 1
    $\begingroup$ Are more than 4 fours allowed? $\endgroup$ Commented May 5, 2020 at 13:55
  • 1
    $\begingroup$ It would be very interesting to know how many fours and operations are needed for any given accuracy. $\endgroup$
    – Simd
    Commented May 24, 2020 at 15:56
  • 5
    $\begingroup$ I’m voting to close this question because open-ended puzzles are off-topic as of May 2019 $\endgroup$
    – bobble
    Commented Aug 5, 2021 at 3:55

10 Answers 10

10
$\begingroup$

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.

$\endgroup$
2
  • 4
    $\begingroup$ That is extremely impressive! $\endgroup$
    – user63779
    Commented May 5, 2020 at 12:41
  • 4
    $\begingroup$ "This doesn’t seem to be the type of question that calls for spoiler hiding" - all other answerers seem to disagree. $\endgroup$
    – Steve
    Commented May 5, 2020 at 13:50
6
$\begingroup$

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

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

Surely that can be improved on….

$\endgroup$
2
  • $\begingroup$ Good start! Yes it can be improved on though. Since the question, the best I've got is about 0.2 $\endgroup$
    – user63779
    Commented May 5, 2020 at 2:37
  • $\begingroup$ Lol Nice observation $\endgroup$
    – Ankit
    Commented May 5, 2020 at 2:43
6
$\begingroup$

$$\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$.

$\endgroup$
4
  • $\begingroup$ 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? $\endgroup$
    – Damila
    Commented May 5, 2020 at 4:17
  • $\begingroup$ @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. $\endgroup$
    – msh210
    Commented May 5, 2020 at 4:25
  • 1
    $\begingroup$ @Damila he did score it correctly $\endgroup$
    – Ankit
    Commented May 5, 2020 at 4:37
  • $\begingroup$ I missed the round down symbols. Well done! $\endgroup$
    – Damila
    Commented May 5, 2020 at 12:00
5
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ You can only use up to 4 fours. $\endgroup$
    – user63779
    Commented May 22, 2020 at 17:52
  • 1
    $\begingroup$ Yes I realized this too late, but this gave me the motivation to work on brute forcing the original problem, which is a bit more complex. Still working on it. $\endgroup$
    – Sarah
    Commented May 23, 2020 at 23:05
  • $\begingroup$ Updated the answer $\endgroup$
    – Sarah
    Commented May 24, 2020 at 4:19
4
$\begingroup$

This isn't legal, but

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

with a score of $+\infty$

$\endgroup$
4
  • $\begingroup$ Yes there's a reason I disallowed inverse trig functions / complex logarithms $\endgroup$
    – user63779
    Commented May 5, 2020 at 5:02
  • $\begingroup$ :) (extra characters to pad the comment) $\endgroup$
    – shoover
    Commented May 5, 2020 at 5:04
  • $\begingroup$ @FlorianF Fewer operations ;) $\endgroup$
    – Guimoute
    Commented May 24, 2020 at 18:23
  • 3
    $\begingroup$ $4 \times arctan(4/4)$ uses fewer operations, so it scores a larger infinity than yours. [grammar fixed] $\endgroup$
    – Florian F
    Commented May 24, 2020 at 18:44
3
$\begingroup$

3.160964... in 4 operations, score 0.42820978

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

$\endgroup$
2
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ It seems sin and ln and log with no explicit base are not legal. $\endgroup$
    – msh210
    Commented May 5, 2020 at 3:24
  • $\begingroup$ @msh210 yeah probably $\endgroup$
    – Ankit
    Commented May 5, 2020 at 3:28
  • $\begingroup$ @Ankit indeed they are not. $\endgroup$
    – user63779
    Commented May 5, 2020 at 3:32
  • $\begingroup$ but can you do log base 4? $\endgroup$ Commented Jul 21, 2020 at 12:25
2
$\begingroup$

$\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).

$\endgroup$
0
1
$\begingroup$

Second answer, got it to 3.18 with 5 operations:

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

Score = 0.276

$\endgroup$
1
$\begingroup$

If this is legal:

$$\frac4{\sqrt[4!]{44}}$$

Equals

3.416

With 3 operations,

division, factorial, root.

For a score of 0.187

$\endgroup$
2
  • $\begingroup$ I didn't say roots were allowed, but this and one other answer are very creative. I'll allow it. $\endgroup$
    – user63779
    Commented May 5, 2020 at 4:32
  • $\begingroup$ I have another answer. Posted as a different answer. Got it down to 3.18 $\endgroup$
    – Damila
    Commented May 5, 2020 at 5:05