Pi Estimation using Integers 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$$
 A: $$
\frac{71\times5}{63\times2-9-8+4}=\frac{355}{113}=3.141592\color{#A0A0A0}{92}
$$
A: Here are some more formulas using Ramanujan's approximation.
$$ \left(\left(\frac{\frac{{3}^{8}}{\left(9 + 7\right) - 5}}{6}\right) - 2\right)^{1/4}$$
$$ \left(\left(\frac{\frac{{3}^{8}}{9 + 2}}{6}\right) - 7 + 5\right)^{1/4} $$
$$ \left(\frac{\left(\left(\frac{{3}^{8}}{9 + 2}\right) - 7\right) - 5}{6}\right)^{1/4}$$
A: 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.
A: I modified my program to include rationals with small denominators as intermediate values.
Using the approximation $$\pi\approx \sqrt[4]{\frac{2143}{22}} \approx
3.14159265$$ 
which also has nine decimal places and is apparently due to Ramanujan (Wikipedia),
we get the result
$$ \left(\left(\frac{{3}^{6}}{7 + \frac{8 - 5}{9}}\right) - 2\right)^{1/4}$$
This is a variation of the expression shown in the OP, but computed with limited human intervention.
If we permit concatenation of digits, we get the following pretty result:
$$\left(97 + 3 \times \left(\frac{6}{52 - 8}\right)\right)^{1/4}.$$
Another one of this type is 
$$\left(3 + 96 - \left(\frac{5}{2 + \frac{8}{7}}\right)\right)^{1/4}.$$
More formulas of this type are
$$\left(97 + \frac{\frac{3}{5 - \left(\frac{8}{6}\right)}}{2}\right)^{1/4} $$
$$\left(98 - \left(\frac{\frac{7}{2} + 3}{6 + 5}\right)\right)^{1/4} $$
$$\left(\left(\frac{{\left(8 - 5\right)}^{6}}{\frac{3}{9} + 7}\right) - 2\right)^{1/4}$$
The code for the modified algorithm follows:

with(combinat,powerset);

maxnumer := 2200;
denomset := {1, 2, 3, 5, 11, 22};

maxv_comp_const :=
proc()
    local s, d;

    s:= {};

    for d in denomset do
        s := s union {seq(k/d, k=0..maxnumer)};
    od;

    nops(s);
end proc;

maxcount := maxv_comp_const();

repr :=
proc(s)
    local d, f, dstr, fstr, dtstr, ftstr, res, aprob, bprob, x, y,
    leftset, rightset, check, typeset;
    global maxcount;
    option remember;

    res := table();

    if nops(s) = 1 then
        d := op(1,s);
        res[d] := [d, sprintf("%d", d), sprintf("%d", d)];

        return op(res);
    fi;

    check :=
    proc(val)
        global maxnumer, denomset;

        if not(type(val, rational)) then return false; fi;

        if val<0 then return false; fi;
        if type(res[val], list) then return false; fi;

        if numer(val)<=maxnumer and denom(val) in denomset then
            return true
        fi;

        return false;
    end proc;

    typeset :=
    proc(dtstr, what, ftstr)
        local pard, parf;

        if length(dtstr)=1 then
            pard := dtstr;
        else
            pard := sprintf("\\left(%s\\right)", dtstr);
        fi;
        if length(ftstr)=1 then
            parf := ftstr;
        else
            parf := sprintf("\\left(%s\\right)", ftstr);
        fi;

        if evalb(what = "+") then
            return sprintf("%s + %s", dtstr, ftstr);
        elif evalb(what = "-") then
            return sprintf("%s - %s", pard, parf);
        elif evalb(what = "*") then
            return sprintf("%s \\times %s", pard, parf);
        elif evalb(what = "/") then
            return
            sprintf("\\frac{%s}{%s}", dtstr, ftstr);
        fi;

        return sprintf("{%s}^{%s}", pard, parf);
    end proc;

    for leftset in powerset(s) do
        rightset := s minus leftset;

        if nops(leftset)=0 or nops(rightset)=0 then next fi;

        aprob := repr(leftset);
        bprob := repr(rightset);

        if nops(op(op(res))) >= maxcount then next fi;

        for x in op(aprob) do for y in op(bprob) do
            d := x[1]; dstr:= x[2]; dtstr := x[3];
            f := y[1]; fstr:= y[2]; ftstr := y[3];

            if check(d+f) then
                res[d+f] := [d+f, sprintf("(%s) + (%s)", dstr, fstr),
                            typeset(dtstr, "+", ftstr)];
            fi;

            if check(d-f) then
                res[d-f] := [d-f, sprintf("(%s) - (%s)", dstr, fstr),
                            typeset(dtstr, "-", ftstr)];
            fi;

            if check(d*f) then
                res[d*f] := [d*f, sprintf("(%s) * (%s)", dstr, fstr),
                            typeset(dtstr, "*", ftstr)];
            fi;

            if f <> 0 and check(d/f) then
                res[d/f] := [d/f, sprintf("(%s) / (%s)", dstr, fstr),
                            typeset(dtstr, "/", ftstr)];
            fi;

            if not(d=0 or f=0) and evalf(abs(f*log(d))<10)
            and check(d^f) then
                res[d^f] := [d^f, sprintf("(%s) ^ (%s)", dstr, fstr),
                            typeset(dtstr, "^", ftstr)];
            fi;

        od od;
    od;

    return op(res);
end;


approx_pi :=
proc()
    local what, allset, allrepr, numerset, denomset, x, y,
    xt, yt, xpair, ypair;

    what := 2143/22;
    allset := {seq(k, k=1..9)} minus {1,4};
    allrepr := repr(allset);

    xpair := allrepr[what];
    if type(xpair, list) then
        printf("(%s)^(1/4) %a %a\n", xpair[2],
               xpair[1]^(1/4), evalf(xpair[1]^(1/4)));
        printf("\\left(%s\\right)^{1/4}\n\n", xpair[3]);
    fi;
end;

A: $$\frac{71*5}{2^6+49} =\frac{355}{113} = 3.141592.$$
