Cody

# Problem 43290. Calculate numerical integration.

Solution 1992328

Submitted on 27 Oct 2019
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
x=0:0.01:1; y=@(x)x.^2 z_correct = 0.3334 assert(abs(integralx2(x,y)-z_correct)<0.001)

y = function_handle with value: @(x)x.^2 z_correct = 0.3334 z = Columns 1 through 18 0 0.0001 0.0004 0.0009 0.0016 0.0025 0.0036 0.0049 0.0064 0.0081 0.0100 0.0121 0.0144 0.0169 0.0196 0.0225 0.0256 0.0289 Columns 19 through 36 0.0324 0.0361 0.0400 0.0441 0.0484 0.0529 0.0576 0.0625 0.0676 0.0729 0.0784 0.0841 0.0900 0.0961 0.1024 0.1089 0.1156 0.1225 Columns 37 through 54 0.1296 0.1369 0.1444 0.1521 0.1600 0.1681 0.1764 0.1849 0.1936 0.2025 0.2116 0.2209 0.2304 0.2401 0.2500 0.2601 0.2704 0.2809 Columns 55 through 72 0.2916 0.3025 0.3136 0.3249 0.3364 0.3481 0.3600 0.3721 0.3844 0.3969 0.4096 0.4225 0.4356 0.4489 0.4624 0.4761 0.4900 0.5041 Columns 73 through 90 0.5184 0.5329 0.5476 0.5625 0.5776 0.5929 0.6084 0.6241 0.6400 0.6561 0.6724 0.6889 0.7056 0.7225 0.7396 0.7569 0.7744 0.7921 Columns 91 through 101 0.8100 0.8281 0.8464 0.8649 0.8836 0.9025 0.9216 0.9409 0.9604 0.9801 1.0000

Error using assert The condition input argument must be a scalar logical. Error in Test1 (line 4) assert(abs(integralx2(x,y)-z_correct)<0.001)

2   Fail
x=0:0.01:1; y=@(x)x.^3 z_correct = 0.25 assert(abs(integralx2(x,y)-z_correct)<0.001)

y = function_handle with value: @(x)x.^3 z_correct = 0.2500 z = Columns 1 through 18 0 0.0000 0.0000 0.0000 0.0001 0.0001 0.0002 0.0003 0.0005 0.0007 0.0010 0.0013 0.0017 0.0022 0.0027 0.0034 0.0041 0.0049 Columns 19 through 36 0.0058 0.0069 0.0080 0.0093 0.0106 0.0122 0.0138 0.0156 0.0176 0.0197 0.0220 0.0244 0.0270 0.0298 0.0328 0.0359 0.0393 0.0429 Columns 37 through 54 0.0467 0.0507 0.0549 0.0593 0.0640 0.0689 0.0741 0.0795 0.0852 0.0911 0.0973 0.1038 0.1106 0.1176 0.1250 0.1327 0.1406 0.1489 Columns 55 through 72 0.1575 0.1664 0.1756 0.1852 0.1951 0.2054 0.2160 0.2270 0.2383 0.2500 0.2621 0.2746 0.2875 0.3008 0.3144 0.3285 0.3430 0.3579 Columns 73 through 90 0.3732 0.3890 0.4052 0.4219 0.4390 0.4565 0.4746 0.4930 0.5120 0.5314 0.5514 0.5718 0.5927 0.6141 0.6361 0.6585 0.6815 0.7050 Columns 91 through 101 0.7290 0.7536 0.7787 0.8044 0.8306 0.8574 0.8847 0.9127 0.9412 0.9703 1.0000

Error using assert The condition input argument must be a scalar logical. Error in Test2 (line 4) assert(abs(integralx2(x,y)-z_correct)<0.001)