Approximate PI

The problem

PI, or π is a mathematical constant, the ratio of a circle's circumference to its diameter, commonly approximated as 3.14159. It has been represented by the Greek letter "π" since the mid-18th century, though it is also sometimes spelled out as "pi" (/paɪ/).

PI can be computed using the following formula:

PI = 4.0 * (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11) ...)

Write a program that displays the result of 4 X (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11)) and (1 - (1.0/3) + (1.0/5) - (1.0/7) + (1.0/9) - (1.0/11) + (1.0/13)). Use 1.0 instead of 1 in your program.

Breaking it down

public static void main(String[] args) {

    double pi1 = 4.0 * (1 - (1.0 / 3) + (1.0 / 5) - (1.0 / 7) + (1.0 / 9) - (1.0 / 11));
    System.out.println(pi1);

    double pi2 = 4.0 * (1 - (1.0 / 3) + (1.0 / 5) - (1.0 / 7) + (1.0 / 9)
            * (1.0 / 11) - (1.0 / 13));
    System.out.println(pi2);

}

Output

2.9760461760461765
2.6683538683538686