Cody

Solution 1823062

Submitted on 22 May 2019 by Hans Kramer
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))

ans = 1

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

ans = 1 ans = -0.3333

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429 ans = 0.1111 ans = -0.0909 ans = 0.0769

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429 ans = 0.1111 ans = -0.0909 ans = 0.0769 ans = -0.0667 ans = 0.0588 ans = -0.0526

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429 ans = 0.1111 ans = -0.0909 ans = 0.0769 ans = -0.0667 ans = 0.0588 ans = -0.0526 ans = 0.0476 ans = -0.0435 ans = 0.0400 ans = -0.0370

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429 ans = 0.1111 ans = -0.0909 ans = 0.0769 ans = -0.0667 ans = 0.0588 ans = -0.0526 ans = 0.0476 ans = -0.0435 ans = 0.0400 ans = -0.0370 ans = 0.0345 ans = -0.0323 ans = 0.0303

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429 ans = 0.1111 ans = -0.0909 ans = 0.0769 ans = -0.0667 ans = 0.0588 ans = -0.0526 ans = 0.0476 ans = -0.0435 ans = 0.0400 ans = -0.0370 ans = 0.0345 ans = -0.0323 ans = 0.0303 ans = -0.0286 ans = 0.0270 ans = -0.0256

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

ans = 1 ans = -0.3333 ans = 0.2000 ans = -0.1429 ans = 0.1111 ans = -0.0909 ans = 0.0769 ans = -0.0667 ans = 0.0588 ans = -0.0526 ans = 0.0476 ans = -0.0435 ans = 0.0400 ans = -0.0370 ans = 0.0345 ans = -0.0323 ans = 0.0303 ans = -0.0286 ans = 0.0270 ans = -0.0256 ans = 0.0244 ans = -0.0233 ans = 0.0222 ans = -0.0213 ans = 0.0204