Cody

Solution 1303620

Submitted on 20 Oct 2017 by Bhartendu
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)

x0 = 0.2143 x0 = 0.1715 x0 = 0.1372 x0 = 0.1098 x0 = 0.0880 x0 = 0.0707 x0 = 0.0574 x0 = 0.0478 x0 = 0.0422 x0 = 0.0402 x0 = 0.0400 x0 = 0.0400 x0 = 0.0400

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

x0 = 0.2927 x0 = 0.2390 x0 = 0.2023 x0 = 0.1833 x0 = 0.1785 x0 = 0.1783 x0 = 0.1783 x0 = 0.1783

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

x0 = 0.3070 x0 = 0.2528 x0 = 0.2179 x0 = 0.2027 x0 = 0.2001 x0 = 0.2000 x0 = 0.2000

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

x0 = 0.4393 x0 = 0.3944 x0 = 0.3816 x0 = 0.3807 x0 = 0.3807 x0 = 0.3807

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

x0 = 0.7350 x0 = 0.7251 x0 = 0.7248 x0 = 0.7248 x0 = 0.7248

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

x0 = 1

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

x0 = 1.3963 x0 = 1.3801 x0 = 1.3797 x0 = 1.3797 x0 = 1.3797

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

x0 = 1.9889 x0 = 1.9106 x0 = 1.9037 x0 = 1.9037 x0 = 1.9037

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

x0 = 2.3273 x0 = 2.2027 x0 = 2.1870 x0 = 2.1867 x0 = 2.1867

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

x0 = 3.9830 x0 = 3.5837 x0 = 3.4732 x0 = 3.4658 x0 = 3.4657 x0 = 3.4657

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

x0 = 6.1814 x0 = 5.3732 x0 = 5.0484 x0 = 5.0009 x0 = 5.0000 x0 = 5.0000 x0 = 5

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

x0 = 23.8159 x0 = 19.5248 x0 = 16.6649 x0 = 15.3011 x0 = 15.0116 x0 = 15.0000 x0 = 15.0000 x0 = 15.0000

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

x0 = 44.9214 x0 = 36.4167 x0 = 30.2439 x0 = 26.5295 x0 = 25.1665 x0 = 25.0022 x0 = 25.0000 x0 = 25.0000 x0 = 25.0000

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

x0 = 106.5659 x0 = 85.7374 x0 = 69.7465 x0 = 58.4384 x0 = 52.1097 x0 = 50.1641 x0 = 50.0011 x0 = 50.0000 x0 = 50.0000

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

x0 = 420.1563 x0 = 336.6124 x0 = 270.4728 x0 = 219.2161 x0 = 181.9494 x0 = 159.4170 x0 = 151.0488 x0 = 150.0145 x0 = 150.0000 x0 = 150.0000 x0 = 150

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

x0 = 1.8917e+03 x0 = 1.5138e+03 x0 = 1.2123e+03 x0 = 972.7002 x0 = 785.1419 x0 = 644.5606 x0 = 551.8582 x0 = 508.8726 x0 = 500.3041 x0 = 500.0004 x0 = 500.0000 x0 = 500

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

x0 = 2.1552e+03 x0 = 1.7247e+03 x0 = 1.3809e+03 x0 = 1.1076e+03 x0 = 893.1133 x0 = 731.0433 x0 = 621.7088 x0 = 567.8602 x0 = 555.5694 x0 = 555.0012 x0 = 555.0000 x0 = 555

Suggested Problems

More from this Author139