Cody

Solution 2191512

Submitted on 4 Apr 2020 by Shanidev Singh
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))

approx = 0 durr = 1 approx = 1

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238 durr = 0.1111 approx = 0.8349 durr = 0.0909 approx = 0.7440 durr = 0.0769 approx = 0.8209

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238 durr = 0.1111 approx = 0.8349 durr = 0.0909 approx = 0.7440 durr = 0.0769 approx = 0.8209 durr = 0.0667 approx = 0.7543 durr = 0.0588 approx = 0.8131 durr = 0.0526 approx = 0.7605

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238 durr = 0.1111 approx = 0.8349 durr = 0.0909 approx = 0.7440 durr = 0.0769 approx = 0.8209 durr = 0.0667 approx = 0.7543 durr = 0.0588 approx = 0.8131 durr = 0.0526 approx = 0.7605 durr = 0.0476 approx = 0.8081 durr = 0.0435 approx = 0.7646 durr = 0.0400 approx = 0.8046 durr = 0.0370 approx = 0.7676

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238 durr = 0.1111 approx = 0.8349 durr = 0.0909 approx = 0.7440 durr = 0.0769 approx = 0.8209 durr = 0.0667 approx = 0.7543 durr = 0.0588 approx = 0.8131 durr = 0.0526 approx = 0.7605 durr = 0.0476 approx = 0.8081 durr = 0.0435 approx = 0.7646 durr = 0.0400 approx = 0.8046 durr = 0.0370 approx = 0.7676 durr = 0.0345 approx = 0.8020 durr = 0.0323 approx = 0.7698 durr = 0.0303 approx = 0.8001

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238 durr = 0.1111 approx = 0.8349 durr = 0.0909 approx = 0.7440 durr = 0.0769 approx = 0.8209 durr = 0.0667 approx = 0.7543 durr = 0.0588 approx = 0.8131 durr = 0.0526 approx = 0.7605 durr = 0.0476 approx = 0.8081 durr = 0.0435 approx = 0.7646 durr = 0.0400 approx = 0.8046 durr = 0.0370 approx = 0.7676 durr = 0.0345 approx = 0.8020 durr = 0.0323 approx = 0.7698 durr = 0.0303 approx = 0.8001 durr = 0.0286 approx = 0.7715 durr = 0.0270 approx = 0.7985 durr = 0.0256 approx = 0.7729

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

approx = 0 durr = 1 approx = 1 durr = 0.3333 approx = 0.6667 durr = 0.2000 approx = 0.8667 durr = 0.1429 approx = 0.7238 durr = 0.1111 approx = 0.8349 durr = 0.0909 approx = 0.7440 durr = 0.0769 approx = 0.8209 durr = 0.0667 approx = 0.7543 durr = 0.0588 approx = 0.8131 durr = 0.0526 approx = 0.7605 durr = 0.0476 approx = 0.8081 durr = 0.0435 approx = 0.7646 durr = 0.0400 approx = 0.8046 durr = 0.0370 approx = 0.7676 durr = 0.0345 approx = 0.8020 durr = 0.0323 approx = 0.7698 durr = 0.0303 approx = 0.8001 durr = 0.0286 approx = 0.7715 durr = 0.0270 approx = 0.7985 durr = 0.0256 approx = 0.7729 durr = 0.0244 approx = 0.7973 durr = 0.0233 approx = 0.7740 durr = 0.0222 approx = 0.7963 durr = 0.0213 approx = 0.7750 durr = 0.0204 approx = 0.7954

Suggested Problems

More from this Author139