53
$\begingroup$

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.

$$\begin{matrix} \underline{\text{Operations}} & \underline{\text{Score}} & \underline{\text{User}}\\ 1 & 0.864669301 & \text{pacoverflow}\\ 2 & 1.272568270 & \text{pacoverflow}\\ 3 & 1.501203245 & \text{Ben Frankel}\\ 4 & 2.254197410 & \text{Ben Frankel}\\ 5 & 2.286460415 & \text{Lynn}\\ 6 & 2.713605107 & \text{Lynn}\\ 7 & 2.151734961 & \text{Lynn}\\ 8 & 2.135316968 & \text{Ben Frankel}\\ 9 & 2.063009554 & \text{Ben Frankel}\\ 10 & 2.186087400 & \text{Glen O} \end{matrix}$$ Let me know if I've missed one.

$\endgroup$
  • 7
    $\begingroup$ 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$ $\endgroup$ – Ross Millikan Apr 17 '15 at 16:58
  • 1
    $\begingroup$ 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. $\endgroup$ – leoll2 Apr 17 '15 at 17:51
  • 1
    $\begingroup$ @RossMillikan I think I can top that with A = 12^3^4^5^6^7^8^9 ;-) $\endgroup$ – Mark N Apr 17 '15 at 18:00
  • 7
    $\begingroup$ 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. $\endgroup$ – Lynn Apr 17 '15 at 19:28
  • 1
    $\begingroup$ @MarkN: Yes, I thought about that. I tried $12^{3^{456789}}$ but couldn't evaluate the score. $\endgroup$ – Ross Millikan Apr 17 '15 at 20:43

13 Answers 13

45
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ Very impressive, but isn't that actually closer to -200743.9379? $\endgroup$ – squeamish ossifrage Apr 17 '15 at 21:08
  • 1
    $\begingroup$ Err, I had a little typo there. Should be right now. $\endgroup$ – Lynn Apr 17 '15 at 21:15
  • 1
    $\begingroup$ Ah yes, that's better :-D $\endgroup$ – squeamish ossifrage Apr 17 '15 at 21:18
  • 2
    $\begingroup$ You're missing a zero in your "off by" number. It should be 0.000034... $\endgroup$ – GentlePurpleRain Apr 17 '15 at 21:25
  • 1
    $\begingroup$ 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. $\endgroup$ – Ben Frankel Apr 18 '15 at 22:11
17
$\begingroup$

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)

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Glen O Apr 18 '15 at 10:26
  • $\begingroup$ @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. $\endgroup$ – Ben Frankel Apr 18 '15 at 10:32
  • $\begingroup$ 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. $\endgroup$ – Glen O Apr 18 '15 at 10:37
  • $\begingroup$ +1, I was wondering if there was anything better for n=1,2,3. $\endgroup$ – pacoverflow Apr 18 '15 at 16:51
16
$\begingroup$

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!)!)!)!

$\endgroup$
14
$\begingroup$

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

$\endgroup$
13
$\begingroup$

Score = 1.187987428

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

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

$\endgroup$
11
$\begingroup$

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

$\endgroup$
  • 1
    $\begingroup$ That 10 operation one is extremely cool! $\endgroup$ – Lynn Apr 19 '15 at 16:43
  • $\begingroup$ 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 $\endgroup$ – user477343 Sep 9 '18 at 9:02
10
$\begingroup$

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)

$\endgroup$
3
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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) $\endgroup$ – Glen O Apr 18 '15 at 8:37
  • $\begingroup$ 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. $\endgroup$ – Glen O Apr 18 '15 at 12:18
  • $\begingroup$ @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 :) $\endgroup$ – thepace Apr 19 '15 at 12:15
  • $\begingroup$ 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. $\endgroup$ – Glen O Apr 19 '15 at 13:36
  • $\begingroup$ 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). $\endgroup$ – Glen O Apr 19 '15 at 13:38
1
$\begingroup$

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)

$\endgroup$
  • $\begingroup$ Your second attempt uses exponentiation, which costs 3 operations. So it's actually 12 operations, not 10. $\endgroup$ – Glen O Apr 18 '15 at 9:26
  • $\begingroup$ 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. $\endgroup$ – Glen O Apr 19 '15 at 3:41
0
$\begingroup$

1 operation score 2.2538864...

12 / 3.456789 ≈ π + 0.329837026

$\endgroup$
  • $\begingroup$ The decimal point is not a valid operation, and would have to count as one. $\endgroup$ – boboquack Feb 10 '18 at 23:40
  • $\begingroup$ @boboquack There is no such claim on the question. The question does not forbid non natural numbers. $\endgroup$ – Bruno Costa Feb 10 '18 at 23:47
  • 2
    $\begingroup$ "Your job is to approximate π 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)." Since the decimal point is between two of your digits, it must be an operator, as that is the only thing you are allowed to do to the digits. However, it is not listed as one of the permitted operators, therefore it must be forbidden. $\endgroup$ – boboquack Feb 11 '18 at 0:08
  • $\begingroup$ What I am arguing is that the number1.234 has the digits 1 to 4 in sequence and doesn't have any operator. There is no operator between number 1 and 2 since 1 and 2 are part of the same number. $\endgroup$ – Bruno Costa Feb 11 '18 at 0:18
  • $\begingroup$ Then under what condition are you allowed to add a decimal point? $\endgroup$ – boboquack Feb 11 '18 at 0:42
0
$\begingroup$

1st ops:

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

$\endgroup$
  • 3
    $\begingroup$ 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. $\endgroup$ – Rubio Feb 11 '18 at 19:33
-2
$\begingroup$

 14 Operations - score 0.16088866261

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

$\endgroup$
  • 8
    $\begingroup$ 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.. $\endgroup$ – Kevin Cruijssen Jun 8 '16 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.