Cody

# Problem 2908. Approximation of Pi

Solution 1972080

Submitted on 11 Oct 2019 by Earnest
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
n = 1; y_correct = -0.858407346410207; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 y = -0.8584

2   Pass
n = 2; y_correct = 0.474925986923126; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 y = 0.4749

3   Pass
n = 4; y_correct = 0.246354558351698; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 y = 0.2464

4   Pass
n = 7; y_correct = -0.142145830148691; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 total = 3.3397 total = 2.9760 total = 3.2837 y = -0.1421

5   Pass
n = 10; y_correct = 0.099753034660390; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 total = 3.3397 total = 2.9760 total = 3.2837 total = 3.0171 total = 3.2524 total = 3.0418 y = 0.0998

6   Pass
n = 14; y_correct = 0.071338035810608; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 total = 3.3397 total = 2.9760 total = 3.2837 total = 3.0171 total = 3.2524 total = 3.0418 total = 3.2323 total = 3.0584 total = 3.2184 total = 3.0703 y = 0.0713

7   Pass
n = 17; y_correct = -0.058772861819756; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 total = 3.3397 total = 2.9760 total = 3.2837 total = 3.0171 total = 3.2524 total = 3.0418 total = 3.2323 total = 3.0584 total = 3.2184 total = 3.0703 total = 3.2082 total = 3.0792 total = 3.2004 y = -0.0588

8   Pass
n = 20; y_correct = 0.049968846921953; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 total = 3.3397 total = 2.9760 total = 3.2837 total = 3.0171 total = 3.2524 total = 3.0418 total = 3.2323 total = 3.0584 total = 3.2184 total = 3.0703 total = 3.2082 total = 3.0792 total = 3.2004 total = 3.0861 total = 3.1942 total = 3.0916 y = 0.0500

9   Pass
n = 25; y_correct = -0.039984031845239; assert(abs(pi_approx(n)-y_correct)<(100*eps))

total = 4 total = 2.6667 total = 3.4667 total = 2.8952 total = 3.3397 total = 2.9760 total = 3.2837 total = 3.0171 total = 3.2524 total = 3.0418 total = 3.2323 total = 3.0584 total = 3.2184 total = 3.0703 total = 3.2082 total = 3.0792 total = 3.2004 total = 3.0861 total = 3.1942 total = 3.0916 total = 3.1892 total = 3.0962 total = 3.1851 total = 3.0999 total = 3.1816 y = -0.0400