Cody

# Problem 2908. Approximation of Pi

Solution 1831308

Submitted on 30 May 2019 by PRASANNA GAWADE
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))

estimate = 1

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

estimate = 1 estimate = 0.6667

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238 estimate = 0.8349 estimate = 0.7440 estimate = 0.8209

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238 estimate = 0.8349 estimate = 0.7440 estimate = 0.8209 estimate = 0.7543 estimate = 0.8131 estimate = 0.7605

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238 estimate = 0.8349 estimate = 0.7440 estimate = 0.8209 estimate = 0.7543 estimate = 0.8131 estimate = 0.7605 estimate = 0.8081 estimate = 0.7646 estimate = 0.8046 estimate = 0.7676

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238 estimate = 0.8349 estimate = 0.7440 estimate = 0.8209 estimate = 0.7543 estimate = 0.8131 estimate = 0.7605 estimate = 0.8081 estimate = 0.7646 estimate = 0.8046 estimate = 0.7676 estimate = 0.8020 estimate = 0.7698 estimate = 0.8001

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238 estimate = 0.8349 estimate = 0.7440 estimate = 0.8209 estimate = 0.7543 estimate = 0.8131 estimate = 0.7605 estimate = 0.8081 estimate = 0.7646 estimate = 0.8046 estimate = 0.7676 estimate = 0.8020 estimate = 0.7698 estimate = 0.8001 estimate = 0.7715 estimate = 0.7985 estimate = 0.7729

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

estimate = 1 estimate = 0.6667 estimate = 0.8667 estimate = 0.7238 estimate = 0.8349 estimate = 0.7440 estimate = 0.8209 estimate = 0.7543 estimate = 0.8131 estimate = 0.7605 estimate = 0.8081 estimate = 0.7646 estimate = 0.8046 estimate = 0.7676 estimate = 0.8020 estimate = 0.7698 estimate = 0.8001 estimate = 0.7715 estimate = 0.7985 estimate = 0.7729 estimate = 0.7973 estimate = 0.7740 estimate = 0.7963 estimate = 0.7750 estimate = 0.7954