I ran across this problem in a high school math competition:
"You must use the integers $1$ to $9$ and only addition, subtraction, multiplication, division, and exponentiation to approximate the number $\pi$ as accurately as possible. Each integer must be used at most one time. Parenthesis are able to be used."
I tried writing a program in MATLAB to solve this problem but it was very inefficient (brute-force) and took too long.
What is the correct answer, and how would I figure it out?
EXAMPLE:
$$\pi \approx \frac {(6+8+2^3)} 7 = \frac {22} 7 \approx 3.142857$$
Here are three approximations which I came up with, just by sitting down and "playing" with the numbers (no brute-force algorithm needed):
1.) $\pi \approx 3+\dfrac {(5 \times 7)^{(\large8/9)^4}} {2^6+1} = 3.1415926539$
2.) $\pi \approx \left (\dfrac{3^7} {5+8+9} -2\right)^{1/4} = 3.141592652$
3.) $\pi \approx \dfrac{7^3+2 \times 6} {(8+5) \times 9 - 4} = \dfrac {355} {113} = 3.1415929$
I'm sure that there are other solutions out there, these are just the first that I could think of.