{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-16T00:12:35.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-16T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":42580,"title":"Conic equation","description":"A conic of revolution (around the |z| axis) can be defined by the equation\r\n\r\n   s^2 – 2*R*z + (k+1)*z^2 = 0\r\n\r\nwhere |s^2=x^2+y^2|, |R| is the vertex radius of curvature, and |k| is the conic constant: |k\u003c-1| for a hyperbola, |k=-1| for a parabola, |-1\u003ck\u003c0| for a tall ellipse, |k=0| for a sphere, and |k\u003e0| for a short ellipse.\r\n\r\nWrite a function |z=conic(s,R,k)| to calculate height |z| as a function of radius |s| for given |R| and |k|.  Choose the branch of the solution that gives |z=s^2/(2*R)+...| for small values of |s|.  This defines a concave surface for |R\u003e0| and a convex surface for |R\u003c0|.  \r\n\r\nThe trick is to get full machine precision for all values of |s| and |R|.  The test suite will require a relative error less than |4*eps|, where |eps| is the machine precision.\r\n\r\nHint (added 2015/09/03): the straightforward solution is \r\n\r\n   z = (R-sqrt(R^2-(k+1)*s^2))/(k+1), \r\n\r\nbut this does not work if |k=-1|, gives the wrong branch of the solution if |R\u003c0|, and is subject to severe roundoff error if |s^2| is small compared to |R^2|.  It is possible, however, to find a mathematically equivalent form of the solution that solves all three problems at once.\r\n","description_html":"\u003cp\u003eA conic of revolution (around the \u003ctt\u003ez\u003c/tt\u003e axis) can be defined by the equation\u003c/p\u003e\u003cpre\u003e   s^2 – 2*R*z + (k+1)*z^2 = 0\u003c/pre\u003e\u003cp\u003ewhere \u003ctt\u003es^2=x^2+y^2\u003c/tt\u003e, \u003ctt\u003eR\u003c/tt\u003e is the vertex radius of curvature, and \u003ctt\u003ek\u003c/tt\u003e is the conic constant: \u003ctt\u003ek\u0026lt;-1\u003c/tt\u003e for a hyperbola, \u003ctt\u003ek=-1\u003c/tt\u003e for a parabola, \u003ctt\u003e-1\u0026lt;k\u0026lt;0\u003c/tt\u003e for a tall ellipse, \u003ctt\u003ek=0\u003c/tt\u003e for a sphere, and \u003ctt\u003ek\u0026gt;0\u003c/tt\u003e for a short ellipse.\u003c/p\u003e\u003cp\u003eWrite a function \u003ctt\u003ez=conic(s,R,k)\u003c/tt\u003e to calculate height \u003ctt\u003ez\u003c/tt\u003e as a function of radius \u003ctt\u003es\u003c/tt\u003e for given \u003ctt\u003eR\u003c/tt\u003e and \u003ctt\u003ek\u003c/tt\u003e.  Choose the branch of the solution that gives \u003ctt\u003ez=s^2/(2*R)+...\u003c/tt\u003e for small values of \u003ctt\u003es\u003c/tt\u003e.  This defines a concave surface for \u003ctt\u003eR\u0026gt;0\u003c/tt\u003e and a convex surface for \u003ctt\u003eR\u0026lt;0\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eThe trick is to get full machine precision for all values of \u003ctt\u003es\u003c/tt\u003e and \u003ctt\u003eR\u003c/tt\u003e.  The test suite will require a relative error less than \u003ctt\u003e4*eps\u003c/tt\u003e, where \u003ctt\u003eeps\u003c/tt\u003e is the machine precision.\u003c/p\u003e\u003cp\u003eHint (added 2015/09/03): the straightforward solution is\u003c/p\u003e\u003cpre\u003e   z = (R-sqrt(R^2-(k+1)*s^2))/(k+1), \u003c/pre\u003e\u003cp\u003ebut this does not work if \u003ctt\u003ek=-1\u003c/tt\u003e, gives the wrong branch of the solution if \u003ctt\u003eR\u0026lt;0\u003c/tt\u003e, and is subject to severe roundoff error if \u003ctt\u003es^2\u003c/tt\u003e is small compared to \u003ctt\u003eR^2\u003c/tt\u003e.  It is possible, however, to find a mathematically equivalent form of the solution that solves all three problems at once.\u003c/p\u003e","function_template":"function z=conic(s,R,k)\r\nz=0;\r\nend","test_suite":"%%\r\nR=5;\r\nk=-1;\r\ns=-5:5;\r\nz=[25 16 9 4 1 0 1 4 9 16 25]/10;\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=-5;\r\nk=-1;\r\ns=-5:5;\r\nz=-[25 16 9 4 1 0 1 4 9 16 25]/10;\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=6;\r\nk=0;\r\ns=0:0.125:2;\r\nz=[0 0.001302224649086391 0.005210595859100573 ...\r\n   0.01173021649825800 0.02086962844930099 ...\r\n   0.03264086885999461 0.04705955010467117 ...\r\n   0.06414496470811713 0.08392021690038396 ...\r\n   0.1064123829368584 0.1316527028472488 ...\r\n   0.1596768068881667 0.1905249806888747 ...\r\n   0.2242424739260392 0.2608798583755018 ...\r\n   0.3004934424110011 0.3431457505076198];\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=6800;\r\nk=-2;\r\ns=10.^(-9:9);\r\nz=[7.352941176470588e-23 7.352941176470588e-21 ...\r\n   7.352941176470588e-19 7.352941176470588e-17 ...\r\n   7.352941176470588e-15 7.352941176470588e-13 ...\r\n   7.352941176470548e-11 7.352941176466613e-9 ...\r\n   7.352941176073046e-7 0.00007352941136716365 ...\r\n   0.007352937201052538 0.7352543677216725 ...\r\n   73.13611097583313 5292.973166264779 93430.93334894173 ...\r\n   993223.1197327390 9.993202311999733e6 9.99932002312e7 ...\r\n   9.9999320002312e8];\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=exp(1);\r\nk=pi;\r\ns=10.^(-7:0);\r\nz=[1.839397205857214e-15 1.839397205857469e-13 ...\r\n   1.839397205882986e-11 1.839397208434684e-09 ...\r\n   1.839397463604480e-07 0.00001839422981299153 ...\r\n   0.001841981926630790 0.2212216213343403];\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nt=fileread('conic.m');\r\nassert(isempty(findstr(t,'roots')))\r\nassert(isempty(findstr(t,'fzero')))\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":245,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":37,"created_at":"2015-08-26T21:39:35.000Z","updated_at":"2026-04-08T11:17:23.000Z","published_at":"2015-08-26T22:21:10.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA conic of revolution (around the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e axis) can be defined by the equation\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   s^2 – 2*R*z + (k+1)*z^2 = 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhere\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es^2=x^2+y^2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the vertex radius of curvature, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the conic constant:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u0026lt;-1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a hyperbola,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek=-1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a parabola,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-1\u0026lt;k\u0026lt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a tall ellipse,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek=0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a sphere, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u0026gt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a short ellipse.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez=conic(s,R,k)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to calculate height\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as a function of radius\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for given\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Choose the branch of the solution that gives\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez=s^2/(2*R)+...\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for small values of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. This defines a concave surface for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u0026gt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a convex surface for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u0026lt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe trick is to get full machine precision for all values of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. The test suite will require a relative error less than\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e4*eps\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, where\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eeps\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the machine precision.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHint (added 2015/09/03): the straightforward solution is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   z = (R-sqrt(R^2-(k+1)*s^2))/(k+1),]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ebut this does not work if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek=-1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, gives the wrong branch of the solution if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u0026lt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and is subject to severe roundoff error if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es^2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is small compared to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR^2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. It is possible, however, to find a mathematically equivalent form of the solution that solves all three problems at once.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":42580,"title":"Conic equation","description":"A conic of revolution (around the |z| axis) can be defined by the equation\r\n\r\n   s^2 – 2*R*z + (k+1)*z^2 = 0\r\n\r\nwhere |s^2=x^2+y^2|, |R| is the vertex radius of curvature, and |k| is the conic constant: |k\u003c-1| for a hyperbola, |k=-1| for a parabola, |-1\u003ck\u003c0| for a tall ellipse, |k=0| for a sphere, and |k\u003e0| for a short ellipse.\r\n\r\nWrite a function |z=conic(s,R,k)| to calculate height |z| as a function of radius |s| for given |R| and |k|.  Choose the branch of the solution that gives |z=s^2/(2*R)+...| for small values of |s|.  This defines a concave surface for |R\u003e0| and a convex surface for |R\u003c0|.  \r\n\r\nThe trick is to get full machine precision for all values of |s| and |R|.  The test suite will require a relative error less than |4*eps|, where |eps| is the machine precision.\r\n\r\nHint (added 2015/09/03): the straightforward solution is \r\n\r\n   z = (R-sqrt(R^2-(k+1)*s^2))/(k+1), \r\n\r\nbut this does not work if |k=-1|, gives the wrong branch of the solution if |R\u003c0|, and is subject to severe roundoff error if |s^2| is small compared to |R^2|.  It is possible, however, to find a mathematically equivalent form of the solution that solves all three problems at once.\r\n","description_html":"\u003cp\u003eA conic of revolution (around the \u003ctt\u003ez\u003c/tt\u003e axis) can be defined by the equation\u003c/p\u003e\u003cpre\u003e   s^2 – 2*R*z + (k+1)*z^2 = 0\u003c/pre\u003e\u003cp\u003ewhere \u003ctt\u003es^2=x^2+y^2\u003c/tt\u003e, \u003ctt\u003eR\u003c/tt\u003e is the vertex radius of curvature, and \u003ctt\u003ek\u003c/tt\u003e is the conic constant: \u003ctt\u003ek\u0026lt;-1\u003c/tt\u003e for a hyperbola, \u003ctt\u003ek=-1\u003c/tt\u003e for a parabola, \u003ctt\u003e-1\u0026lt;k\u0026lt;0\u003c/tt\u003e for a tall ellipse, \u003ctt\u003ek=0\u003c/tt\u003e for a sphere, and \u003ctt\u003ek\u0026gt;0\u003c/tt\u003e for a short ellipse.\u003c/p\u003e\u003cp\u003eWrite a function \u003ctt\u003ez=conic(s,R,k)\u003c/tt\u003e to calculate height \u003ctt\u003ez\u003c/tt\u003e as a function of radius \u003ctt\u003es\u003c/tt\u003e for given \u003ctt\u003eR\u003c/tt\u003e and \u003ctt\u003ek\u003c/tt\u003e.  Choose the branch of the solution that gives \u003ctt\u003ez=s^2/(2*R)+...\u003c/tt\u003e for small values of \u003ctt\u003es\u003c/tt\u003e.  This defines a concave surface for \u003ctt\u003eR\u0026gt;0\u003c/tt\u003e and a convex surface for \u003ctt\u003eR\u0026lt;0\u003c/tt\u003e.\u003c/p\u003e\u003cp\u003eThe trick is to get full machine precision for all values of \u003ctt\u003es\u003c/tt\u003e and \u003ctt\u003eR\u003c/tt\u003e.  The test suite will require a relative error less than \u003ctt\u003e4*eps\u003c/tt\u003e, where \u003ctt\u003eeps\u003c/tt\u003e is the machine precision.\u003c/p\u003e\u003cp\u003eHint (added 2015/09/03): the straightforward solution is\u003c/p\u003e\u003cpre\u003e   z = (R-sqrt(R^2-(k+1)*s^2))/(k+1), \u003c/pre\u003e\u003cp\u003ebut this does not work if \u003ctt\u003ek=-1\u003c/tt\u003e, gives the wrong branch of the solution if \u003ctt\u003eR\u0026lt;0\u003c/tt\u003e, and is subject to severe roundoff error if \u003ctt\u003es^2\u003c/tt\u003e is small compared to \u003ctt\u003eR^2\u003c/tt\u003e.  It is possible, however, to find a mathematically equivalent form of the solution that solves all three problems at once.\u003c/p\u003e","function_template":"function z=conic(s,R,k)\r\nz=0;\r\nend","test_suite":"%%\r\nR=5;\r\nk=-1;\r\ns=-5:5;\r\nz=[25 16 9 4 1 0 1 4 9 16 25]/10;\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=-5;\r\nk=-1;\r\ns=-5:5;\r\nz=-[25 16 9 4 1 0 1 4 9 16 25]/10;\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=6;\r\nk=0;\r\ns=0:0.125:2;\r\nz=[0 0.001302224649086391 0.005210595859100573 ...\r\n   0.01173021649825800 0.02086962844930099 ...\r\n   0.03264086885999461 0.04705955010467117 ...\r\n   0.06414496470811713 0.08392021690038396 ...\r\n   0.1064123829368584 0.1316527028472488 ...\r\n   0.1596768068881667 0.1905249806888747 ...\r\n   0.2242424739260392 0.2608798583755018 ...\r\n   0.3004934424110011 0.3431457505076198];\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=6800;\r\nk=-2;\r\ns=10.^(-9:9);\r\nz=[7.352941176470588e-23 7.352941176470588e-21 ...\r\n   7.352941176470588e-19 7.352941176470588e-17 ...\r\n   7.352941176470588e-15 7.352941176470588e-13 ...\r\n   7.352941176470548e-11 7.352941176466613e-9 ...\r\n   7.352941176073046e-7 0.00007352941136716365 ...\r\n   0.007352937201052538 0.7352543677216725 ...\r\n   73.13611097583313 5292.973166264779 93430.93334894173 ...\r\n   993223.1197327390 9.993202311999733e6 9.99932002312e7 ...\r\n   9.9999320002312e8];\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nR=exp(1);\r\nk=pi;\r\ns=10.^(-7:0);\r\nz=[1.839397205857214e-15 1.839397205857469e-13 ...\r\n   1.839397205882986e-11 1.839397208434684e-09 ...\r\n   1.839397463604480e-07 0.00001839422981299153 ...\r\n   0.001841981926630790 0.2212216213343403];\r\nt=arrayfun(@(x)conic(x,R,k),s);\r\nassert(all(abs(t-z)\u003c=4*eps*abs(z)))\r\n%%\r\nt=fileread('conic.m');\r\nassert(isempty(findstr(t,'roots')))\r\nassert(isempty(findstr(t,'fzero')))\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":245,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":37,"created_at":"2015-08-26T21:39:35.000Z","updated_at":"2026-04-08T11:17:23.000Z","published_at":"2015-08-26T22:21:10.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA conic of revolution (around the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e axis) can be defined by the equation\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   s^2 – 2*R*z + (k+1)*z^2 = 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhere\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es^2=x^2+y^2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the vertex radius of curvature, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the conic constant:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u0026lt;-1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a hyperbola,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek=-1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a parabola,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e-1\u0026lt;k\u0026lt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a tall ellipse,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek=0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a sphere, and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u0026gt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for a short ellipse.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez=conic(s,R,k)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to calculate height\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e as a function of radius\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for given\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. Choose the branch of the solution that gives\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ez=s^2/(2*R)+...\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e for small values of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. This defines a concave surface for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u0026gt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and a convex surface for\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u0026lt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe trick is to get full machine precision for all values of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. The test suite will require a relative error less than\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e4*eps\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, where\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eeps\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is the machine precision.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHint (added 2015/09/03): the straightforward solution is\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[   z = (R-sqrt(R^2-(k+1)*s^2))/(k+1),]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ebut this does not work if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ek=-1\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, gives the wrong branch of the solution if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR\u0026lt;0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, and is subject to severe roundoff error if\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es^2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is small compared to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eR^2\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e. It is possible, however, to find a mathematically equivalent form of the solution that solves all three problems at once.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"conic\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"conic\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"conic\"","","\"","conic","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3e90\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3df0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3530\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d4110\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f0f2e3d4070\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3fd0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f0f2e3d3f30\u003e":"tag:\"conic\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3f30\u003e":"tag:\"conic\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"conic\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"conic\"","","\"","conic","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3e90\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3df0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3530\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d4110\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f0f2e3d4070\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3fd0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f0f2e3d3f30\u003e":"tag:\"conic\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f0f2e3d3f30\u003e":"tag:\"conic\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":42580,"difficulty_rating":"medium-hard"}]}}