Cody

Solution 1745042

Submitted on 7 Mar 2019 by Alfonso Nieto-Castanon
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
x = 0.5; r = 0.999; n = 1; x_correct = 0.5; p_correct = 0.5; [p, x] = f(x, r, n); assert(isequal(p,p_correct)); assert(x==x_correct);

2   Pass
x = 0.5; r = 0.999; n = 2; x_correct = 0.999; p_correct = [1 0]; [p, x] = f(x, r, n); assert(isequal(p,p_correct)); assert(x==x_correct);

3   Pass
x = 0.5; r = 0.999; n = 3; x_correct = 0.00399; p_correct = [-4 4 0 0]; [p, x] = f(x, r, n); assert(isequal(p,p_correct)); assert(abs(x-x_correct)<1E-5);

4   Pass
x = 0.5; r = 0.999; n = 5; x_correct = 0.06248; [p, x] = f(x, r, n); assert(isequal(p(1:3),[-16384 65536 -98304])); assert(abs(x-x_correct)<1E-5);

5   Pass
x = 0.5; r = 0.999; n = 6; x_correct = 0.23407; [p, x] = f(x, r, n); assert(abs(sum(p(1:3))+2.25485E10)<1E5); assert(abs(x-x_correct)<1E-5);

6   Pass
x = 0.5; r = 0.9999; n = 7; x_correct = 0.09891; [p, x] = f(x, r, n); assert(abs(sum(p))<1E5); assert(abs(x-x_correct)<1E-5);

Suggested Problems