Cody

Solution 1938434

Submitted on 16 Sep 2019 by Augusto Mazzei
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
user_solution = fileread('legendrePoly.m'); assert(isempty(strfind(user_solution,'regexp'))); assert(isempty(strfind(user_solution,'2str'))); assert(isempty(strfind(user_solution,'str2'))); assert(isempty(strfind(user_solution,'interp'))); assert(isempty(strfind(user_solution,'printf'))); assert(isempty(strfind(user_solution,'assert')));

2   Pass
n = 0; P_correct = [1]/1; assert(isequal(round(legendrePoly(n)*1),round(P_correct*1)));

3   Pass
n = 1; P_correct = [1 0]/1; assert(isequal(round(legendrePoly(n)*1),round(P_correct*1)));

4   Pass
n = 2; P_correct = [3 0 -1]/2; assert(isequal(round(legendrePoly(n)*2),round(P_correct*2)));

p = 1.5000 0 -0.5000

5   Pass
n = 3; P_correct = [5 0 -3 0]/2; assert(isequal(round(legendrePoly(n)*2),round(P_correct*2)));

p = 0 7.5000 -9.0000 2.5000 p = 2.5000 0 -1.5000 0

6   Pass
n = 4; P_correct = [35 0 -30 0 3]/8; assert(isequal(round(legendrePoly(n)*8),round(P_correct*8)));

p = 0 0 22.5000 -35.0000 13.5000 p = 0 17.5000 -30.0000 17.5000 -4.0000 p = 4.3750 0 -3.7500 0 0.3750

7   Pass
n = 5; P_correct = [63 0 -70 0 15 0]/8; assert(isequal(round(legendrePoly(n)*8),round(P_correct*8)));

p = 0 0 0 52.5000 -90.0000 38.5000 p = 0 0 70.0000 -157.5000 120.0000 -31.5000 p = 0 39.3750 -87.5000 78.7500 -37.5000 7.8750 p = 7.8750 0 -8.7500 0 1.8750 0

8   Pass
n = 6; P_correct = [231 0 -315 0 105 0 -5]/16; assert(isequal(round(legendrePoly(n)*16),round(P_correct*16)));

p = 0 0 0 0 105 -189 85 p = 0 0 0 210 -525 441 -125 p = 0 0 196.8750 -577.5000 656.2500 -346.5000 71.8750 p = 0 86.6250 -236.2500 288.7500 -210.0000 86.6250 -14.7500 p = 14.4375 0 -19.6875 0 6.5625 0 -0.3125

9   Pass
n = 7; P_correct = [429 0 -693 0 315 0 -35 0]/16; assert(isequal(round(legendrePoly(n)*16),round(P_correct*16)));

p = 0 0 0 0 0 189 -350 162 p = 0 0 0 0 525 -1386 1225 -363 p = 1.0e+03 * 0 0 0 0.7219 -2.3625 2.9453 -1.6625 0.3589 p = 1.0e+03 * 0 0 0.5198 -1.8769 2.8350 -2.2523 0.9363 -0.1609 p = 0 187.6875 -606.3750 938.4375 -918.7500 563.0625 -189.8750 26.8125 p = 26.8125 0 -43.3125 0 19.6875 0 -2.1875 0

10   Pass
n = 8; P_correct = [6435 0 -12012 0 6930 0 -1260 0 35]/128; assert(isequal(round(legendrePoly(n)*128),round(P_correct*128)));

p = 0 0 0 0 0 0 315 -594 280 p = 0 0 0 0 0 1155 -3150 2871 -875 p = 1.0e+03 * 0 0 0 0 2.1656 -7.5075 9.8438 -5.7915 1.2906 p = 1.0e+04 * 0 0 0 0.2252 -0.9096 1.5015 -1.2679 0.5470 -0.0962 p = 1.0e+04 * 0 0 0.1314 -0.5631 1.0612 -1.1261 0.7028 -0.2413 0.0352 p = 1.0e+03 * 0 0.4022 -1.5015 2.8153 -3.4650 2.8153 -1.4175 0.4022 -0.0500 p = 50.2734 0 -93.8438 0 54.1406 0 -9.8438 0 0.2734

11   Pass
n = 9; P_correct = [12155 0 -25740 0 18018 0 -4620 0 315 0]/128; assert(isequal(round(legendrePoly(n)*128),round(P_correct*128)));

p = 0 0 0 0 0 0 0 495 -945 451 p = 0 0 0 0 0 0 2310 -6435 5985 -1859 p = 1.0e+04 * 0 0 0 0 0 0.5631 -2.0213 2.7349 -1.6538 0.3772 p = 1.0e+04 * 0 0 0 0 0.7883 -3.3784 5.8616 -5.1480 2.2877 -0.4111 p = 1.0e+04 * 0 0 0 0.6569 -3.1532 6.4752 -7.2765 4.7056 -1.6538 0.2458 p = 1.0e+04 * 0 0 0.3217 -1.5953 3.6036 -4.7860 3.9848 -2.0512 0.5985 -0.0760 p = 1.0e+04 * 0 0.0855 -0.3620 0.7977 -1.1824 1.1965 -0.8013 0.3419 -0.0852 0.0095 p = 94.9609 0 -201.0938 0 140.7656 0 -36.0938 0 2.4609 0

12   Pass
n = 10; P_correct = [46189 0 -109395 0 90090 0 -30030 0 3465 0 -63]/256; assert(isequal(round(legendrePoly(n)*256),round(P_correct*256)));

p = 1.0e+03 * 0 0 0 0 0 0 0 0 0.7425 -1.4300 0.6885 p = 1.0e+04 * 0 0 0 0 0 0 0 0.4290 -1.2127 1.1440 -0.3602 p = 1.0e+04 * 0 0 0 0 0 0 1.3138 -4.8262 6.6701 -4.1113 0.9537 p = 1.0e+05 * 0 0 0 0 0 0.2365 -1.0511 1.8822 -1.6979 0.7713 -0.1411 p = 1.0e+05 * 0 0 0 0 0.2628 -1.3401 2.8904 -3.3730 2.2436 -0.8053 0.1216 p = 1.0e+05 * 0 0 0 0.1823 -1.0135 2.4887 -3.4910 3.0084 -1.5852 0.4710 -0.0607 p = 1.0e+05 * 0 0 0.0769 -0.4330 1.1402 -1.8187 1.8933 -1.2991 0.5685 -0.1443 0.0162 p = 1.0e+04 * 0 0.1804 -0.8546 2.1651 -3.7538 4.5467 -3.8007 2.1651 -0.8106 0.1804 -0.0181 p = 180.4258 0 -427.3242 0 351.9141 0 -117.3047 0 13.5352 0 -0.2461

13   Pass
n = 11; P_correct = [88179 0 -230945 0 218790 0 -90090 0 15015 0 -693 0]/256; assert(isequal(round(legendrePoly(n)*256),round(P_correct*256)));

p = 1.0e+03 * 0 0 0 0 0 0 0 0 0 1.0725 -2.0790 1.0075 p = 1.0e+04 * 0 0 0 0 0 0 0 0 0.7508 -2.1450 2.0444 -0.6500 p = 1.0e+05 * 0 0 0 0 0 0 0 0.2815 -1.0511 1.4747 -0.9217 0.2165 p = 1.0e+05 * 0 0 0 0 0 0 0.6306 -2.8716 5.2553 -4.8316 2.2315 -0.4141 p = 1.0e+06 * 0 0 0 0 0 0.0893 -0.4730 1.0529 -1.2613 0.8569 -0.3129 0.0479 p = 1.0e+06 * 0 0 0 0 0.0820 -0.4850 1.2500 -1.8187 1.6104 -0.8660 0.2614 -0.0341 p = 1.0e+06 * 0 0 0 0.0487 -0.3077 0.8790 -1.4780 1.5914 -1.1177 0.4980 -0.1283 0.0146 p = 1.0e+05 * 0 0 0.1804 -1.1367 3.4186 -6.3654 7.9533 -6.8201 3.9790 -1.5156 0.3410 -0.0344 p = 1.0e+05 * 0 0.0379 -0.1985 0.5683 -1.1281 1.5914 -1.5949 1.1367 -0.5678 0.1894 -0.0379 0.0034 p = 344.4492 0 -902.1289 0 854.6484 0 -351.9141 0 58.6523 0 -2.7070 0

14   Pass
n = 12; P_correct = [676039 0 -1939938 0 2078505 0 -1021020 0 225225 0 -18018 0 231]/1024; assert(isequal(round(legendrePoly(n)*1024),round(P_correct*1024)));

p = 1.0e+03 * 0 0 0 0 0 0 0 0 0 0 1.5015 -2.9250 1.4245 p = 1.0e+04 * 0 0 0 0 0 0 0 0 0 1.2512 -3.6036 3.4613 -1.1088 p = 1.0e+05 * 0 0 0 0 0 0 0 0 0.5631 -2.1271 3.0180 -1.9061 0.4522 p = 1.0e+06 * 0 0 0 0 0 0 0 0.1532 -0.7095 1.3188 -1.2297 0.5752 -0.1079 p = 1.0e+06 * 0 0 0 0 0 0 0.2680 -1.4550 3.3108 -4.0415 2.7905 -1.0330 0.1601 p = 1.0e+06 * 0 0 0 0 0 0.3118 -1.9144 5.0923 -7.6013 6.8706 -3.7568 1.1495 -0.1517 p = 1.0e+06 * 0 0 0 0 0.2436 -1.6368 4.9057 -8.5479 9.4489 -6.7696 3.0633 -0.7991 0.0919 p = 1.0e+06 * 0 0 0 0.1263 -0.8931 2.9099 -5.7034 7.3657 -6.4647 3.8395 -1.4834 0.3376 -0.0344 p = 1.0e+06 * 0 0 0.0417 -0.2905 0.9824 -2.0915 3.0491 -3.1372 2.2878 -1.1619 0.3921 -0.0792 0.0073 p = 1.0e+05 * 0 0.0792 -0.4547 1.4524 -3.2477 5.2287 -6.1102 5.2287 -3.2658 1.4524 -0.4359 0.0792 -0.0066 p = 1.0e+03 * 0.6602 0 -1.8945 0 2.0298 0 -0.9971 0 0.2199 0 -0.0176 0 0.0002

15   Pass
n = 13; P_correct = [1300075 0 -4056234 0 4849845 0 -2771340 0 765765 0 -90090 0 3003 0]/1024; assert(isequal(round(legendrePoly(n)*1024),round(P_correct*1024)));

p = 1.0e+03 * 0 0 0 0 0 0 0 0 0 0 0 2.0475 -4.0040 1.9575 p = 1.0e+04 * 0 0 0 0 0 0 0 0 0 0 2.0020 -5.8012 5.6056 -1.8062 p = 1.0e+05 * 0 0 0 0 0 0 0 0 0 1.0636 -4.0541 5.8012 -3.6937 0.8829 p = 1.0e+06 * 0 0 0 0 0 0 0 0 0.3446 -1.6166 3.0405 -2.8658 1.3536 -0.2563 p = 1.0e+07 * 0 0 0 0 0 0 0 0.0727 -0.4020 0.9296 -1.1509 0.8046 -0.3011 0.0471 p = 1.0e+07 * 0 0 0 0 0 0 0.1039 -0.6547 1.7804 -2.7078 2.4865 -1.3778 0.4264 -0.0568 p = 1.0e+07 * 0 0 0 0 0 0.1023 -0.7145 2.2097 -3.9485 4.4533 -3.2424 1.4866 -0.3921 0.0455 p = 1.0e+07 * 0 0 0 0 0.0695 -0.5229 1.7862 -3.6253 4.8040 -4.2992 2.5926 -1.0141 0.2331 -0.0240 p = 1.0e+07 * 0 0 0 0.0320 -0.2501 0.9150 -2.0482 3.0850 -3.2483 2.4110 -1.2418 0.4238 -0.0864 0.0080 p = 1.0e+07 * 0 0 0.0095 -0.0726 0.2728 -0.6536 1.0891 -1.3072 1.1439 -0.7262 0.3268 -0.0990 0.0182 -0.0015 p = 1.0e+06 * 0 0.0165 -0.1030 0.3631 -0.9030 1.6340 -2.1813 2.1786 -1.6332 0.9078 -0.3632 0.0990 -0.0165 0.0013 p = 1.0e+03 * 1.2696 0 -3.9612 0 4.7362 0 -2.7064 0 0.7478 0 -0.0880 0 0.0029 0

16   Pass
n = 14; P_correct = [5014575 0 -16900975 0 22309287 0 -14549535 0 4849845 0 -765765 0 45045 0 -429]/2048; assert(isequal(round(legendrePoly(n)*2048),round(P_correct*2048)));

p = Columns 1 through 14 0 0 0 0 0 0 0 0 0 0 0 0 2730 -5355 Column 15 2626 p = Columns 1 through 14 0 0 0 0 0 0 0 0 0 0 0 30940 -90090 87465 Column 15 -28314 p = 1.0e+06 * 0 0 0 0 0 0 0 0 0 0 0.1914 -0.7348 1.0586 -0.6783 0.1631 p = 1.0e+06 * 0 0 0 0 0 0 0 0 0 0.7275 -3.4459 6.5399 -6.2162 2.9591 -0.5643 p = 1.0e+07 * 0 0 0 0 0 0 0 0 0.1819 -1.0185 2.3834 -2.9834 2.1064 -0.7953 0.1254 p = 1.0e+07 * 0 0 0 0 0 0 0 0.3118 -2.0006 5.5288 -8.5287 7.9288 -4.4409 1.3871 -0.1863 p = 1.0e+08 * 0 0 0 0 0 0 0.0375 -0.2689 0.8502 -1.5477 1.7729 -1.3077 0.6062 -0.1614 0.0189 p = 1.0e+08 * 0 0 0 0 0 0.0320 -0.2501 0.8814 -1.8338 2.4784 -2.2533 1.3764 -0.5441 0.1262 -0.0131 p = 1.0e+08 * 0 0 0 0 0.0192 -0.1598 0.6127 -1.4192 2.1923 -2.3529 1.7729 -0.9243 0.3186 -0.0655 0.0061 p = 1.0e+08 * 0 0 0 0.0079 -0.0680 0.2760 -0.6945 1.1951 -1.4678 1.3072 -0.8415 0.3829 -0.1171 0.0216 -0.0018 p = 1.0e+07 * 0 0 0.0215 -0.1783 0.7364 -1.9608 3.6757 -5.0420 5.1473 -3.9216 2.2058 -0.8913 0.2451 -0.0411 0.0032 p = 1.0e+06 * 0 0.0343 -0.2311 0.8913 -2.4401 4.9019 -7.3600 8.4033 -7.3505 4.9019 -2.4513 0.8913 -0.2228 0.0343 -0.0024 p = 1.0e+04 * 0.2449 0.0000 -0.8252 0.0000 1.0893 0.0000 -0.7104 0.0000 0.2368 0.0000 -0.0374 0.0000 0.0022 0.0000 -0.0000

17   Pass
n = 15; P_correct = [9694845 0 -35102025 0 50702925 0 -37182145 0 14549535 0 -2909907 0 255255 0 -6435 0]/2048; assert(isequal(round(legendrePoly(n)*2048),round(P_correct*2048)));

p = Columns 1 through 14 0 0 0 0 0 0 0 0 0 0 0 0 0 3570 Columns 15 through 16 -7020 3451 p = Columns 1 through 14 0 0 0 0 0 0 0 0 0 0 0 0 46410 -135660 Columns 15 through 16 132210 -42959 p = 1.0e+06 * 0 0 0 0 0 0 0 0 0 0 0 0.3307 -1.2763 1.8484 -1.1905 0.2877 p = 1.0e+07 * 0 0 0 0 0 0 0 0 0 0 0.1455 -0.6944 1.3273 -1.2701 0.6084 -0.1167 p = 1.0e+07 * 0 0 0 0 0 0 0 0 0 0.4244 -2.4007 5.6710 -7.1599 5.0953 -1.9377 0.3076 p = 1.0e+08 * 0 0 0 0 0 0 0 0 0.0857 -0.5577 1.5604 -2.4337 2.2849 -1.2910 0.4064 -0.0550 p = 1.0e+08 * 0 0 0 0 0 0 0 0.1232 -0.9003 2.8932 -5.3415 6.1937 -4.6171 2.1600 -0.5796 0.0683 p = 1.0e+09 * 0 0 0 0 0 0 0.0128 -0.1027 0.3701 -0.7843 1.0763 -0.9911 0.6119 -0.2441 0.0571 -0.0060 p = 1.0e+09 * 0 0 0 0 0 0.0096 -0.0831 0.3287 -0.7802 1.2288 -1.3394 1.0220 -0.5384 0.1872 -0.0388 0.0036 p = 1.0e+09 * 0 0 0 0 0.0051 -0.0471 0.2001 -0.5210 0.9191 -1.1503 1.0397 -0.6774 0.3113 -0.0960 0.0179 -0.0015 p = 1.0e+08 * 0 0 0 0.0193 -0.1802 0.8039 -2.2469 4.3487 -6.1028 6.3398 -4.8971 2.7852 -1.1356 0.3147 -0.0532 0.0041 p = 1.0e+08 * 0 0 0.0048 -0.0431 0.1941 -0.5686 1.1845 -1.8277 2.1324 -1.8954 1.2794 -0.6462 0.2369 -0.0596 0.0092 -0.0007 p = 1.0e+07 * 0 0.0071 -0.0514 0.2154 -0.6437 1.4216 -2.3711 3.0462 -3.0455 2.3693 -1.4217 0.6462 -0.2154 0.0497 -0.0071 0.0005 p = 1.0e+04 * 0.4734 0 -1.7140 -0.0000 2.4757 -0.0000 -1.8155 -0.0000 0.7104 -0.0000 -0.1421 -0.0000 0.0125 -0.0000 -0.0003 -0.0000

Suggested Problems

More from this Author18