Cody

Problem 2801. geometric progression

Solution 3390523

Submitted on 26 Oct 2020
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   Fail
nterms = 10; term0 = randi(10) ratio = (-1)^randi(2)*randi(10) correctsequence = term0*ratio.^(0:nterms-1); for position = 1:nterms errorsequence = correctsequence; errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50); [errorposition, truesequence] = find_error(errorsequence); assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 1 at position %d', position); end

term0 = 10 ratio = -4 d = 3.0978 + 1.1275i et = 1.0e+06 * Columns 1 through 9 0.0001 + 0.0000i 0.0002 + 0.0001i 0.0005 + 0.0004i 0.0010 + 0.0018i 0.0012 + 0.0066i -0.0039 + 0.0219i -0.0366 + 0.0634i -0.1848 + 0.1550i -0.7472 + 0.2720i Column 10 -2.6214 + 0.0000i d = 3.6039 + 1.7355i et = 1.0e+06 * Columns 1 through 9 -0.0000 + 0.0000i -0.0000 + 0.0000i -0.0001 - 0.0001i -0.0004 - 0.0005i -0.0006 - 0.0025i 0.0023 - 0.0100i 0.0255 - 0.0320i 0.1476 - 0.0711i 0.6554 - 0.0000i Column 10 2.3618 + 1.1374i ts = 1.0e+06 * Columns 1 through 9 -0.0000 + 0.0000i -0.0000 + 0.0000i -0.0001 - 0.0001i -0.0004 - 0.0005i -0.0006 - 0.0025i 0.0023 - 0.0100i 0.0255 - 0.0320i 0.1476 - 0.0711i 0.6554 - 0.0000i Column 10 2.3618 + 1.1374i ep = 1

failed test 1 at position 1

2   Fail
nterms = 15; term0 = randi(10) ratio = (-1)^randi(2)*randi(10) correctsequence = term0*ratio.^(0:nterms-1); for position = 1:nterms errorsequence = correctsequence; errorsequence(position) = errorsequence(position) + (-1)^randi(2)*randi(50); [errorposition, truesequence] = find_error(errorsequence); assert(errorposition == position && isequal(truesequence, correctsequence), 'failed test 2 at position %d', position); end

term0 = 9 ratio = -6 d = 5.6289 et = 1.0e+11 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0002 0.0012 0.0070 0.0395 0.2226 1.2530 7.0528 d = 6 et = 1.0e+11 * -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0002 -0.0009 -0.0054 -0.0327 -0.1959 -1.1755 -7.0528 ts = 1.0e+11 * -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0002 -0.0009 -0.0054 -0.0327 -0.1959 -1.1755 -7.0528 ep = 1

failed test 2 at position 1

Suggested Problems

More from this Author9

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!