# Four fours to get $\pi$ [closed]

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

• It would be more appropriate to post this here, as the problem would probably get closed for 'lack of context' on Math SE. May 5 '20 at 12:25
• If anyone can get $\log_2 (\sqrt{8} + 6) \approx 3.1422$ in $4$ operations, you would get a score of approximately $0.812$. May 5 '20 at 12:27
• Are more than 4 fours allowed? May 5 '20 at 13:55
• @zixuan No, you can only use up to 4 fours. May 5 '20 at 14:11
• I’m voting to close this question because open-ended puzzles are off-topic as of May 2019 Aug 5 at 3:55

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

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.

• That is extremely impressive! May 5 '20 at 12:41
• "This doesn’t seem to be the type of question that calls for spoiler hiding" - all other answerers seem to disagree. May 5 '20 at 13:50

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

• 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? May 5 '20 at 4: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. May 5 '20 at 4:25
• @Damila he did score it correctly May 5 '20 at 4:37
• I missed the round down symbols. Well done! May 5 '20 at 12:00

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

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

Surely that can be improved on….

• Good start! Yes it can be improved on though. Since the question, the best I've got is about 0.2 May 5 '20 at 2:37
• Lol Nice observation May 5 '20 at 2:43

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.

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.

• You can only use up to 4 fours. May 22 '20 at 17:52
• 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. May 23 '20 at 23:05
• Updated the answer May 24 '20 at 4:19

3.160964... in 4 operations, score 0.42820978

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

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

• It seems sin and ln and log with no explicit base are not legal. May 5 '20 at 3:24
• @msh210 yeah probably May 5 '20 at 3:28
• @Ankit indeed they are not. May 5 '20 at 3:32
• but can you do log base 4? Jul 21 '20 at 12:25

This isn't legal, but

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

with a score of $$+\infty$$

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

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

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

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

Second answer, got it to 3.18 with 5 operations:

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

Score = 0.276