{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.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":"2025-12-14T00: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":8051,"title":"Stress-Strain Properties - 4","description":"A common measure of the ability of a material to carry load per unit mass is termed strength-to-weight ratio and is calculated by dividing the ultimate tensile strength of the material by its density. This property is key in weight-critical applications, such as aerospace, where many materials with high strength-to-weight ratios are used (e.g., Ni-based superalloys, Ti-based alloys, Al-based alloys, and composites).\r\n\r\nWrite a function to calculate the strength-to-weight ratio for a given material provided its ultimate tensile strength and density.\r\n\r\nPrevious problem: 3 - \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8050-stress-strain-properties-3 qualitative measure of brittleness\u003e. Next problem: 5 - \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8052-stress-strain-properties-5 stiffness-to-weight ratio\u003e.","description_html":"\u003cp\u003eA common measure of the ability of a material to carry load per unit mass is termed strength-to-weight ratio and is calculated by dividing the ultimate tensile strength of the material by its density. This property is key in weight-critical applications, such as aerospace, where many materials with high strength-to-weight ratios are used (e.g., Ni-based superalloys, Ti-based alloys, Al-based alloys, and composites).\u003c/p\u003e\u003cp\u003eWrite a function to calculate the strength-to-weight ratio for a given material provided its ultimate tensile strength and density.\u003c/p\u003e\u003cp\u003ePrevious problem: 3 - \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8050-stress-strain-properties-3\"\u003equalitative measure of brittleness\u003c/a\u003e. Next problem: 5 - \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8052-stress-strain-properties-5\"\u003estiffness-to-weight ratio\u003c/a\u003e.\u003c/p\u003e","function_template":"function [StWR] = stress_strain4(S_u,density)\r\n\r\nStWR = 1;\r\n\r\nend\r\n","test_suite":"%% Note\r\n% The following properties are measured at room temperature and are tensile\r\n% in a single direction. Some materials, such as metals are generally\r\n% isotropic, whereas others, like composite are highly anisotropic\r\n% (different properties in different directions). Also, property values can\r\n% range depending on the material grade. Finally, thermal or environmental\r\n% changes can alter these properties, sometimes drastically.\r\n\r\n%% steel alloy (ASTM A36)\r\nS_y = 250e6; %Pa\r\nS_u = 400e6; %Pa\r\ne_y = 0.00125;\r\ne_u = 0.35;\r\nnu = 0.26;\r\nG = 79.3e9; %Pa\r\nE = 200e9; %Pa\r\ndensity = 7.85; %g/cm^3\r\nsh_exp = 0.14; %strain-hardening exponent\r\nsh_coeff = 0.463; %strain-hardening coefficient\r\nStWR_corr = 5.096e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% titanium (Ti-6Al-4V)\r\nS_y = 830e6; %Pa\r\nS_u = 900e6; %Pa\r\ne_y = 0.00728;\r\ne_u = 0.14;\r\nnu = 0.342;\r\nG = 44e9; %Pa\r\nE = 114e9; %Pa\r\ndensity = 4.51; %g/cm^3\r\nsh_exp = 0.04; %strain-hardening exponent\r\nsh_coeff = 0.974; %strain-hardening coefficient\r\nStWR_corr = 19.96e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% Inconel 718\r\nS_y = 1172e6; %Pa\r\nS_u = 1407e6; %Pa\r\ne_y = 0.00563;\r\ne_u = 0.027;\r\nnu = 0.29;\r\nG = 11.6e9; %Pa\r\nE = 208e9; %Pa\r\ndensity = 8.19; %g/cm^3\r\nsh_exp = 0.075; %strain-hardening exponent\r\nsh_coeff = 1.845; %strain-hardening coefficient\r\nStWR_corr = 17.18e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% aluminum alloy (6061-T6)%^\u0026\r\nS_y = 241e6; %Pa\r\nS_u = 300e6; %Pa\r\ne_y = 0.0035;\r\ne_u = 0.15;\r\nnu = 0.33;\r\nG = 26e9; %Pa\r\nE = 68.9e9; %Pa\r\ndensity = 2.7; %g/cm^3\r\nsh_exp = 0.042; %strain-hardening exponent\r\nsh_coeff = 0.325; %strain-hardening coefficient\r\nStWR_corr = 11.11e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% copper\r\nS_y = 70e6; %Pa\r\nS_u = 220e6; %Pa\r\ne_y = 0.00054;\r\ne_u = 0.48;\r\nnu = 0.34;\r\nG = 48e9; %Pa\r\nE = 130e9; %Pa\r\ndensity = 8.92; %g/cm^3\r\nsh_exp = 0.44; %strain-hardening exponent\r\nsh_coeff = 0.304; %strain-hardening coefficient\r\nStWR_corr = 2.466e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% rhenium\r\nS_y = 317e6; %Pa\r\nS_u = 1130e6; %Pa\r\ne_y = 0.000685;\r\ne_u = 0.24;\r\nnu = 0.3;\r\nG = 178e9; %Pa\r\nE = 463e9; %Pa\r\ndensity = 21.02; %g/cm^3\r\nsh_exp = 0.353; %strain-hardening exponent\r\nsh_coeff = 1.870; %strain-hardening coefficient\r\nStWR_corr = 5.376e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% polymer (nylon, 6/6)\r\nS_y = 82e6; %Pa\r\nS_u = 82e6; %Pa\r\ne_y = 0.0265;\r\ne_u = 0.45;\r\nnu = 0.41;\r\nG = 2.8e9; %Pa\r\nE = 3.1e-2; %Pa\r\ndensity = 1.14; %g/cm^3\r\nStWR_corr = 7.193e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% polymer (nylon, 6/6) reinforced with 45wt.% glass fiber\r\nS_y = 230e6; %Pa\r\nS_u = 230e6; %Pa\r\ne_y = 0.016;\r\ne_u = 0.016;\r\nnu = 0.35;\r\nG = 13.0e9; %Pa\r\nE = 14.5e9; %Pa\r\ndensity = 1.51; %g/cm^3\r\nStWR_corr = 15.23e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% diamond\r\nS_y = 1200e6; %Pa\r\nS_u = 1200e6; %Pa\r\ne_y = 0.001;\r\ne_u = 0.001;\r\nnu = 0.20;\r\nG = 478e9; %Pa\r\nE = 1200e9; %Pa\r\ndensity = 3.51; %g/cm^3\r\nStWR_corr = 34.19e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tS_u = 400e6; %Pa\r\n\t\tdensity = 7.85; %g/cm^3\r\n\t\tStWR_corr = 5.096e7;\r\n\tcase 2\r\n\t\tS_u = 230e6; %Pa\r\n\t\tdensity = 1.51; %g/cm^3\r\n\t\tStWR_corr = 15.23e7;\r\n\tcase 3\r\n\t\tS_u = 1130e6; %Pa\r\n\t\tdensity = 21.02; %g/cm^3\r\n\t\tStWR_corr = 5.376e7;\r\n\tcase 4\r\n\t\tS_u = 1200e6; %Pa\r\n\t\tdensity = 3.51; %g/cm^3\r\n\t\tStWR_corr = 34.19e7;\r\nend\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tS_u = 300e6; %Pa\r\n\t\tdensity = 2.7; %g/cm^3\r\n\t\tStWR_corr = 11.11e7;\r\n\tcase 2\r\n\t\tS_u = 900e6; %Pa\r\n\t\tdensity = 4.51; %g/cm^3\r\n\t\tStWR_corr = 19.96e7;\r\n\tcase 3\r\n\t\tS_u = 220e6; %Pa\r\n\t\tdensity = 8.92; %g/cm^3\r\n\t\tStWR_corr = 2.466e7;\r\n\tcase 4\r\n\t\tS_u = 230e6; %Pa\r\n\t\tdensity = 1.51; %g/cm^3\r\n\t\tStWR_corr = 15.23e7;\r\nend\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tS_u = 300e6; %Pa\r\n\t\tdensity = 2.7; %g/cm^3\r\n\t\tStWR_corr = 11.11e7;\r\n\tcase 2\r\n\t\tS_u = 1200e6; %Pa\r\n\t\tdensity = 3.51; %g/cm^3\r\n\t\tStWR_corr = 34.19e7;\r\n\tcase 3\r\n\t\tS_u = 82e6; %Pa\r\n\t\tdensity = 1.14; %g/cm^3\r\n\t\tStWR_corr = 7.193e7;\r\n\tcase 4\r\n\t\tS_u = 900e6; %Pa\r\n\t\tdensity = 4.51; %g/cm^3\r\n\t\tStWR_corr = 19.96e7;\r\nend\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":222,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-30T19:24:41.000Z","updated_at":"2026-03-10T20:20:32.000Z","published_at":"2015-03-30T19:24:41.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 common measure of the ability of a material to carry load per unit mass is termed strength-to-weight ratio and is calculated by dividing the ultimate tensile strength of the material by its density. This property is key in weight-critical applications, such as aerospace, where many materials with high strength-to-weight ratios are used (e.g., Ni-based superalloys, Ti-based alloys, Al-based alloys, and composites).\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 to calculate the strength-to-weight ratio for a given material provided its ultimate tensile strength and density.\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\u003ePrevious problem: 3 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8050-stress-strain-properties-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003equalitative measure of brittleness\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 5 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8052-stress-strain-properties-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estiffness-to-weight ratio\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":331,"title":"Compute Area from Fixed Sum Cumulative Probability","description":"In Matlab the code\r\n v = rand(1,3);\r\n v = v/sum(v);\r\nis sometimes suggested as a convenient means of generating three random variables, whose ranges are restricted to [0,1], which have a fixed sum of one. However, this procedure has the property that the area-wise density distribution of the three values, considered as cartesian coordinates in 3D space, is widely variable throughout the planar region of possible locations of v. For any given density value in the range of this density distribution, let A be the corresponding area of the subregion of all points whose density is less than or equal to this given value, and let P be the corresponding probability that v would lie in this subregion. The task is to write a function 'fixedsumarea' which receives P as an input and gives A as an output:\r\n A = fixedsumarea(P);\r\nYou should assume that initially 'rand(1,3)' perfectly generates three independent random variables each uniformly distributed on [0,1], but subsequently each is modified by being divided by their mutual sum.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 311.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 155.65px; transform-origin: 407px 155.65px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58px 8px; transform-origin: 58px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn Matlab the code\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e v = rand(1,3);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e v = v/sum(v);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 147px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 73.5px; text-align: left; transform-origin: 384px 73.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 371.5px 8px; transform-origin: 371.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eis sometimes suggested as a convenient means of generating three random variables, whose ranges are restricted to [0,1], which have a fixed sum of one. However, this procedure has the property that the area-wise density distribution of the three values, considered as cartesian coordinates in 3D space, is widely variable throughout the planar region of possible locations of v. For any given density value in the range of this density distribution, let A be the corresponding area of the subregion of all points whose density is less than or equal to this given value, and let P be the corresponding probability that v would lie in this subregion. The task is to write a function 'fixedsumarea' which receives P as an input and gives A as an output:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; tab-size: 4; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e A = fixedsumarea(P);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 362.5px 8px; transform-origin: 362.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou should assume that initially 'rand(1,3)' perfectly generates three independent random variables each uniformly distributed on [0,1], but subsequently each is modified by being divided by their mutual sum.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function A = fixedsumarea(P)\r\n  P = 1/2;\r\n  A = 0;\r\nend","test_suite":"%%\r\nfiletext = fileread('fixedsumarea.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'elseif') || contains(filetext, 'switch ');\r\nassert(~illegal)\r\n\r\n%%\r\nP = pi/4;\r\nA_correct = 0.7984235067141288;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = 1/sqrt(11);\r\nA_correct = 0.4964013344766580;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = exp(-3);\r\nA_correct = 0.1494793760894695;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = (1/27)^(1/5);\r\nA_correct = 0.6605992894366502;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = sin(sqrt(2));\r\nA_correct = 0.8634048022602919;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = 68/137;\r\nA_correct = 0.6471420329484348;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":7,"created_by":28,"edited_by":223089,"edited_at":"2023-02-21T09:48:12.000Z","deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2023-02-21T09:48:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-17T05:58:59.000Z","updated_at":"2025-10-20T16:39:20.000Z","published_at":"2012-02-17T18:47:40.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn Matlab the code\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[ v = rand(1,3);\\n v = v/sum(v);]]\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eis sometimes suggested as a convenient means of generating three random variables, whose ranges are restricted to [0,1], which have a fixed sum of one. However, this procedure has the property that the area-wise density distribution of the three values, considered as cartesian coordinates in 3D space, is widely variable throughout the planar region of possible locations of v. For any given density value in the range of this density distribution, let A be the corresponding area of the subregion of all points whose density is less than or equal to this given value, and let P be the corresponding probability that v would lie in this subregion. The task is to write a function 'fixedsumarea' which receives P as an input and gives A as an output:\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[ A = fixedsumarea(P);]]\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou should assume that initially 'rand(1,3)' perfectly generates three independent random variables each uniformly distributed on [0,1], but subsequently each is modified by being divided by their mutual sum.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":8051,"title":"Stress-Strain Properties - 4","description":"A common measure of the ability of a material to carry load per unit mass is termed strength-to-weight ratio and is calculated by dividing the ultimate tensile strength of the material by its density. This property is key in weight-critical applications, such as aerospace, where many materials with high strength-to-weight ratios are used (e.g., Ni-based superalloys, Ti-based alloys, Al-based alloys, and composites).\r\n\r\nWrite a function to calculate the strength-to-weight ratio for a given material provided its ultimate tensile strength and density.\r\n\r\nPrevious problem: 3 - \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8050-stress-strain-properties-3 qualitative measure of brittleness\u003e. Next problem: 5 - \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8052-stress-strain-properties-5 stiffness-to-weight ratio\u003e.","description_html":"\u003cp\u003eA common measure of the ability of a material to carry load per unit mass is termed strength-to-weight ratio and is calculated by dividing the ultimate tensile strength of the material by its density. This property is key in weight-critical applications, such as aerospace, where many materials with high strength-to-weight ratios are used (e.g., Ni-based superalloys, Ti-based alloys, Al-based alloys, and composites).\u003c/p\u003e\u003cp\u003eWrite a function to calculate the strength-to-weight ratio for a given material provided its ultimate tensile strength and density.\u003c/p\u003e\u003cp\u003ePrevious problem: 3 - \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8050-stress-strain-properties-3\"\u003equalitative measure of brittleness\u003c/a\u003e. Next problem: 5 - \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8052-stress-strain-properties-5\"\u003estiffness-to-weight ratio\u003c/a\u003e.\u003c/p\u003e","function_template":"function [StWR] = stress_strain4(S_u,density)\r\n\r\nStWR = 1;\r\n\r\nend\r\n","test_suite":"%% Note\r\n% The following properties are measured at room temperature and are tensile\r\n% in a single direction. Some materials, such as metals are generally\r\n% isotropic, whereas others, like composite are highly anisotropic\r\n% (different properties in different directions). Also, property values can\r\n% range depending on the material grade. Finally, thermal or environmental\r\n% changes can alter these properties, sometimes drastically.\r\n\r\n%% steel alloy (ASTM A36)\r\nS_y = 250e6; %Pa\r\nS_u = 400e6; %Pa\r\ne_y = 0.00125;\r\ne_u = 0.35;\r\nnu = 0.26;\r\nG = 79.3e9; %Pa\r\nE = 200e9; %Pa\r\ndensity = 7.85; %g/cm^3\r\nsh_exp = 0.14; %strain-hardening exponent\r\nsh_coeff = 0.463; %strain-hardening coefficient\r\nStWR_corr = 5.096e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% titanium (Ti-6Al-4V)\r\nS_y = 830e6; %Pa\r\nS_u = 900e6; %Pa\r\ne_y = 0.00728;\r\ne_u = 0.14;\r\nnu = 0.342;\r\nG = 44e9; %Pa\r\nE = 114e9; %Pa\r\ndensity = 4.51; %g/cm^3\r\nsh_exp = 0.04; %strain-hardening exponent\r\nsh_coeff = 0.974; %strain-hardening coefficient\r\nStWR_corr = 19.96e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% Inconel 718\r\nS_y = 1172e6; %Pa\r\nS_u = 1407e6; %Pa\r\ne_y = 0.00563;\r\ne_u = 0.027;\r\nnu = 0.29;\r\nG = 11.6e9; %Pa\r\nE = 208e9; %Pa\r\ndensity = 8.19; %g/cm^3\r\nsh_exp = 0.075; %strain-hardening exponent\r\nsh_coeff = 1.845; %strain-hardening coefficient\r\nStWR_corr = 17.18e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% aluminum alloy (6061-T6)%^\u0026\r\nS_y = 241e6; %Pa\r\nS_u = 300e6; %Pa\r\ne_y = 0.0035;\r\ne_u = 0.15;\r\nnu = 0.33;\r\nG = 26e9; %Pa\r\nE = 68.9e9; %Pa\r\ndensity = 2.7; %g/cm^3\r\nsh_exp = 0.042; %strain-hardening exponent\r\nsh_coeff = 0.325; %strain-hardening coefficient\r\nStWR_corr = 11.11e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% copper\r\nS_y = 70e6; %Pa\r\nS_u = 220e6; %Pa\r\ne_y = 0.00054;\r\ne_u = 0.48;\r\nnu = 0.34;\r\nG = 48e9; %Pa\r\nE = 130e9; %Pa\r\ndensity = 8.92; %g/cm^3\r\nsh_exp = 0.44; %strain-hardening exponent\r\nsh_coeff = 0.304; %strain-hardening coefficient\r\nStWR_corr = 2.466e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% rhenium\r\nS_y = 317e6; %Pa\r\nS_u = 1130e6; %Pa\r\ne_y = 0.000685;\r\ne_u = 0.24;\r\nnu = 0.3;\r\nG = 178e9; %Pa\r\nE = 463e9; %Pa\r\ndensity = 21.02; %g/cm^3\r\nsh_exp = 0.353; %strain-hardening exponent\r\nsh_coeff = 1.870; %strain-hardening coefficient\r\nStWR_corr = 5.376e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% polymer (nylon, 6/6)\r\nS_y = 82e6; %Pa\r\nS_u = 82e6; %Pa\r\ne_y = 0.0265;\r\ne_u = 0.45;\r\nnu = 0.41;\r\nG = 2.8e9; %Pa\r\nE = 3.1e-2; %Pa\r\ndensity = 1.14; %g/cm^3\r\nStWR_corr = 7.193e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% polymer (nylon, 6/6) reinforced with 45wt.% glass fiber\r\nS_y = 230e6; %Pa\r\nS_u = 230e6; %Pa\r\ne_y = 0.016;\r\ne_u = 0.016;\r\nnu = 0.35;\r\nG = 13.0e9; %Pa\r\nE = 14.5e9; %Pa\r\ndensity = 1.51; %g/cm^3\r\nStWR_corr = 15.23e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%% diamond\r\nS_y = 1200e6; %Pa\r\nS_u = 1200e6; %Pa\r\ne_y = 0.001;\r\ne_u = 0.001;\r\nnu = 0.20;\r\nG = 478e9; %Pa\r\nE = 1200e9; %Pa\r\ndensity = 3.51; %g/cm^3\r\nStWR_corr = 34.19e7;\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tS_u = 400e6; %Pa\r\n\t\tdensity = 7.85; %g/cm^3\r\n\t\tStWR_corr = 5.096e7;\r\n\tcase 2\r\n\t\tS_u = 230e6; %Pa\r\n\t\tdensity = 1.51; %g/cm^3\r\n\t\tStWR_corr = 15.23e7;\r\n\tcase 3\r\n\t\tS_u = 1130e6; %Pa\r\n\t\tdensity = 21.02; %g/cm^3\r\n\t\tStWR_corr = 5.376e7;\r\n\tcase 4\r\n\t\tS_u = 1200e6; %Pa\r\n\t\tdensity = 3.51; %g/cm^3\r\n\t\tStWR_corr = 34.19e7;\r\nend\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tS_u = 300e6; %Pa\r\n\t\tdensity = 2.7; %g/cm^3\r\n\t\tStWR_corr = 11.11e7;\r\n\tcase 2\r\n\t\tS_u = 900e6; %Pa\r\n\t\tdensity = 4.51; %g/cm^3\r\n\t\tStWR_corr = 19.96e7;\r\n\tcase 3\r\n\t\tS_u = 220e6; %Pa\r\n\t\tdensity = 8.92; %g/cm^3\r\n\t\tStWR_corr = 2.466e7;\r\n\tcase 4\r\n\t\tS_u = 230e6; %Pa\r\n\t\tdensity = 1.51; %g/cm^3\r\n\t\tStWR_corr = 15.23e7;\r\nend\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tS_u = 300e6; %Pa\r\n\t\tdensity = 2.7; %g/cm^3\r\n\t\tStWR_corr = 11.11e7;\r\n\tcase 2\r\n\t\tS_u = 1200e6; %Pa\r\n\t\tdensity = 3.51; %g/cm^3\r\n\t\tStWR_corr = 34.19e7;\r\n\tcase 3\r\n\t\tS_u = 82e6; %Pa\r\n\t\tdensity = 1.14; %g/cm^3\r\n\t\tStWR_corr = 7.193e7;\r\n\tcase 4\r\n\t\tS_u = 900e6; %Pa\r\n\t\tdensity = 4.51; %g/cm^3\r\n\t\tStWR_corr = 19.96e7;\r\nend\r\nassert(abs(stress_strain4(S_u,density)-StWR_corr)/StWR_corr\u003c1e-2)\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":222,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-03-30T19:24:41.000Z","updated_at":"2026-03-10T20:20:32.000Z","published_at":"2015-03-30T19:24:41.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 common measure of the ability of a material to carry load per unit mass is termed strength-to-weight ratio and is calculated by dividing the ultimate tensile strength of the material by its density. This property is key in weight-critical applications, such as aerospace, where many materials with high strength-to-weight ratios are used (e.g., Ni-based superalloys, Ti-based alloys, Al-based alloys, and composites).\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 to calculate the strength-to-weight ratio for a given material provided its ultimate tensile strength and density.\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\u003ePrevious problem: 3 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8050-stress-strain-properties-3\\\"\u003e\u003cw:r\u003e\u003cw:t\u003equalitative measure of brittleness\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. Next problem: 5 -\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8052-stress-strain-properties-5\\\"\u003e\u003cw:r\u003e\u003cw:t\u003estiffness-to-weight ratio\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\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\"}]}"},{"id":331,"title":"Compute Area from Fixed Sum Cumulative Probability","description":"In Matlab the code\r\n v = rand(1,3);\r\n v = v/sum(v);\r\nis sometimes suggested as a convenient means of generating three random variables, whose ranges are restricted to [0,1], which have a fixed sum of one. However, this procedure has the property that the area-wise density distribution of the three values, considered as cartesian coordinates in 3D space, is widely variable throughout the planar region of possible locations of v. For any given density value in the range of this density distribution, let A be the corresponding area of the subregion of all points whose density is less than or equal to this given value, and let P be the corresponding probability that v would lie in this subregion. The task is to write a function 'fixedsumarea' which receives P as an input and gives A as an output:\r\n A = fixedsumarea(P);\r\nYou should assume that initially 'rand(1,3)' perfectly generates three independent random variables each uniformly distributed on [0,1], but subsequently each is modified by being divided by their mutual sum.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 311.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 155.65px; transform-origin: 407px 155.65px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58px 8px; transform-origin: 58px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn Matlab the code\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e v = rand(1,3);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e v = v/sum(v);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 147px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 73.5px; text-align: left; transform-origin: 384px 73.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 371.5px 8px; transform-origin: 371.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eis sometimes suggested as a convenient means of generating three random variables, whose ranges are restricted to [0,1], which have a fixed sum of one. However, this procedure has the property that the area-wise density distribution of the three values, considered as cartesian coordinates in 3D space, is widely variable throughout the planar region of possible locations of v. For any given density value in the range of this density distribution, let A be the corresponding area of the subregion of all points whose density is less than or equal to this given value, and let P be the corresponding probability that v would lie in this subregion. The task is to write a function 'fixedsumarea' which receives P as an input and gives A as an output:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 84px 8.5px; tab-size: 4; transform-origin: 84px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e A = fixedsumarea(P);\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 362.5px 8px; transform-origin: 362.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou should assume that initially 'rand(1,3)' perfectly generates three independent random variables each uniformly distributed on [0,1], but subsequently each is modified by being divided by their mutual sum.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function A = fixedsumarea(P)\r\n  P = 1/2;\r\n  A = 0;\r\nend","test_suite":"%%\r\nfiletext = fileread('fixedsumarea.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'elseif') || contains(filetext, 'switch ');\r\nassert(~illegal)\r\n\r\n%%\r\nP = pi/4;\r\nA_correct = 0.7984235067141288;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = 1/sqrt(11);\r\nA_correct = 0.4964013344766580;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = exp(-3);\r\nA_correct = 0.1494793760894695;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = (1/27)^(1/5);\r\nA_correct = 0.6605992894366502;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = sin(sqrt(2));\r\nA_correct = 0.8634048022602919;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n%%\r\nP = 68/137;\r\nA_correct = 0.6471420329484348;\r\nassert(abs(fixedsumarea(P)-A_correct)\u003c100*eps)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":7,"created_by":28,"edited_by":223089,"edited_at":"2023-02-21T09:48:12.000Z","deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2023-02-21T09:48:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-17T05:58:59.000Z","updated_at":"2025-10-20T16:39:20.000Z","published_at":"2012-02-17T18:47:40.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn Matlab the code\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[ v = rand(1,3);\\n v = v/sum(v);]]\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eis sometimes suggested as a convenient means of generating three random variables, whose ranges are restricted to [0,1], which have a fixed sum of one. However, this procedure has the property that the area-wise density distribution of the three values, considered as cartesian coordinates in 3D space, is widely variable throughout the planar region of possible locations of v. For any given density value in the range of this density distribution, let A be the corresponding area of the subregion of all points whose density is less than or equal to this given value, and let P be the corresponding probability that v would lie in this subregion. The task is to write a function 'fixedsumarea' which receives P as an input and gives A as an output:\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[ A = fixedsumarea(P);]]\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou should assume that initially 'rand(1,3)' perfectly generates three independent random variables each uniformly distributed on [0,1], but subsequently each is modified by being divided by their mutual sum.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"density\"","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:\"density\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"density\"","","\"","density","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fac4507ef60\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fac4507eec0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fac4507e600\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fac4507f1e0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fac4507f140\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fac4507f0a0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fac4507f000\u003e":"tag:\"density\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fac4507f000\u003e":"tag:\"density\""},"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":"search","password":"J3bGPZzQ7asjJcCk","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:\"density\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"density\"","","\"","density","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fac4507ef60\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fac4507eec0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fac4507e600\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fac4507f1e0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fac4507f140\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fac4507f0a0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fac4507f000\u003e":"tag:\"density\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fac4507f000\u003e":"tag:\"density\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":8051,"difficulty_rating":"easy"},{"id":331,"difficulty_rating":"hard"}]}}