Cody

Problem 42580. Conic equation

Solution 2285154

Submitted on 16 May 2020
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
R=5; k=-1; s=-5:5; z=[25 16 9 4 1 0 1 4 9 16 25]/10; t=arrayfun(@(x)conic(x,R,k),s); assert(all(abs(t-z)<=4*eps*abs(z)))

z = 2.5000 method 2 z = 1.6000 method 2 z = 0.9000 method 2 z = 0.4000 method 2 z = 0.1000 method 2 z = 0 method 2 z = 0.1000 method 2 z = 0.4000 method 2 z = 0.9000 method 2 z = 1.6000 method 2 z = 2.5000 method 2

2   Pass
R=-5; k=-1; s=-5:5; z=-[25 16 9 4 1 0 1 4 9 16 25]/10; t=arrayfun(@(x)conic(x,R,k),s); assert(all(abs(t-z)<=4*eps*abs(z)))

z = -2.5000 method 2 z = -1.6000 method 2 z = -0.9000 method 2 z = -0.4000 method 2 z = -0.1000 method 2 z = 0 method 2 z = -0.1000 method 2 z = -0.4000 method 2 z = -0.9000 method 2 z = -1.6000 method 2 z = -2.5000 method 2

3   Fail
R=6; k=0; s=0:0.125:2; z=[0 0.001302224649086391 0.005210595859100573 ... 0.01173021649825800 0.02086962844930099 ... 0.03264086885999461 0.04705955010467117 ... 0.06414496470811713 0.08392021690038396 ... 0.1064123829368584 0.1316527028472488 ... 0.1596768068881667 0.1905249806888747 ... 0.2242424739260392 0.2608798583755018 ... 0.3004934424110011 0.3431457505076198]; t=arrayfun(@(x)conic(x,R,k),s); assert(all(abs(t-z)<=4*eps*abs(z)))

z = 0 method 1 z = 0.001302224649087 method 1 z = 0.005210595859101 method 1 z = 0.011730216498258 method 1 z = 0.020869628449301 method 1 z = 0.032640868859994 method 1 z = 0.047059550104671 method 1 z = 0.064144964708117 method 1 z = 0.083920216900384 method 1 z = 0.106412382936858 method 1 z = 0.131652702847249 method 1 z = 0.159676806888167 method 1 z = 0.190524980688875 method 1 z = 0.224242473926039 method 1 z = 0.260879858375501 method 1 z = 0.300493442411002 method 1 z = 0.343145750507619 method 1

Assertion failed.

4   Fail
R=6800; k=-2; s=10.^(-9:9); z=[7.352941176470588e-23 7.352941176470588e-21 ... 7.352941176470588e-19 7.352941176470588e-17 ... 7.352941176470588e-15 7.352941176470588e-13 ... 7.352941176470548e-11 7.352941176466613e-9 ... 7.352941176073046e-7 0.00007352941136716365 ... 0.007352937201052538 0.7352543677216725 ... 73.13611097583313 5292.973166264779 93430.93334894173 ... 993223.1197327390 9.993202311999733e6 9.99932002312e7 ... 9.9999320002312e8]; t=arrayfun(@(x)conic(x,R,k),s); assert(all(abs(t-z)<=4*eps*abs(z)))

z = 0 method 1 z = 0 method 1 z = 0 method 1 z = 0 method 1 z = 0 method 1 z = 9.094947017729282e-13 method 1 z = 7.366907084360719e-11 method 1 z = 7.353264663834125e-09 method 1 z = 7.352937245741487e-07 method 1 z = 7.352941156568704e-05 method 1 z = 0.007352937201176 method 1 z = 0.735254367721609 method 1 z = 73.136110975832707 method 1 z = 5.292973166264779e+03 method 1 z = 9.343093334894173e+04 method 1 z = 9.932231197327389e+05 method 1 z = 9.993202311999733e+06 method 1 z = 9.999320023119999e+07 method 1 z = 9.999932000231200e+08 method 1

Assertion failed.

5   Fail
R=exp(1); k=pi; s=10.^(-7:0); z=[1.839397205857214e-15 1.839397205857469e-13 ... 1.839397205882986e-11 1.839397208434684e-09 ... 1.839397463604480e-07 0.00001839422981299153 ... 0.001841981926630790 0.2212216213343403]; t=arrayfun(@(x)conic(x,R,k),s); assert(all(abs(t-z)<=4*eps*abs(z)))

z = 1.822853476646816e-15 method 1 z = 1.838937477911346e-13 method 1 z = 1.839398552614263e-11 method 1 z = 1.839397158667487e-09 method 1 z = 1.839397463191244e-07 method 1 z = 1.839422981295618e-05 method 1 z = 0.001841981926631 method 1 z = 0.221221621334340 method 1

Assertion failed.

6   Pass
t=fileread('conic.m'); assert(isempty(findstr(t,'roots'))) assert(isempty(findstr(t,'fzero')))

Suggested Problems

More from this Author10

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!