Cody

Solution 573311

Submitted on 3 Feb 2015 by James
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))

a = 1 ma4 = 1 ma4 = 1 ans = -0.8584

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

a = 1 3 ma4 = 1 3 ma4 = 1 -1 ans = 0.4749

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

a = 1 3 5 7 ma4 = 1 3 1 3 ma4 = 1 -1 1 -1 ans = 0.2464

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

a = 1 3 5 7 9 11 13 ma4 = 1 3 1 3 1 3 1 ma4 = 1 -1 1 -1 1 -1 1 ans = -0.1421

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

a = 1 3 5 7 9 11 13 15 17 19 ma4 = 1 3 1 3 1 3 1 3 1 3 ma4 = 1 -1 1 -1 1 -1 1 -1 1 -1 ans = 0.0998

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

a = 1 3 5 7 9 11 13 15 17 19 21 23 25 27 ma4 = 1 3 1 3 1 3 1 3 1 3 1 3 1 3 ma4 = 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ans = 0.0713

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

a = 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 ma4 = 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 ma4 = 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 ans = -0.0588

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

a = 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 ma4 = 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 ma4 = 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ans = 0.0500

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

a = 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 ma4 = 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 3 1 ma4 = 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 ans = -0.0400

Suggested Problems

More from this Author139