79

There have been two other questions here and here that are similar to this one, but this changes the rules up a little.

Your job is to approximate $\pi$ using the sequence of digits (in order):

1 2 3 4 5 6 7 8 9

with operators inserted between them (permitted operators listed below). You are to find the best approximation to $\pi$ that you can using the allowed operators and the numbers listed in order as they appear above. You must use all nine digits.

Your score is given by $$ \frac{-\ln\left|1-A/\pi\right|}{n_{ops}} = \frac{\ln\left|\frac{\pi}{\pi-A}\right|}{n_{ops}} $$ where $n_{ops}$ is the number of operators you used, and $A$ is your approximation. So if you managed to get $A=22/7$ and required three operations, then we have $\ln\left|1-A/\pi\right|\approx−7.818$, and so your score would be approximately $2.606$. Larger scores are better.

You may use parentheses, but only to control order of operations - other uses such as binomials or Jacobi symbols are not valid.

Permitted operations:

  • $+$ (plus): standard addition of real or complex numbers.
  • $-$ (minus): standard subtraction of real or complex numbers, or unary negation of real or complex numbers.
  • $\times$ (times): standard multiplication of real or complex numbers. Implied multiplication (e.g. $(1+2)3$) counts as an operation.
  • $/$ or $\div$ (divide): standard division of real or complex numbers (allows division by positive or negative infinity to get zero).
  • $\sqrt{ }$ (square root): standard principle square root of real or complex numbers, with second root (negative if number being square rooted is positive) allowed as $\sqrt[-]{}$ as a single operation.
  • $!$ (factorial): standard factorial for non-negative integer values (i.e. natural numbers) only, cannot be applied to non-natural numbers.
  • $|.|$ (absolute value): standard absolute value for real or complex numbers, equal to $\sqrt{a^2+b^2}$ if the number is of the form $a+bi$ with $a$ and $b$ real and $i$ being the imaginary number.
  • $\lfloor.\rfloor$ (floor): standard round-downwards to integer for real numbers only.
  • $\lceil.\rceil$ (ceil): standard round-upwards to integer for real numbers only.

Permitted operations but counting as three operations:

  • $^\wedge$ (exponentiation): standard exponentiation of real and complex numbers with integer powers only. Note that $0^0$ cannot be used.
  • $\ln(.)$ (natural log): standard natural logarithm of positive real numbers only.

Note the restrictions on some operators - This is primarily to ensure that exact values of $\pi$ cannot be obtained, as well as ensuring that the operations are well-defined.

If you feel that a reasonable operation has been left out, mention it in the comments and I may add it.

Note: There must be at least 1 operation in your answer!

I will also upvote people who obtain high accuracy using many operations, in addition to those who get a good score, and encourage others to do likewise.

I'm also going to keep track of the best answers for each number of operations, up to 10.

Operations Score User
1 0.864669301 pacoverflow
2 1.272568270 pacoverflow
3 1.501203245 Ben Frankel
4 2.254197410 Ben Frankel
5 2.286460415 Lynn
6 2.713605107 Lynn
7 2.151734961 Lynn
8 2.135316968 Ben Frankel
9 2.063009554 Ben Frankel
10 2.186087400 Glen O

Let me know if I've missed one.

bobble
  • 10,245
  • 4
  • 32
  • 80
Glen O
  • 5,033
  • 1
  • 16
  • 31
  • 11
    I think you should review your scoring algorithm. If I submit $A=123456789$ with no operations I get an infinite score. If that is not allowed, I could do $A=12^{3456789}$ and get a score a little over $2.86 \cdot 10^6$ – Ross Millikan Apr 17 '15 at 16:58
  • 1
    I felt free to add a condition to the problem: at least one operation is required! This is to prevent 0 operation from being the best answer. If you don't agree with my edit, simply remove that condition and I'll be happy as well. – leoll2 Apr 17 '15 at 17:51
  • 1
    @RossMillikan I think I can top that with A = 12^3^4^5^6^7^8^9 ;-) – Mark N Apr 17 '15 at 18:00
  • The formula must be definitely rewritten. I suggest the minimum value of n/ln(1-abs((x-pi)/pi)) or the maximum value of n*ln(1-abs((x-pi)/pi)) 0 operation still forbidden. – leoll2 Apr 17 '15 at 18:05
  • 7
    You definitely want $-\ln|\dots|$, not $|\ln|\dots||$. The latter bounces off the y axis and goes back up to infinity when you're really far off. – Lynn Apr 17 '15 at 19:28
  • Are decimal points allowed in concatenation? – Steven Stadnicki Apr 17 '15 at 19:48
  • o wow, i never expected to find this level math in a question, i've seen greatnproofs but this is so well define. I'm actually excited about this, ye nerd much, but still xD great one :) – Vincent Apr 17 '15 at 20:08
  • 1
    @MarkN: Yes, I thought about that. I tried $12^{3^{456789}}$ but couldn't evaluate the score. – Ross Millikan Apr 17 '15 at 20:43
  • 1
    Some people are right that I overlooked a few issues. First one leoll2 corrected him for, and I thank him for that. My scoring system was intended to find, essentially, how many digits of accuracy were obtained. Now that I see the flaw, it's easy enough to correct - Mauris Van Hauwe identified the option. I'll update the question. – Glen O Apr 18 '15 at 03:23
  • I've also edited in that very good approximations requiring a lot of operations will still get an upvote from me, even if the actual score isn't high. Just in case somebody finds a really incredible one. – Glen O Apr 18 '15 at 03:29
  • Someone has added a solution involving decimals (as in, .6 in the calculation). Now, they weren't in order anyway, but how do people feel about the question of decimals? Shall we allow them, or not? – Glen O Apr 19 '15 at 08:48
  • 1
    A decimal, if allowed, should probably count as at least one operator, since it can be considered a division by some power of 10. – pacoverflow Apr 19 '15 at 18:48
  • All $n_{\mathrm{ops}}$ from 4 to 10 now have a score of 2 or higher! – Ben Frankel Apr 20 '15 at 12:28
  • 1
    @BenFrankel I have brute-forced the 1-, 2-, and 3-op answers, and found that they are all optimal (without factorials.) – LegionMammal978 Oct 05 '15 at 21:26
  • 1
    @LegionMammal978, Oh, that's good to know. All of my answers through 5 are optimal in the set of operations excluding factorial, absolute value, floor/ceil, exponentiation, and logarithm. My program actually found a slightly better result for 8 operations, but it was so slight that I felt like it wasn't worth resurfacing this thread over (and now the result is lost). – Ben Frankel Oct 05 '15 at 22:45
  • Below is one I discovered online, but is it allowed?

    $$\pi \approx 2^{5^{.4}} - .6 - \bigg(\frac{.3^9}{7}\bigg)^{.8^{.1}}$$

    – Mr Pie Nov 18 '17 at 23:52
  • @user477343 - unfortunately, as the digits are not in order (and the decimal places aren't really allowed anyway), it doesn't satisfy the requirements... but it's still a pretty nice formula. If we ignore the decimals and the incorrect order, it would have a score of about 1.62, which isn't bad. – Glen O Jan 11 '18 at 16:26
  • I don't know if it's going to be useful but maybe you could allow concatenation. 1 ... 2 = 12 – Bruno Costa Feb 10 '18 at 23:02
  • Another useful operation could be the modulo operation 13 % 5 = 3 – Bruno Costa Feb 10 '18 at 23:42
  • @BrunoCosta - are you suggesting allowing concatenation after other operations, like "(1+2)...(3+4) = 37"? If so, I think that's too difficult to reasonably define properly and keep fair. If it's just for digits (1...2 = 12), it's already available and free to do. Modulo is interesting, but also difficult to define fairly. Since this is puzzling rather than codegolf or another such SE, I think I'd rather not add modulo to it. – Glen O Feb 16 '18 at 03:31
  • @GlenO I don't really understand what you mean by keeping things fair since both operations are well defined mathematically, you don't have to define them yourself. The fairness on my perspective comes from the fact that anyone that is able to understand and use the operations to their advantage will do so. – Bruno Costa Feb 16 '18 at 15:06
  • Since there are no restrictions on your question (you only mention such restriction on the comments) about using rational numbers maybe you should be including the operation e(+/-)x = 10^x as well. – Bruno Costa Feb 16 '18 at 15:26
  • @BrunoCosta - it's difficult to define fairly because you have to be able to determine how the concatenation occurs, for example can you concatenate 10.3 with 7 to get 10.37? What happens if you try to concatenate 10.3 with 7.1? What happens if you try to concatenate 1/3 with 5? Can you concatenate 10 with 3 to get 10.03 (since 10=10.0)? It's just too complicated, in my view. – Glen O Feb 17 '18 at 04:19
  • @BrunoCosta - as for the order of magnitude operation... I can't see a scenario in which that would be useful, since you'd have to at least consider it an operation that counts as 3 ops, otherwise it's unbalanced compared with the exponentiation operation. Besides, I'd call the "e" more like a shorthand for "x10^", and thus you're effectively adding in another two digits into the expression. The permissible operations aren't just "operations that anyone would understand", but "standard operations" (5e7 is just a notation, not an operation). – Glen O Feb 17 '18 at 04:25
  • @BrunoCosta - I'm not sure what you mean about "no restrictions... about using rational numbers" - I'm quite explicit about permissible numbers and operations in the question. Someone submitted an answer with decimals, so I asked how people felt about the decimal place "operation" during concatenation of digits... and nobody gave a reason to include it, so it remains an invalid "operation". I'm not sure how it can be any clearer than I've made it. – Glen O Feb 17 '18 at 04:29
  • Fun useful approximation (just random): $$\large\pi^3\simeq \frac{31}{1-\dfrac{12}{39^3-40}}$$ – Mr Pie Sep 09 '18 at 08:51
  • (-1+23)÷7, three operations, theoretical score 2.606, but is missing digits so is not competing. – Cœur Feb 28 '19 at 15:00
  • I once asked a question that asks for EXACTLY pi. – Scratch---Cat Nov 14 '19 at 11:48
  • 4
    I’m voting to close this question because open-ended puzzles are off-topic as of May 2019 – bobble Aug 05 '21 at 03:56

15 Answers15

59

4 ops = 1.9934200404 points:

$1+2+34 \div \sqrt{56789} = 3.1426746469\dots$

Off by 0.00108199.

5 ops = 2.2864604146 points:

$\sqrt{12}-34\cdot \sqrt{56} \div 789 = 3.1416267073\dots$

Off by 0.0000340537.

6 ops = 2.7136051067 points:

$(1+(23+4+5)\div 678)\cdot\sqrt 9 = \frac{355}{113} = 3.14159292035 \dots$

Off by only 0.000000266764(!)

Now we can keep taking square roots of 1 in this expression to get a lower score bound for $n$ operations where $n \geq 6$, namely: $$s_n = -\ln \left( \frac{ 355/113 } \pi - 1 \right) / n$$

Which yields the results:

 7 ops = 2.3259472344 points
 8 ops = 2.0352038301 points
 9 ops = 1.8090700712 points
10 ops = 1.6281630641 points

Oh, and to demonstrate the restrictions in the OP -- if complex logarithms were allowed, I could write $$\ln(-1) \div \sqrt{\lfloor -2/3456789 \rfloor} = i\pi/i = \pi.$$

EDIT: for 7 ops, I found

$$\sqrt{\sqrt{123-\sqrt{4!+5678/9}}}=3.14159355670578 \dots$$

scoring 2.1517349612 points, beating Ben Frankel's score.

Lynn
  • 2,485
  • 11
  • 21
  • 1
    Very impressive, but isn't that actually closer to -200743.9379? – r3mainer Apr 17 '15 at 21:08
  • 1
    Err, I had a little typo there. Should be right now. – Lynn Apr 17 '15 at 21:15
  • 1
    Ah yes, that's better :-D – r3mainer Apr 17 '15 at 21:18
  • 2
    You're missing a zero in your "off by" number. It should be 0.000034... – GentlePurpleRain Apr 17 '15 at 21:25
  • Very nice solution. While I'm not going to award the extra +15 yet, if I could upvote you twice I would, for finding a way to achieve one of the normal rational approximation. – Glen O Apr 18 '15 at 04:09
  • @GlenO: I've added more high scores, some based on my solution for n=6. – Lynn Apr 18 '15 at 14:16
  • Your score for 6 operations is rather close to $e$... hmm... – Ben Frankel Apr 18 '15 at 14:50
  • Regarding the restriction on $\ln$, that's exactly why I ruled it out - it's easy to get $\pi$ exactly if we allow complex numbers when applying it. Anyway, I'm certainly updating results, although I think I'll establish a principle that operations that don't change the result (like square-rooting 1) won't count for the table I'm tracking in the question - just to keep things interesting. – Glen O Apr 18 '15 at 15:09
  • 1
    I found a smaller error using 9 operations, thus passing your lower bound from 9 and on. I can use $n = |n|$ wherever to add operations. – Ben Frankel Apr 18 '15 at 22:11
  • I improved a bit on Ben Frankel's score for 7 operations. – Lynn Apr 19 '15 at 19:28
  • I've accepted this answer, as it doesn't look like anybody is going to beat it. If someone does, I'll be interested to see how. – Glen O Apr 29 '15 at 13:34
  • @GlenO The 4- and 5- operation answers cannot be beaten without factorials. – LegionMammal978 Oct 06 '15 at 10:07
22

I wrote a program that approximates an inputted value using inputted digits by checking increasingly complex expressions. These are the best results so far:


10: Score - 1.82589426:

$\sqrt{\sqrt{12\cdot\frac{\sqrt{34}-\sqrt{5}}{6}-7}+\sqrt{89}} \approx 3.141592691$

Accurate to 8 digits.


9: Score - 2.06300955:

$\sqrt{1+\sqrt{\sqrt{2}\cdot\frac{3}{45-\sqrt{6}}\cdot789}} \approx 3.141592626$

Accurate to 8 digits.


8: Score - 2.13531697:

$\sqrt{1+\frac{\sqrt{23}-\sqrt{4\cdot56}}{78}+9} \approx 3.141592773$

Accurate to 7 digits.


7: Score - 2.06840056:

$\sqrt{123\frac{\sqrt{\sqrt{4}+56-7}}{89}} \approx 3.1415943$

Accurate to 6 digits.


6: Score - 2.14803568:

$123\times(\sqrt{4}+\sqrt{5/67})/89 \approx 3.141585$

Accurate to 5 digits.


5: Score - 2.28646041:

$\sqrt{12}-34\cdot\frac{\sqrt{56}}{789} \approx 3.141627$

Accurate to 4 digits. (Mauris reached this first)


4: Score - 2.25419741:

$\sqrt{\frac{1234}{56+78-9}} \approx 3.141974$

Accurate to 4 digits.


3: Score - 1.50120325:

$\frac{1234}{567}-8+9 \approx 3.176367$

Accurate to 2 digits.


2: Score - 1.27256827:

$\frac{1}{2345}\cdot6789 \approx 2.895096$

Error of ~0.25. (pacoverflow reached this first)


1: Score - 0.86466930:

$\frac{12345}{6789} \approx 1.818383$

Error of ~1.3. (pacoverflow reached this first)

Ben Frankel
  • 3,648
  • 19
  • 33
  • Your calculation seems to be backwards, in terms of score. The score is 0.651964286 (which is the inverse of the number you gave). I think your computer code might have had a bug in it. – Glen O Apr 18 '15 at 10:26
  • @GlenO, are you sure? I've tried a few times to recalculate the score of 3.17 with 3 ops but I get the same result. EDIT: Also if pacoverflow is off by 0.16 with 3 ops and he gets ~0.9 score then I am off by 0.035 so I shouldn't get ~0.65 score. – Ben Frankel Apr 18 '15 at 10:32
  • Oops, just noticed I used "log" on my PC's calculator, assuming it would be ln. It's log_10. So you're right. Sorry about that. – Glen O Apr 18 '15 at 10:37
  • +1, I was wondering if there was anything better for n=1,2,3. – pacoverflow Apr 18 '15 at 16:51
18

This one isn't in order, but I can't resist offering it up anyway:

$\dfrac{\ln((8\times5!)^3+(2\times\sqrt{9})!+4!)}{\sqrt{7\times6+1}}$

14 ops, but off by just $4\times 10^{-14}$! The catch here is:

43 (which shows up in the denominator) is a so-called Heegner Number, so $e^{\pi\sqrt{43}}$ is very close to an integer - specifically, to $960^3+744$.

Steven Stadnicki
  • 2,491
  • 15
  • 28
18

Score = 2,176,716,257 (That's not a typo)

I think you want to fix your scoring formula.

Here's my attempt:

123456789!

And here's the proof of my score:

Thank you, Wolfram Alpha
In the screenshot, note that $log$ denotes the natural log as explained on the right.
Screenshot

If you don't fix the formula, you run into a problem with infinite scores because...

Adding factorials makes $n_{ops}$ grow linearly but $A$ grow at a much faster rate.
My next guesses would all yield higher scores:
(123456789!)!
((123456789!)!)!
(((123456789!)!)!)!

Engineer Toast
  • 17,506
  • 1
  • 49
  • 152
15

Score = 1.187987428

Here's my first effort, off by 0.00827 with 5 operators:

$$\sqrt{\sqrt{(1234 \times 56\ /\ 78)\ /\ 9}} = 3.14986$$

Engineer Toast
  • 17,506
  • 1
  • 49
  • 152
r3mainer
  • 9,671
  • 4
  • 40
  • 45
14

I figured I'd have a go at it myself. Here's an approximation I found:

$\sqrt{\sqrt{123+4-5\times6+\frac7{8+9}}} \approx 3.14161421087308 \approx \pi+0.000021557$

with 8 operations. Score = 1.486190839099123

UPDATE: here's a new one:

$\sqrt{\sqrt{\frac12+\frac{3!+4}{5+6}+7+89}}\approx 3.141592652582646 \approx \pi - 0.000000001007147$

with 10 operations. Score = 2.186087400111085. This one is based on an expression given by Ramanujan, $\pi\approx\sqrt[4]{\frac{2143}{22}}$.

Glen O
  • 5,033
  • 1
  • 16
  • 31
  • 1
    That 10 operation one is extremely cool! – Lynn Apr 19 '15 at 16:43
  • Also, regarding Ramanujan's approximation, it can also be written like this: $$\large\pi\approx \sqrt{\sqrt{3^4+\frac{19^2}{78-56}}}$$ which uses all the digits from $1$ to $9$ too (but not in order). That is a special approximation :D – Mr Pie Sep 09 '18 at 09:02
14

I believe this is the highest score possible with 100 or fewer operations:

99 operations; Score > $10^{10^{10^{10^{10^{10^{10^{10^{10^{10^{10}}}}}}}}}}$

$$ \left(\left[1 - \left(2\times\log\left\lceil\sqrt{3!!!!!!!!!!!!!}\right\rceil -\sqrt{4}\right)\div\left(\left\lfloor\sqrt{\left\lceil\sqrt{5}\right\rceil !!!!!!!!!!!!!}\right\rfloor!\right)\right]^{\left\lceil\sqrt{6!!!!!!!!!!!!}\right\rceil !} \div\left\lfloor\sqrt{7}\right\rfloor\right)\times\left\lceil\sqrt{\left\lceil\sqrt{8}\right\rceil !!!!!!!!!!!!!}\right\rceil!\times\left\lfloor\sqrt{(\sqrt{9}) !!!!!!!!!!!!!}\right\rfloor!\approx \pi + \frac{1}{2\sqrt{3!!!!!!!!!!!!!}}$$ Those long strings of factorials represent iterated factorials, not double factorials or anything weird like that.

As the rather absurd score above suggests, arbitrarily large scores are possible. In particular, we can construct a sequence of approximations $A_k$ that converge extremely rapidly to $\pi$, giving scores that go diverge rapidly infinity. (See Rex Eupseiphos's answer for the first few terms of the sequence to see how fast it approximates $\pi$).

Let $x!_k$ represent $k$ iterations of the factorial, e.g. $3!_2 = (3!)!=6!= 720$. According to the rules of the puzzle, using $!_k$ requires $k$ operations. Then we have $$ \pi \approx A_k =\left(\left[1 - \left(2\times\log\left\lceil\sqrt{3!_k}\right\rceil -\sqrt{4}\right)\div\left(\left\lfloor\sqrt{\left\lceil\sqrt{5}\right\rceil !_k}\right\rfloor!\right)\right]^{\left\lceil\sqrt{6!_{k-1}}\right\rceil !} \div\left\lfloor\sqrt{7}\right\rfloor\right)\times\left\lceil\sqrt{\left\lceil\sqrt{8}\right\rceil!_k}\right\rceil!\times\left\lfloor\sqrt{(\sqrt{9})!_k}\right\rfloor!$$ has $n_{ops} = 34 + 5k$. The score of $A_k$ goes to infinity as $k$ goes to infinity. We have bounds $$\pi < A_k < \pi\cdot\exp\left(\frac1{6\cdot\left\lceil\sqrt{3!_k}\right\rceil}\right)$$ which implies that the score of $A_k$ is bounded below by $$ \mathrm{score}(A_k) = -\frac{\ln\left(\frac{A}{\pi} -1\right)}{34+5k} > \frac{\log\left(3\cdot\left\lceil\sqrt{3!_k}\right\rceil\right)}{34+5k}$$

Explanation and proof:

Stirling's approximation tells us that $$\pi = \lim_{n\rightarrow\infty} \frac{n!^2}{2 n \left(\frac{n}{e}\right)^{2n}}$$ This is the main principle used. To prove the bounds of $A_k$ claimed above, we use some easy asymptotic bounds. For $\frac{x}{m} > -1$: $$\left(1 + \frac{x}{m}\right)^m = \exp\left(m\log\left(1 + \frac{x}{m}\right)\right) < \exp\left(m\cdot\frac{x}{m}\right) = \exp(x)$$ Slightly more difficult is a lower bound on $\left(1 + \frac{x}{m}\right)^m$, but using the fact that $\log(z) > z-1 - (z-1)^2$ for $1>z > 0.3$ (see WolframAlpha) we can see that $$\left(1+\frac{x}{m}\right)^m > \exp\left(x - \frac{x^2}{m}\right)$$ Furthermore, we use the refinement of Stirling's approximation: $$\pi\cdot\exp\left(\frac2{12n+1}\right)<\frac{n!^2}{2n\left(\frac{n}{e}\right)^{2n}} < \pi\cdot\exp\left(\frac1{6n}\right)$$ This is all we need. Let $u_k = \left\lceil\sqrt{3!_k}\right\rceil$. Since $n!$ is never a perfect square for $n>1$ (this follow's from Bertrand's Postulate), we also have $\left\lfloor\sqrt{3!_k}\right\rfloor = u_k-1$. This allows us to simplify $A_k$: \begin{eqnarray}A_k &=&\left(\left[1 - \left(2\times\log\left\lceil\sqrt{3!_k}\right\rceil -\sqrt{4}\right)\div\left(\left\lfloor\sqrt{\left\lceil\sqrt{5}\right\rceil !_k}\right\rfloor!\right)\right]^{\left\lceil\sqrt{6!_{k-1}}\right\rceil !} \div\left\lfloor\sqrt{7}\right\rfloor\right)\times\left\lceil\sqrt{\left\lceil\sqrt{8}\right\rceil!_k}\right\rceil!\times\left\lfloor\sqrt{(\sqrt{9})!_k}\right\rfloor!\\&=&\frac{\left[1 - \frac{2\times\log\left\lceil\sqrt{3!_k}\right\rceil -\sqrt{4}}{\left\lfloor\sqrt{\left\lceil\sqrt{5}\right\rceil !_k}\right\rfloor!}\right]^{\left\lceil\sqrt{6!_{k-1}}\right\rceil !} \times\left\lceil\sqrt{\left\lceil\sqrt{8}\right\rceil!_k}\right\rceil!\times\left\lfloor\sqrt{(\sqrt{9})!_k}\right\rfloor!}{\left\lfloor\sqrt{7}\right\rfloor}\\&=&\frac{\left[1 - \frac{2\times\log\left\lceil\sqrt{3!_k}\right\rceil - 2}{\left\lfloor\sqrt{3 !_k}\right\rfloor!}\right]^{\left\lceil\sqrt{(3!)!_{k-1}}\right\rceil !} \times\left\lceil\sqrt{3!_k}\right\rceil!\times\left\lfloor\sqrt{3!_k}\right\rfloor!}{2}\\&=&\frac{\left[1 - \frac{2\log u_k - 2}{(u_k - 1)!}\right]^{u_k !} u_k!(u_k - 1)!}{2}\\&=&\frac{\left[1 + \frac{2u_k(1 - \log u_k)}{u_k!}\right]^{u_k !} u_k!^2}{2u_k}\end{eqnarray} This final formula allows us to get an upper bound for $A_k$, assuming $2u_k(1 - \log u_k) > - u_k!$, which is true for all $k\ge0$.: \begin{eqnarray}A_k &=& \frac{\left(1 + \frac{2u_k(1 - \log u_k)}{u_k!}\right)^{u_k !} u_k!^2}{2u_k} < \frac{\exp(2u_k(1 - \log u_k)) u_k!^2}{2u_k}\\&=&\frac{u_k!^2}{2u_k\left(\frac{u_k}{e}\right)^{2u_k}}<\pi\cdot\exp\left(\frac{1}{6 u_k}\right)\end{eqnarray} To find a lower bound, because $1>1+\frac{2u_k(1 - \log u_k)}{u_k!} > 0.3$ for all $k\ge 1$, we have \begin{eqnarray}A_k &=& \frac{\left(1 + \frac{2u_k(1 - \log u_k)}{u_k!}\right)^{u_k !} u_k!^2}{2u_k} \\&>& \exp\left(-\frac{(2u_k(1 - \log u_k))^2}{u_k!}\right) \frac{u_k!^2}{2u_k\left(\frac{u_k}{e}\right)^{2u_k}}\\&>&\pi\cdot\exp\left(-\frac{(2u_k(1 - \log u_k))^2}{u_k!}\right)\exp\left(\frac{2}{12 u_k + 1}\right)\\&=&\pi\cdot\exp\left(\frac{2}{12 u_k + 1} - \frac{(2u_k(1 - \log u_k))^2}{u_k!}\right)\end{eqnarray} The part inside the exponential is positive for all $k \ge 2$. Computationally, $A_k$ can be seen to be larger than $\pi$ for $k=0,1$, so we have the desired bounds for all $k$: $$\pi < A_k < \pi\cdot\exp\left(\frac1{6\cdot\left\lceil\sqrt{3!_k}\right\rceil}\right)$$ For $k \ge 2$, we have the more precise lower bound $$A_k > \pi\cdot\exp\left(\frac{2}{12 u_k + 1} - \frac{(2u_k(1 - \log u_k))^2}{u_k!}\right)$$

Calculation of the score:

The answer at the top is $A_{13}$, which will be off by about $\frac{1}{\sqrt{3!_{13}}}$ and has $34 + 5\cdot 13 = 99$ operations. From the above calculation of score, we know that its score is at least $$ \frac{1}{99}\log\left(3\cdot\sqrt{3!_{13}}\right) > 3!_{12}$$ Since $x! > 10^x$ for $x>24$, and $(3!)! = 720 > 24$, we can conclude that a power tower of $11$ tens is a lower bound for the score. WolframAlpha gives this approximation for $3!_{12}$: $$10^{10^{10^{10^{10^{10^{10^{10^{10^{10^{1749.66}}}}}}}}}} $$

12

Attempt with 4 operators: (Score = 0.978898573)

$$\sqrt{\sqrt{\sqrt{\sqrt{123456789}}}} = 3.20420$$ (off by 0.06261)

Attempt with 3 operators: (Score = 0.991181027)

(1+2345+6)/789 = 2.98098 (off by 0.16060)

Attempt with 2 operators: (Score = 1.272568270)

(1/2345)*6789 = 2.89509 (off by 0.24649)

Attempt with 1 operator: (Score = 0.864669301)

12345/6789 = 1.81838 (off by 1.32320)

pacoverflow
  • 15,204
  • 2
  • 55
  • 94
6

Slightly simplifying Dark Malthorp's remarkable solution, we get: $$\pi \approx A_k = \left[1 - \left( 2 \cdot \log\lceil \sqrt{3!_k}\rceil + \sqrt{4}\right)\div(\lfloor\sqrt{\lceil\sqrt 5\rceil!_k}\rfloor!)\right]^{\lceil\sqrt{6!_{k-1}}\rceil!} \div \lfloor\sqrt 7\rfloor \cdot \lceil\sqrt{\lceil\sqrt 8\rceil!_k} \rceil!\cdot \lfloor\sqrt{\sqrt{9}!_k}\rfloor!$$ which has $34+5k$ operations. Also, the approximation is bounded by $\pi < A_k < \pi\cdot(1+1/6\sqrt{3!_k})$, which is an astoundingly close approximation to $\pi$ when $k \geq 3$.

For convenience for reading and for calculating (with small k), the formula for can be simplified to: $$A = \frac{\left[1 - \frac{2\left(\log{n} - 1)\right)}{(n-1)!} \right]^{n!}}{2} n! (n-1)!$$ where $n = \lceil\sqrt{3!_k}\rceil$

39 operations ($k = 1$):
We have $n = 3$, and $$A = \left[1 - \left( 2 \cdot \log\lceil \sqrt{3!}\rceil + \sqrt{4}\right)\div(\lfloor\sqrt{\lceil\sqrt 5\rceil!}\rfloor!)\right]^{\lceil\sqrt{6}\rceil!} \div \lfloor\sqrt 7\rfloor \cdot \lceil\sqrt{\lceil\sqrt 8\rceil!} \rceil!\cdot \lfloor\sqrt{\sqrt{9}!}\rfloor! = 3.21826$$ for a score of 0.0952...not particularly impressive. However, it does validate the bounds on the estimate: $$\pi < A_1 = 3.21826 < 3.355 = \pi\cdot\left(1+\frac{1}{6\sqrt 3!}\right)$$

44 operations ($k = 2$):
We have $n = \lceil\sqrt{3!!}\rceil = 27$. The calculation gets much more difficult than with $k=1$, but it's still tractable. I did it using MPFR (Multiple Precision Floating-Point Reliably) in R:

1 - (2*log(mpfr(27,200))-2)/factorial(mpfr(26,200)))^factorial(mpfr(27,200))*   
factorial(mpfr(27, 200)) * factorial(mpfr(26, 200))/2

which gives $$A = \left[1 - \left( 2 \cdot \log\lceil \sqrt{3!!}\rceil + \sqrt{4}\right)\div(\lfloor\sqrt{\lceil\sqrt 5\rceil!!}\rfloor!)\right]^{\lceil\sqrt{6!}\rceil!}\div \lfloor\sqrt 7\rfloor \cdot \lceil\sqrt{\lceil\sqrt 8\rceil!!} \rceil!\cdot \lfloor\sqrt{\sqrt{9}!!}\rfloor! = 3.16104$$ for a score of 0.1156...still not very impressive, but provides another validation of the bounds: $$\pi < A_2 = 3.16104 < 3.16111 = \pi\cdot\left(1+\frac{1}{6\sqrt{3!!}}\right)$$

49 operations ($k = 3$): With $k=3$, the direct calculations become intractable because $n = \lceil\sqrt{3!!!}\rceil \approx 1.61\times 10^{873}$, which we'd need to take the factorial of and then put it in the exponent--not going to happen. However, Dark Malthorp's proof gives valid bounds on the approximation that are not impossible to calculate for $k=3$: $$\pi < A_3 < \pi\cdot\left(1+\frac{1}{6\sqrt{3!!!}}\right)$$ which gives $$\pi < A = \left[1 - \left( 2 \cdot \log\lceil \sqrt{3!!!}\rceil + \sqrt{4}\right)\div(\lfloor\sqrt{\lceil\sqrt 5\rceil!!!}\rfloor!)\right]^{\lceil\sqrt{6!!}\rceil!} \div \lfloor\sqrt 7\rfloor \cdot \lceil\sqrt{\lceil\sqrt 8\rceil!!!} \rceil!\cdot \lfloor\sqrt{\sqrt{9}!!!}\rfloor! = 3.1415926535897932384...\approx \pi + 10^{-873}$$ accurate to nearly 1000 digits. This gives a score of around 41.07.

3

Not sure if decimal are allowed, but here's my attempt

1 operator, score 1.1765956249508713525610395676804...

$$123.4/56.789 \approx 2.17295603 \approx \pi - 0.96863662$$

3 operator, score 2.06714352383430453303221463889...

$$(1234/56)/(\lfloor7.89\rfloor) \approx 3.14795918 \approx \pi + 0.00636653 $$

boboquack
  • 21,982
  • 1
  • 66
  • 138
wuiyang
  • 303
  • 1
  • 8
2

SCORE: 1.116831135 (7 Ops)

(1-2) * (34-56) / 7 * (-8 + 9) = 22/7

SCORE: 0.977227243 (8 Ops)

((1+2) * 3)/4/(5+6)/7/8/9 = 22/7

SCORE: 1.5636 (5 Ops) Thanks @Glen O.

(⌊1234/56⌋/7)*(-8+9) = 22/7

thepace
  • 2,927
  • 1
  • 13
  • 11
  • I figured I'd give you a nudge towards a further improvement. $\lfloor 1234/56\rfloor = 22$. (for that matter, it's not far from being 22, so you might be able to drop the floor operation and get an even better score) – Glen O Apr 18 '15 at 08:37
  • Also, you've used log_10 rather than ln in your score calculation. Your scores should be 0.977227108 for 8 ops and 1.116830981 for 7 ops. – Glen O Apr 18 '15 at 12:18
  • @Glen O: ln|1−A/π| = -7.818. So the calculation is correct.Right? I used the example in the problem. Also do update my name in the top 10 answers :) – thepace Apr 19 '15 at 12:15
  • That is the correct logarithm. And then you negate it and divide it by the number of operations, giving 1.116831135 for the 7 ops case and 0.977227243 for the 8 ops case. The scores you listed in your answer are the values you get if you use log_10 rather than ln. – Glen O Apr 19 '15 at 13:36
  • And I'm not sure what you mean about the top 10 answers. Perhaps you didn't notice, but it's not a top 10 - it's best answer for each number of operations. The only answer your score beats is the 1 op answer, which obviously your answers aren't (1 op answers, that is). – Glen O Apr 19 '15 at 13:38
  • Thanks Glen.. Got it :) For Ops 7 and 8 , the value is less than the one posted. Right? – thepace Apr 19 '15 at 15:39
  • Yes, your scores are lower than the current best for 7 and 8 ops. – Glen O Apr 20 '15 at 01:05
1

With the incorrect scoring method:

((((12!^3!^4!^5!^6!^7!^8!^9!)!)!)!)!...... resulting in a pi that far..far away but gives the highest of scores!

Second Attempt: 10 operators (Score = 0.524352512)

1/(2^3) + |-4+5-6+7-8+9| = 3.125 (off by 0.01659)

First attempt: 4 operators (Score = 0.665238338)

(1/2)+3-(456/789) = 2.92205 (off by 0.21953)

Mark N
  • 5,868
  • 22
  • 60
  • Your second attempt uses exponentiation, which costs 3 operations. So it's actually 12 operations, not 10. – Glen O Apr 18 '15 at 09:26
  • Following on from my previous comment, you can actually reduce it back to 11 operations by using $2+3!$ (for two operations) instead of 2^3. – Glen O Apr 19 '15 at 03:41
0

(1/2)!³⁺⁴⁻⁵(-6-7+8+9)= π

which I think would give a score of infinity.

risky mysteries
  • 13,072
  • 3
  • 24
  • 96
  • 1
    Unfortunately, the question states that you can only apply factorial to natural numbers, so your answer is invalid. Clever idea though! – HTM Mar 06 '21 at 02:28
  • Oh, well thanks for pointing that out. – Daniel Magee Mar 06 '21 at 04:06
  • Indeed, the restriction on factorial was put in place specifically because of (1/2)! being reasonably interpreted as gamma(3/2). – Glen O Mar 07 '21 at 06:54
0

1st ops:

$1+2-3-4+5-6+7+\sqrt{\sqrt{\sqrt{\sqrt{8+9}}}} = 3.1937216143839002$

Rubio
  • 41,676
  • 6
  • 90
  • 242
Rohit-Pandey
  • 203
  • 1
  • 7
  • 4
    Fixed square root symbols for you, but why is this labeled "1st ops"? There are 12 operations here, and you didn't include your score. – Rubio Feb 11 '18 at 19:33
-4

 14 Operations - score 0.16088866261

$\sqrt((6!)/(8\times5))-(\sqrt(\sqrt(34)-\sqrt(21)))+\ln(\sqrt((9-7)))\approx3.47190671012$

SKr
  • 1
  • 1
  • 10
    I'm not one of the downvoters, but I think you've neglected an important rule of the question that is present in all other answers: the numbers 1 though 9 should be used in that order. In your answer it's 6,8,5,3,4,2,1,9,7 instead of 1,2,3,4,5,6,7,8,9.. – Kevin Cruijssen Jun 08 '16 at 13:11