$\pi$ in terms of $4$?

685 Views Asked by At

I'm trying to define $\pi$ in terms of $4$ by placing a unit circle inside a square, and subtracting the corners of the square.

I'm attempting to use summation to define the area of a corner, then multiplying that by four and subtracting from four (the area of the square)

I thought I figured it out, and I created a program to check. The answer came out to $\approx 3.4$

I'm not sure if it was a program fault, or if I'm simply making a math error. Can someone please lead me in the right direction? This is what I have right now:

$$\pi \approx 4 \times \left(1-\sum\limits_{n=1}^{\infty}\frac{\left(\frac{2-\sqrt 2}{2}\right)^2}{2^{n-1}}\right)$$

Where $\left(\frac{2-\sqrt2}{2}\right)^2$ is the area of the largest corner square and $2^{n-1}$ is the number of squares.

EDIT

After reading the comments I realized I wasn't very clear with what I was trying to achieve, so I created a sketch that should illustrate what I want.

2

There are 2 best solutions below

0
On

Your way of filling the corners will only (as far as I can see) a triangular part of them.

It's going to be hard to fill them with squares.

Chris says the same in his comment except that he actually tries to tell you what you might do (and he caught you miscounting on the number of smaller squares in each step).

7
On

As I mentioned in the comments, the sizes of the squares are a little more complicated than what you're hoping for. I don't know of a simple expression for the size of each square, but you can get each one by solving a quadratic equation. I wrote a program to do so; it draws all the squares whose sizes are above a small threshold. Here's the result. Hope it helps!

Details on the program: for a point $(0,0)\leq(x,y)\leq(1,1)$, we want to find a square with one vertex at $(x,y)$ and the other on the sphere $x_0^2+y_0^2=1$. Writing $b=y-x$, the condition that the two points form a square means that $y_0=x_0+b$. Substituting, we get $2x_0^2+2bx_0+b^2-1=0$. The solution is given by the quadratic equation: $x_0=\frac14\left(-2b+\sqrt{4b^2-4(2)(b^2-1)}\right)$, and then we get $y_0$ from $y_0=x_0+b$. Now draw the square between $(x,y)$ and $(x_0,y_0)$ and repeat the process from each of the points $(x,y_0)$ and $(x_0,y)$.

Here's some C++ code to generate an SVG fragment:

using namespace std;

void box(double x1, double y1, double x2, double y2, int level)
{
    cout
    << "<rect x=\"" << min(x1, x2)
    << "\" y=\"" << min(y1, y2)
    << "\" width=\"" << abs(x1-x2)
    << "\" height=\"" << abs(y1-y2)
    << "\"";

    switch (level % 3)
    {
        case 0: cout << " fill=\"red\""; break;
        case 1: cout << " fill=\"green\""; break;
        case 2: cout << " fill=\"blue\""; break;
    }

    cout << " />" << endl;
}

void boxes(double x1, double y1, double x2, double y2, int level)
{
    double r = 300.0;

    x1 *= r;
    y1 *= r;
    x2 *= r;
    y2 *= r;

    box(r+x1,r+y1,r+x2,r+y2, level);
    box(r+x1,r-y1,r+x2,r-y2, level);
    box(r-x1,r+y1,r-x2,r+y2, level);
    box(r-x1,r-y1,r-x2,r-y2, level);
}

void advance(double x, double y, double& ox, double& oy)
{
    const float b = y - x;
    ox = (-2*b + sqrt(4*b*b - 8*(b*b-1))) / 4;
    oy = ox + b;
}

void drawlevel(int level, double x, double y)
{
    double ox, oy;
    advance(x, y, ox, oy);
    boxes(x, y, ox, oy, level);

    if (abs(x-ox) > 0.0004)
    {
        drawlevel(level + 1, x, oy);
        drawlevel(level + 1, ox, y);
    }
}

int main()
{
    drawlevel(0, 1, 1);
}