Cody

# Problem 44344. The 5th Root

Solution 1435295

Submitted on 6 Feb 2018 by Yu Wang
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
filetext = fileread('fifth_root.m'); assert(isempty(strfind(filetext, '^')),'^ forbidden') assert(isempty(strfind(filetext, 'power')),'power() forbidden') assert(isempty(strfind(filetext, 'mpower')),'mpower() forbidden') assert(isempty(strfind(filetext, 'realpow')),'realpow() forbidden') assert(isempty(strfind(filetext, 'nthroot')),'nthroot() forbidden') assert(isempty(strfind(filetext, 'roots')),'roots() forbidden')

2   Pass
n = 1/9765625; assert(abs(fifth_root(n)-1/25)<1e-5)

error = 1.0000e+10 error = -1024 error = 98976 error = -1024 error = -1023 error = -992 error = -781 error = 0

3   Pass
n = 1/5555; assert(abs(fifth_root(n)-0.178263811215444)<1e-5)

error = 9.9982e+09 error = -1.8002e+06 error = -1.7002e+06 error = 1.3998e+06 error = -1.7002e+06 error = -1.6391e+06 error = -1.5513e+06 error = -1.4289e+06 error = -1.2624e+06 error = -1.0408e+06 error = -7.5160e+05 error = -3.8032e+05 error = 8.9388e+04 error = -3.8032e+05 error = -3.3807e+05 error = -2.9481e+05 error = -2.5054e+05 error = -2.0523e+05 error = -1.5887e+05 error = -1.1144e+05 error = -6.2914e+04 error = -1.3281e+04 error = 3.7480e+04 error = -1.3281e+04 error = -8.2560e+03 error = -3.2197e+03 error = 1.8280e+03 error = -3.2197e+03 error = -2.7154e+03 error = -2.2110e+03 error = -1.7065e+03 error = -1.2020e+03 error = -697.2481 error = -192.4277 error = 312.5059 error = -192.4277 error = -141.9395 error = -91.4501 error = -40.9595 error = 9.5321 error = -40.9595 error = -35.9104 error = -30.8613 error = -25.8122 error = -20.7630 error = -15.7138 error = -10.6647 error = -5.6155 error = -0.5663 error = 4.4829 error = -0.5663 error = -0.0614 error = 0.4436 error = -0.0614 error = -0.0109 error = 0.0396 error = -0.0109 error = -0.0058 error = -7.7980e-04 error = 0.0043 error = -7.7980e-04 error = -2.7488e-04 error = 2.3004e-04 error = -2.7488e-04 error = -2.2439e-04 error = -1.7390e-04 error = -1.2341e-04 error = -7.2915e-05 error = -2.2424e-05 error = 2.8067e-05 error = -2.2424e-05 error = -1.7375e-05 error = -1.2325e-05 error = -7.2755e-06

4   Pass
n = 1/3125; assert(abs(fifth_root(n)-1/5)<1e-5)

error = 9.9968e+09 error = -3.2000e+06 error = -3.1000e+06 error = -4.6566e-10

5   Pass
n = 1/125; assert(abs(fifth_root(n)-0.380730787743176)<1e-5)

error = 9.9200e+09 error = -80000000 error = -79900000 error = -76800000 error = -55700000 error = 22400000 error = -55700000 error = -51370849 error = -46445568 error = -40864607 error = -34564576 error = -27478125 error = -19533824 error = -10656043 error = -764832 error = 10224199 error = -764832 error = 2.8324e+05 error = -764832 error = -6.6052e+05 error = -5.5610e+05 error = -4.5157e+05 error = -3.4693e+05 error = -2.4217e+05 error = -1.3731e+05 error = -3.2341e+04 error = 7.2742e+04 error = -3.2341e+04 error = -2.1837e+04 error = -1.1333e+04 error = -827.6083 error = 9.6790e+03 error = -827.6083 error = 222.9996 error = -827.6083 error = -722.5480 error = -617.4876 error = -512.4271 error = -407.3665 error = -302.3057 error = -197.2449 error = -92.1839 error = 12.8772 error = -92.1839 error = -81.6778 error = -71.1717 error = -60.6656 error = -50.1595 error = -39.6534 error = -29.1473 error = -18.6412 error = -8.1351 error = 2.3710 error = -8.1351 error = -7.0845 error = -6.0338 error = -4.9832 error = -3.9326 error = -2.8820 error = -1.8314 error = -0.7808 error = 0.2698 error = -0.7808 error = -0.6757 error = -0.5707 error = -0.4656 error = -0.3605 error = -0.2555 error = -0.1504 error = -0.0454 error = 0.0597 error = -0.0454 error = -0.0349 error = -0.0243 error = -0.0138 error = -0.0033 error = 0.0072 error = -0.0033 error = -0.0023 error = -0.0012 error = -1.8473e-04 error = 8.6589e-04 error = -1.8473e-04 error = -7.9706e-05 error = 2.5332e-05 error = -7.9706e-05 error = -6.9171e-05 error = -5.8666e-05 error = -4.8116e-05 error = -3.7596e-05 error = -2.7061e-05 error = -1.6555e-05 error = -6.0201e-06

6   Pass
n = 1/5; assert(abs(fifth_root(n)-0.724779663677696)<1e-5)

error = 8.0000e+09 error = -2.0000e+09 error = -1.9999e+09 error = -1.9968e+09 error = -1.9757e+09 error = -1.8976e+09 error = -1.6875e+09 error = -1.2224e+09 error = -319300000 error = 1.2768e+09 error = -319300000 error = -195770649 error = -65082368 error = 73071593 error = -65082368 error = -5.1608e+07 error = -3.8059e+07 error = -2.4434e+07 error = -1.0734e+07 error = 3.0419e+06 error = -1.0734e+07 error = -9.3600e+06 error = -7.9850e+06 error = -6.6093e+06 error = -5.2328e+06 error = -3.8556e+06 error = -2.4776e+06 error = -1.0989e+06 error = 2.8060e+05 error = -1.0989e+06 error = -9.6099e+05 error = -8.2306e+05 error = -6.8513e+05 error = -5.4719e+05 error = -4.0925e+05 error = -2.7129e+05 error = -1.3333e+05 error = 4.6403e+03 error = -1.3333e+05 error = -1.1953e+05 error = -1.0574e+05 error = -9.1939e+04 error = -7.8142e+04 error = -6.4345e+04 error = -5.0548e+04 error = -3.6751e+04 error = -2.2954e+04 error = -9.1569e+03 error = 4.6403e+03 error = -9.1569e+03 error = -7.7772e+03 error = -6.3975e+03 error = -5.0178e+03 error = -3.6380e+03 error = -2.2583e+03 error = -878.5799 error = 501.1497 error = -878.5799 error = -740.6070 error = -602.6340 error = -464.6611 error = -326.6882 error = -188.7152 error = -50.7422 error = 87.2307 error = -50.7422 error = -36.9449 error = -23.1477 error = -9.3504 error = 4.4469 error = -9.3504 error = -7.9706 error = -6.5909 error = -5.2112 error = -3.8314 error = -2.4517 error = -1.0720 error = 0.3077 error = -1.0720 error = -0.9340 error = -0.7960 error = -0.6581 error = -0.5201 error = -0.3821 error = -0.2441 error = -0.1062 error = 0.0318 error = -0.1062 error = -0.0924 error = -0.0786 error = -0.0648 error = -0.0510 error = -0.0372 error = -0.0234 error = -0.0096 error = 0.0042 error = -0.0096 error = -0.0082 error = -0.0068 error = -0.0054 error = -0.0041 error = -0.0027 error = -0.0013 error = 7.4387e-05 error = -0.0013 error = -0.0012 error = -0.0010 error = -8.9383e-04 error = -7.5674e-04 error = -6.1941e-04 error = -4.8208e-04 error = -3.4499e-04 error = -2.0742e-04 error = -7.0572e-05 error = 6.6757e-05 error = -7.0572e-05 error = -5.6982e-05 error = -4.3392e-05 error = -2.9325e-05 error = -1.5497e-05 error = -1.6689e-06

7   Pass
n = 1; assert(abs(fifth_root(n)-1)<1e-5)

error = 1.0000e+10 error = -1 error = 99999 error = -1 error = 0

8   Pass
n = 5; assert(abs(fifth_root(n)-1.37972966146121)<1e-5)

error = 1.0000e+10 error = -5 error = 99995 error = -5 error = -4 error = 27 error = -4 error = -3.3895 error = -2.5117 error = -1.2871 error = 0.3782 error = -1.2871 error = -1.1421 error = -0.9925 error = -0.8384 error = -0.6796 error = -0.5160 error = -0.3474 error = -0.1738 error = 0.0049 error = -0.1738 error = -0.1562 error = -0.1385 error = -0.1208 error = -0.1030 error = -0.0851 error = -0.0672 error = -0.0493 error = -0.0313 error = -0.0132 error = 0.0049 error = -0.0132 error = -0.0114 error = -0.0096 error = -0.0078 error = -0.0060 error = -0.0042 error = -0.0023 error = -5.3743e-04 error = 0.0013 error = -5.3743e-04 error = -3.5625e-04 error = -1.7506e-04 error = 6.1342e-06

9   Pass
n = 25; assert(abs(fifth_root(n)-1.90365393871588)<1e-5)

error = 1.0000e+10 error = -25 error = 99975 error = -25 error = -24 error = 7 error = -24 error = -23.3895 error = -22.5117 error = -21.2871 error = -19.6218 error = -17.4062 error = -14.5142 error = -10.8014 error = -6.1043 error = -0.2390 error = 7.0000 error = -0.2390 error = 0.4195 error = -0.2390 error = -0.1738 error = -0.1084 error = -0.0429 error = 0.0227 error = -0.0429 error = -0.0364 error = -0.0298 error = -0.0232 error = -0.0167 error = -0.0101 error = -0.0035 error = 0.0030 error = -0.0035 error = -0.0029 error = -0.0022 error = -0.0016 error = -9.1525e-04 error = -2.5863e-04 error = 3.9801e-04 error = -2.5863e-04 error = -1.9296e-04 error = -1.2730e-04 error = -6.1639e-05 error = 4.0241e-06

10   Pass
n = 50; assert(abs(fifth_root(n)-2.18672414788656)<1e-5)

error = 1.0000e+10 error = -50 error = 99950 error = -50 error = -49 error = -18 error = 193 error = -18 error = -9.1590 error = 1.5363 error = -9.1590 error = -8.1773 error = -7.1768 error = -6.1572 error = -5.1183 error = -4.0599 error = -2.9815 error = -1.8830 error = -0.7640 error = 0.3756 error = -0.7640 error = -0.6510 error = -0.5378 error = -0.4243 error = -0.3107 error = -0.1968 error = -0.0827 error = 0.0315 error = -0.0827 error = -0.0713 error = -0.0599 error = -0.0485 error = -0.0370 error = -0.0256 error = -0.0142 error = -0.0028 error = 0.0087 error = -0.0028 error = -0.0016 error = -4.7421e-04 error = 6.6905e-04 error = -4.7421e-04 error = -3.5989e-04 error = -2.4556e-04 error = -1.3123e-04 error = -1.6907e-05 error = 9.7419e-05 error = -1.6907e-05 error = -5.4747e-06

11   Pass
n = 500; assert(abs(fifth_root(n)-3.46572421577573)<1e-5)

error = 1.0000e+10 error = -500 error = 99500 error = -500 error = -499 error = -468 error = -257 error = 524 error = -257 error = -213.7085 error = -164.4557 error = -108.6461 error = -45.6458 error = 25.2188 error = -45.6458 error = -38.9247 error = -32.1243 error = -25.2438 error = -18.2827 error = -11.2402 error = -4.1155 error = 3.0920 error = -4.1155 error = -3.3985 error = -2.6807 error = -1.9620 error = -1.2425 error = -0.5222 error = 0.1990 error = -0.5222 error = -0.4501 error = -0.3780 error = -0.3059 error = -0.2338 error = -0.1617 error = -0.0896 error = -0.0175 error = 0.0547 error = -0.0175 error = -0.0103 error = -0.0030 error = 0.0042 error = -0.0030 error = -0.0023 error = -0.0016 error = -8.7700e-04 error = -1.5565e-04 error = 5.6570e-04 error = -1.5565e-04 error = -8.3515e-05 error = -1.1380e-05 error = 6.0755e-05 error = -1.1380e-05 error = -4.1663e-06

12   Pass
n = 3125; assert(abs(fifth_root(n)-5)<1e-5)

error = 1.0000e+10 error = -3125 error = 96875 error = -3125 error = -3124 error = -3093 error = -2882 error = -2101 error = 0

13   Pass
n = 759375; assert(abs(fifth_root(n)-15)<1e-5)

error = 9.9992e+09 error = -759375 error = -659375 error = 2440625 error = -659375 error = -598324 error = -510543 error = -388082 error = -221551 error = 0

14   Pass
n = 9765625; assert(abs(fifth_root(n)-25)<1e-5)

error = 9.9902e+09 error = -9765625 error = -9665625 error = -6565625 error = 14534375 error = -6565625 error = -5681524 error = -4611993 error = -3329282 error = -1803001 error = 0

15   Pass
n = 312500000; assert(abs(fifth_root(n)-50)<1e-5)

error = 9.6875e+09 error = -312500000 error = -312400000 error = -309300000 error = -288200000 error = -210100000 error = 0

16   Pass
n = 75937500000; assert(abs(fifth_root(n)-150)<1e-5)

error = -6.5938e+10 error = 2.4406e+11 error = -6.5938e+10 error = -5.9832e+10 error = -5.1054e+10 error = -3.8808e+10 error = -2.2155e+10 error = 0

17   Pass
n = 31250000000000; assert(abs(fifth_root(n)-500)<1e-5)

error = -3.1240e+13 error = -3.0930e+13 error = -2.8820e+13 error = -2.1010e+13 error = 0

18   Pass
n = 52658067346875; assert(abs(fifth_root(n)-555)<1e-5)

error = -5.2648e+13 error = -5.2338e+13 error = -5.0228e+13 error = -4.2418e+13 error = -2.1408e+13 error = 2.5102e+13 error = -2.1408e+13 error = -1.8156e+13 error = -1.4638e+13 error = -1.0839e+13 error = -6.7416e+12 error = -2.3296e+12 error = 2.4151e+12 error = -2.3296e+12 error = -1.8704e+12 error = -1.4079e+12 error = -9.4198e+11 error = -4.7269e+11 error = 0