Cody

# Problem 42808. Sum of logarithms

Solution 1995030

Submitted on 29 Oct 2019 by Nikolaos Nikolaou
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
v = [1 2]; s_correct = log10(2); assert(abs(logs(v)-s_correct)<.0001)

l = 0 0.3010 s = 0 s = 0.3010

2   Pass
v = 1:20; s_correct = 18.3861; assert(abs(logs(v)-s_correct)<.0001)

l = Columns 1 through 17 0 0.3010 0.4771 0.6021 0.6990 0.7782 0.8451 0.9031 0.9542 1.0000 1.0414 1.0792 1.1139 1.1461 1.1761 1.2041 1.2304 Columns 18 through 20 1.2553 1.2788 1.3010 s = 0 s = 0.3010 s = 0.7782 s = 1.3802 s = 2.0792 s = 2.8573 s = 3.7024 s = 4.6055 s = 5.5598 s = 6.5598 s = 7.6012 s = 8.6803 s = 9.7943 s = 10.9404 s = 12.1165 s = 13.3206 s = 14.5511 s = 15.8063 s = 17.0851 s = 18.3861

3   Pass
v = [pi 5 7]; s_correct = 2.0412; assert(abs(logs(v)-s_correct)<.0001)

l = 0.4971 0.6990 0.8451 s = 0.4971 s = 1.1961 s = 2.0412

4   Pass
v = [1 1 2 3 5 8 13 21]; s_correct = 4.8164; assert(abs(logs(v)-s_correct)<.0001)

l = 0 0 0.3010 0.4771 0.6990 0.9031 1.1139 1.3222 s = 0 s = 0 s = 0.3010 s = 0.7782 s = 1.4771 s = 2.3802 s = 3.4942 s = 4.8164

5   Pass
v = ones(1,400); s_correct = 0; assert(abs(logs(v)-s_correct)<.0001)

l = Columns 1 through 29 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 30 through 58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 59 through 87 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 88 through 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 117 through 145 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 146 through 174 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 175 through 203 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 204 through 232 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 233 through 261 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 262 through 290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 291 through 319 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 320 through 348 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 349 through 377 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 378 through 400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0 s = 0

6   Pass
v = 9:3:99; s_correct = 51.4284; assert(abs(logs(v)-s_correct)<.0001)

l = Columns 1 through 17 0.9542 1.0792 1.1761 1.2553 1.3222 1.3802 1.4314 1.4771 1.5185 1.5563 1.5911 1.6232 1.6532 1.6812 1.7076 1.7324 1.7559 Columns 18 through 31 1.7782 1.7993 1.8195 1.8388 1.8573 1.8751 1.8921 1.9085 1.9243 1.9395 1.9542 1.9685 1.9823 1.9956 s = 0.9542 s = 2.0334 s = 3.2095 s = 4.4648 s = 5.7870 s = 7.1672 s = 8.5986 s = 10.0757 s = 11.5942 s = 13.1505 s = 14.7416 s = 16.3648 s = 18.0180 s = 19.6993 s = 21.4069 s = 23.1393 s = 24.8951 s = 26.6733 s = 28.4726 s = 30.2922 s = 32.1310 s = 33.9883 s = 35.8634 s = 37.7555 s = 39.6640 s = 41.5883 s = 43.5278 s = 45.4820 s = 47.4505 s = 49.4328 s = 51.4284

7   Pass
filetext = fileread('logs.m'); assert(isempty(strfind(filetext,'sum')))