{"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":2774,"title":"Rule of mixtures (composites) - upper bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate this bound for various values.","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eBased on these values, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate this bound for various values.\u003c/p\u003e","function_template":"function Ec = rule_of_mixtures_upper_bound(Ef,Em,ff)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),37))\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),29.8))\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),23.5))\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),307))\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),227.8))\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),158.5))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":129,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:06:34.000Z","updated_at":"2026-02-13T03:46:57.000Z","published_at":"2014-12-14T04:06:34.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eBased on these values, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 this bound for various values.\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":2777,"title":"Rule of mixtures (composites) - either bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate either bound, depending on which bound is requested in the input string.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cpre\u003e    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/pre\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate either bound, depending on which bound is requested in the input string.\u003c/p\u003e","function_template":"function [Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nb_str = 'lower';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 13.6986) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\nb_str = 'L';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 12.4688) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nb_str = 'Upper';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 23.5) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nb_str = 'Lower';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 14.2248) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\nb_str = 'u';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 227.8) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nb_str = 'upper';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 158.5) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":78,"test_suite_updated_at":"2014-12-16T23:04:03.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:54:34.000Z","updated_at":"2026-02-13T03:58:28.000Z","published_at":"2014-12-14T04:54:34.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\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[    Ef: elastic modulus of the fiber material\\n    Em: elastic modulus of the matrix material\\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)]]\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 either bound, depending on which bound is requested in the input string.\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":2778,"title":"Rule of mixtures (composites) - lower and upper bounds (volumes)","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nSometimes, the volume fraction is not known and must be calculated from known volumes (Vf and Vm). In this case, ff = Vf / (Vf + Vm).\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate either bound, depending on which bound is requested in the input string and using the known volumes.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cpre\u003e    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/pre\u003e\u003cp\u003eSometimes, the volume fraction is not known and must be calculated from known volumes (Vf and Vm). In this case, ff = Vf / (Vf + Vm).\u003c/p\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate either bound, depending on which bound is requested in the input string and using the known volumes.\u003c/p\u003e","function_template":"function [Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nVf = 30;\r\nVm = 70;\r\nb_str = 'lower';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 13.6986) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nVf = 11;\r\nVm = 39;\r\nb_str = 'L';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 12.4688) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nVf = 150;\r\nVm = 850;\r\nb_str = 'Lower';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 11.5607) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nVf = 3;\r\nVm = 7;\r\nb_str = 'U';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 307) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nVf = 2.2;\r\nVm = 7.8;\r\nb_str = 'lower bound';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 12.7845) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nVf = 30;\r\nVm = 170;\r\nb_str = 'U bound';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 158.5) \u003c 1e-4)\r\n\r\n%%\r\nEf = 57;\r\nEm = 3.9;\r\nVf = 1.27;\r\nVm = 9;\r\nb_str = 'Lower';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 4.4078) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":"2014-12-16T23:05:00.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T05:06:25.000Z","updated_at":"2026-02-13T04:00:39.000Z","published_at":"2014-12-14T05:06:25.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\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[    Ef: elastic modulus of the fiber material\\n    Em: elastic modulus of the matrix material\\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)]]\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\u003eSometimes, the volume fraction is not known and must be calculated from known volumes (Vf and Vm). In this case, ff = Vf / (Vf + Vm).\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 either bound, depending on which bound is requested in the input string and using the known volumes.\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":2776,"title":"Rule of mixtures (composites) - lower and upper bounds","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate both bounds for various values. Also, return the difference between the modulus estimates and the ratios of this difference to both moduli estimates.","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cpre\u003e    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/pre\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate both bounds for various values. Also, return the difference between the modulus estimates and the ratios of this difference to both moduli estimates.\u003c/p\u003e","function_template":"function [Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff)\r\n Ec_l = 1;\r\n Ec_u = 1;\r\n E_diff = 1;\r\n r_l = 1;\r\n r_u = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 13.6986) \u003c 1e-4)\r\nassert(abs(Ec_u - 37) \u003c 1e-4)\r\nassert(abs(E_diff - 23.3014) \u003c 1e-4)\r\nassert(abs(r_l - 1.7010) \u003c 1e-4)\r\nassert(abs(r_u - .6298) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 12.4688) \u003c 1e-4)\r\nassert(abs(Ec_u - 29.8) \u003c 1e-4)\r\nassert(abs(E_diff - 17.3312) \u003c 1e-4)\r\nassert(abs(r_l - 1.3900) \u003c 1e-4)\r\nassert(abs(r_u - 0.5816) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 11.5607) \u003c 1e-4)\r\nassert(abs(Ec_u - 23.5) \u003c 1e-4)\r\nassert(abs(E_diff - 11.9393) \u003c 1e-4)\r\nassert(abs(r_l - 1.0327) \u003c 1e-4)\r\nassert(abs(r_u - 0.5081) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 14.2248) \u003c 1e-4)\r\nassert(abs(Ec_u - 307) \u003c 1e-4)\r\nassert(abs(E_diff - 292.7752) \u003c 1e-4)\r\nassert(abs(r_l - 20.5821) \u003c 1e-4)\r\nassert(abs(r_u - 0.9537) \u003c 1e-4)\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 12.7845) \u003c 1e-4)\r\nassert(abs(Ec_u - 227.8) \u003c 1e-4)\r\nassert(abs(E_diff - 215.0155) \u003c 1e-4)\r\nassert(abs(r_l - 16.8185) \u003c 1e-4)\r\nassert(abs(r_u - 0.9439) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 11.7440) \u003c 1e-4)\r\nassert(abs(Ec_u - 158.5) \u003c 1e-4)\r\nassert(abs(E_diff - 146.756) \u003c 1e-4)\r\nassert(abs(r_l - 12.4963) \u003c 1e-4)\r\nassert(abs(r_u - 0.9259) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":94,"test_suite_updated_at":"2014-12-16T22:53:00.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:43:12.000Z","updated_at":"2026-02-13T03:51:00.000Z","published_at":"2014-12-14T04:43:12.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\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[    Ef: elastic modulus of the fiber material\\n    Em: elastic modulus of the matrix material\\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)]]\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 both bounds for various values. Also, return the difference between the modulus estimates and the ratios of this difference to both moduli estimates.\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":2775,"title":"Rule of mixtures (composites) - lower bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nWrite a function to calculate this bound for various values.","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eWrite a function to calculate this bound for various values.\u003c/p\u003e","function_template":"function Ec = rule_of_mixtures_lower_bound(Ef,Em,ff)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 13.6986) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 12.4688) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 11.5607) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 14.2248) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 12.7845) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 11.7440) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":183,"test_suite_updated_at":"2014-12-16T22:51:58.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:09:25.000Z","updated_at":"2026-02-13T03:46:16.000Z","published_at":"2014-12-14T04:14:32.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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 this bound for various values.\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":2779,"title":"Rule of mixtures (composites) - weighted bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate the weighted Ec between both bounds, based on the provided weighting (wt) of the upper bound. (The lower bound will have the remainder of the weighting, or 1–wt.)\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate the weighted Ec between both bounds, based on the provided weighting (wt) of the upper bound. (The lower bound will have the remainder of the weighting, or 1–wt.)\u003c/p\u003e","function_template":"function [Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 19.5240) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 25.3493) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 31.1747) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 14.5455) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 17.5303) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 20.5152) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 87.4186) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 160.6124) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 233.8062) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 48.4330) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 85.1220) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 121.8110) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":94,"test_suite_updated_at":"2014-12-16T23:05:34.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-16T04:22:51.000Z","updated_at":"2026-02-13T07:13:31.000Z","published_at":"2014-12-16T04:22:51.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 weighted Ec between both bounds, based on the provided weighting (wt) of the upper bound. (The lower bound will have the remainder of the weighting, or 1–wt.)\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":2780,"title":"Rule of mixtures (composites) - other bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nYou are provided with the estimated elastic modulus at one bound. Determine if it is the lower or upper bound, based on the provided material properties, and return which bound was provided (0 = lower, 1 = upper) and the value for the other bound.\r\n\r\nThe lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nThe upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou are provided with the estimated elastic modulus at one bound. Determine if it is the lower or upper bound, based on the provided material properties, and return which bound was provided (0 = lower, 1 = upper) and the value for the other bound.\u003c/p\u003e\u003cp\u003eThe lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eThe upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e","function_template":"function [Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff)\r\n Ec_other = 1;\r\nend","test_suite":"%%\r\nEc = 37;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 13.6986) \u003c 1e-4)\r\nassert(u_or_l == 1)\r\n\r\n%%\r\nEc = 13.6986;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 37) \u003c 1e-4)\r\nassert(u_or_l == 0)\r\n\r\n%%\r\nEc = 23.5;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 11.5607) \u003c 1e-4)\r\nassert(u_or_l == 1)\r\n\r\n%%\r\nEc = 11.5607;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 23.5) \u003c 1e-4)\r\nassert(u_or_l == 0)\r\n\r\n%%\r\nEc = 11.7440;\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 158.5) \u003c 1e-4)\r\nassert(u_or_l == 0)\r\n\r\n%%\r\nEc = 158.5;\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 11.7440) \u003c 1e-4)\r\nassert(u_or_l == 1)\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":"2014-12-16T23:06:11.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-16T04:42:12.000Z","updated_at":"2026-02-13T07:37:07.000Z","published_at":"2014-12-16T04:42:12.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eYou are provided with the estimated elastic modulus at one bound. Determine if it is the lower or upper bound, based on the provided material properties, and return which bound was provided (0 = lower, 1 = upper) and the value for the other bound.\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 lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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 upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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":2781,"title":"Rule of mixtures (composites) - reverse engineering","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nSuppose that you are reverse engineering a composite article. You've tested coupons from the article to determine Ec and taken sections to determine the material properties and volume fraction for the fiber material. Using the known values, calculate modulus estimates for the matrix material based on both weightings of upper- and lower-bounds. Provide values for (upper-bound) weightings of 0, 1/4, 1/2, 3/4, and 1 (weighting is not related to fiber fraction or material volume).\r\n\r\nThe lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em)   [eq.1]\r\n\r\nThe upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em   [eq.2]\r\n\r\nFor example, for each test case you will calculate Em_l, the lower-bound matrix elastic modulus extrapolated by eq.1, and Em_u, the upper-bound matrix elastic modulus extrapolated by eq.2. The weighted matrix elastic modulus is given by Em = wt * Em_u + (1-wt) * Em_l. For a weighting of 1/4, the weighted modulus is therefore given by Em = 0.25 * Em_u + 0.75 * Em_l.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eSuppose that you are reverse engineering a composite article. You've tested coupons from the article to determine Ec and taken sections to determine the material properties and volume fraction for the fiber material. Using the known values, calculate modulus estimates for the matrix material based on both weightings of upper- and lower-bounds. Provide values for (upper-bound) weightings of 0, 1/4, 1/2, 3/4, and 1 (weighting is not related to fiber fraction or material volume).\u003c/p\u003e\u003cp\u003eThe lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em)   [eq.1]\u003c/p\u003e\u003cp\u003eThe upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em   [eq.2]\u003c/p\u003e\u003cp\u003eFor example, for each test case you will calculate Em_l, the lower-bound matrix elastic modulus extrapolated by eq.1, and Em_u, the upper-bound matrix elastic modulus extrapolated by eq.2. The weighted matrix elastic modulus is given by Em = wt * Em_u + (1-wt) * Em_l. For a weighting of 1/4, the weighted modulus is therefore given by Em = 0.25 * Em_u + 0.75 * Em_l.\u003c/p\u003e","function_template":"function [Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff)\r\n Em = ones(5,1);\r\nend","test_suite":"%%\r\nEc = 35.4;\r\nEf = 100;\r\nff = 0.30;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [7.7143   12.7168   17.7193   22.7218   27.7243])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 85.1;\r\nEf = 250;\r\nff = 0.20;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [43.8750   51.1696   58.4642   65.7589   73.0535])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 155.5;\r\nEf = 1000;\r\nff = 0.05;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [111.0526  120.5101  129.9676  139.4251  148.8826])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 27.6;\r\nEf = 100;\r\nff = 0.10;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [19.5556   21.0529   22.5503   24.0477   25.5450])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 204.9;\r\nEf = 1000;\r\nff = 0.15;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [64.5882   93.3631  122.1380  150.9128  179.6877])) \u003c 1e-2)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":6,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":"2014-12-16T23:18:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-16T05:33:10.000Z","updated_at":"2026-02-13T10:45:04.000Z","published_at":"2014-12-16T05:33: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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eSuppose that you are reverse engineering a composite article. You've tested coupons from the article to determine Ec and taken sections to determine the material properties and volume fraction for the fiber material. Using the known values, calculate modulus estimates for the matrix material based on both weightings of upper- and lower-bounds. Provide values for (upper-bound) weightings of 0, 1/4, 1/2, 3/4, and 1 (weighting is not related to fiber fraction or material volume).\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 lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em) [eq.1]\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 upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em [eq.2]\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\u003eFor example, for each test case you will calculate Em_l, the lower-bound matrix elastic modulus extrapolated by eq.1, and Em_u, the upper-bound matrix elastic modulus extrapolated by eq.2. The weighted matrix elastic modulus is given by Em = wt * Em_u + (1-wt) * Em_l. For a weighting of 1/4, the weighted modulus is therefore given by Em = 0.25 * Em_u + 0.75 * Em_l.\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":54755,"title":"List odd twin composites","description":"Twin primes, or prime numbers that differ by 2 (e.g., 17 and 19, 59 and 61, or 191 and 193), are the subject of several Cody problems: 248, 1096, 3016, and 52298. (See also Cody Problem 53740 for “almost twin primes”.)\r\nThis problem deals with twin composites. Because all even numbers are twin composites, let’s focus on odd twin composites, such as 25 and 27, 63 and 65, and 169 and 171. \r\nWrite a function that takes a number and produces a two-column matrix with the smaller number of the odd twin composite pair in the first column and the larger in the second column. \r\nOptional exercises: (a) prove that the number of odd twin composites is infinite, (b) prove that the number of twin primes is infinite. ","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: 195px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97.5px; transform-origin: 407px 97.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; 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 21px; text-align: left; transform-origin: 384px 21px; 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: 383.775px 8px; transform-origin: 383.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTwin primes, or prime numbers that differ by 2 (e.g., 17 and 19, 59 and 61, or 191 and 193), are the subject of several Cody problems: \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/248\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e248\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/1096\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e1096\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3016\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e3016\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 17.5px 8px; transform-origin: 17.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/52298\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e52298\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 35.3917px 8px; transform-origin: 35.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. (See also \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/53740\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 53740\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 78.95px 8px; transform-origin: 78.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e for “almost twin primes”.)\u003c/span\u003e\u003c/span\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: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 349.95px 8px; transform-origin: 349.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem deals with twin composites. Because all even numbers are twin composites, let’s focus on odd twin composites, such as 25 and 27, 63 and 65, and 169 and 171. \u003c/span\u003e\u003c/span\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: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 380.667px 8px; transform-origin: 380.667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that takes a number and produces a two-column matrix with the smaller number of the odd twin composite pair in the first column and the larger in the second column. \u003c/span\u003e\u003c/span\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: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 379.617px 8px; transform-origin: 379.617px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOptional exercises: (a) prove that the number of odd twin composites is infinite, (b) prove that the number of twin primes is infinite. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = twinComposites(n)\r\n  y = ~isprimes(1:2:n);\r\nend","test_suite":"%%\r\nn = 100;\r\ny = twinComposites(n);\r\ny_correct = [25 27; 33 35; 49 51; 55 57; 63 65; 75 77; 85 87; 91 93; 93 95];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 1000;\r\ny = twinComposites(n);\r\nlen_correct = 200;\r\nmean_correct = [545.84 547.84];\r\nassert(isequal(length(y),len_correct) \u0026\u0026 isequal(mean(y),mean_correct))\r\n\r\n%%\r\nn = 10000;\r\ny = twinComposites(n);\r\nyi_correct = [121 123; 695 697; 1183 1185; 1659 1661; 2093 2095; 2523 2525; 2979 2981; 3383 3385; 3811 3813; 4213 4215; 4615 4617; 5035 5037; 5433 5435; 5871 5873; 6253 6255; 6655 6657; 7073 7075; 7429 7431; 7855 7857; 8249 8251; 8631 8633; 9051 9053; 9453 9455; 9863 9865];\r\nassert(isequal(y(13:117:2748,:),yi_correct))\r\n\r\n%%\r\nn = 100000;\r\ny = twinComposites(n);\r\nyi_correct = [1387 1389; 6921 6923; 12077 12079; 17161 17163; 22099 22101; 27007 27009; 31807 31809; 36615 36617; 41403 41405; 46161 46163; 50875 50877; 55569 55571; 60357 60359; 64973 64975; 69619 69621; 74303 74305; 78953 78955; 83583 83585; 88157 88159; 92797 92799; 97399 97401];\r\nassert(isequal(y(300:1543:length(y),:),yi_correct))\r\n\r\n%%\r\nn = 1e8;\r\ny = twinComposites(n);\r\nyi_correct = [165453 165455; 5402289 5402291; 10497039 10497041; 15545075 15545077; 20564337 20564339; 25562343 25562345; 30545611 30545613; 35513869 35513871; 40472875 40472877; 45421809 45421811; 50362465 50362467; 55295281 55295283; 60222207 60222209; 65142869 65142871; 70058737 70058739; 74969567 74969569; 79875045 79875047; 84776713 84776715; 89673895 89673897; 94567305 94567307; 99457437 99457439];\r\nassert(isequal(y(54321:1932439:length(y),:),yi_correct))\r\n\r\n%%\r\nn = 2500;\r\ny = twinComposites(n);\r\nz = twinComposites(y(900)^2);\r\na = prod(factor(z(654321,1))+factor(z(654321,2)));\r\na_correct = 17376480;\r\nassert(isequal(a,a_correct))\r\n\r\n%%\r\nfiletext = fileread('twinComposites.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp') || contains(filetext,'read'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2022-06-15T03:49:28.000Z","deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-06-15T03:47:54.000Z","updated_at":"2025-09-30T08:35:42.000Z","published_at":"2022-06-15T03:49:28.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\u003eTwin primes, or prime numbers that differ by 2 (e.g., 17 and 19, 59 and 61, or 191 and 193), are the subject of several Cody problems: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/248\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e248\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\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1096\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1096\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\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3016\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3016\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/52298\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e52298\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (See also \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/53740\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 53740\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for “almost twin primes”.)\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\u003eThis problem deals with twin composites. Because all even numbers are twin composites, let’s focus on odd twin composites, such as 25 and 27, 63 and 65, and 169 and 171. \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\u003eWrite a function that takes a number and produces a two-column matrix with the smaller number of the odd twin composite pair in the first column and the larger in the second column. \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\u003eOptional exercises: (a) prove that the number of odd twin composites is infinite, (b) prove that the number of twin primes is infinite. \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":2774,"title":"Rule of mixtures (composites) - upper bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate this bound for various values.","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eBased on these values, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate this bound for various values.\u003c/p\u003e","function_template":"function Ec = rule_of_mixtures_upper_bound(Ef,Em,ff)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),37))\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),29.8))\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),23.5))\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),307))\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),227.8))\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nassert(isequal(rule_of_mixtures_upper_bound(Ef,Em,ff),158.5))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":129,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:06:34.000Z","updated_at":"2026-02-13T03:46:57.000Z","published_at":"2014-12-14T04:06:34.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eBased on these values, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 this bound for various values.\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":2777,"title":"Rule of mixtures (composites) - either bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate either bound, depending on which bound is requested in the input string.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cpre\u003e    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/pre\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate either bound, depending on which bound is requested in the input string.\u003c/p\u003e","function_template":"function [Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nb_str = 'lower';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 13.6986) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\nb_str = 'L';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 12.4688) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nb_str = 'Upper';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 23.5) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nb_str = 'Lower';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 14.2248) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\nb_str = 'u';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 227.8) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nb_str = 'upper';\r\n[Ec] = rule_of_mixtures_either_bound(b_str,Ef,Em,ff);\r\nassert(abs(Ec - 158.5) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":78,"test_suite_updated_at":"2014-12-16T23:04:03.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:54:34.000Z","updated_at":"2026-02-13T03:58:28.000Z","published_at":"2014-12-14T04:54:34.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\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[    Ef: elastic modulus of the fiber material\\n    Em: elastic modulus of the matrix material\\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)]]\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 either bound, depending on which bound is requested in the input string.\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":2778,"title":"Rule of mixtures (composites) - lower and upper bounds (volumes)","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nSometimes, the volume fraction is not known and must be calculated from known volumes (Vf and Vm). In this case, ff = Vf / (Vf + Vm).\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate either bound, depending on which bound is requested in the input string and using the known volumes.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cpre\u003e    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/pre\u003e\u003cp\u003eSometimes, the volume fraction is not known and must be calculated from known volumes (Vf and Vm). In this case, ff = Vf / (Vf + Vm).\u003c/p\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate either bound, depending on which bound is requested in the input string and using the known volumes.\u003c/p\u003e","function_template":"function [Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nVf = 30;\r\nVm = 70;\r\nb_str = 'lower';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 13.6986) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nVf = 11;\r\nVm = 39;\r\nb_str = 'L';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 12.4688) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nVf = 150;\r\nVm = 850;\r\nb_str = 'Lower';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 11.5607) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nVf = 3;\r\nVm = 7;\r\nb_str = 'U';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 307) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nVf = 2.2;\r\nVm = 7.8;\r\nb_str = 'lower bound';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 12.7845) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nVf = 30;\r\nVm = 170;\r\nb_str = 'U bound';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 158.5) \u003c 1e-4)\r\n\r\n%%\r\nEf = 57;\r\nEm = 3.9;\r\nVf = 1.27;\r\nVm = 9;\r\nb_str = 'Lower';\r\n[Ec] = rule_of_mixtures_either_bound_vol(b_str,Ef,Em,Vf,Vm);\r\nassert(abs(Ec - 4.4078) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":"2014-12-16T23:05:00.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T05:06:25.000Z","updated_at":"2026-02-13T04:00:39.000Z","published_at":"2014-12-14T05:06:25.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\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[    Ef: elastic modulus of the fiber material\\n    Em: elastic modulus of the matrix material\\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)]]\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\u003eSometimes, the volume fraction is not known and must be calculated from known volumes (Vf and Vm). In this case, ff = Vf / (Vf + Vm).\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 either bound, depending on which bound is requested in the input string and using the known volumes.\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":2776,"title":"Rule of mixtures (composites) - lower and upper bounds","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate both bounds for various values. Also, return the difference between the modulus estimates and the ratios of this difference to both moduli estimates.","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cpre\u003e    Ef: elastic modulus of the fiber material\r\n    Em: elastic modulus of the matrix material\r\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/pre\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate both bounds for various values. Also, return the difference between the modulus estimates and the ratios of this difference to both moduli estimates.\u003c/p\u003e","function_template":"function [Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff)\r\n Ec_l = 1;\r\n Ec_u = 1;\r\n E_diff = 1;\r\n r_l = 1;\r\n r_u = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 13.6986) \u003c 1e-4)\r\nassert(abs(Ec_u - 37) \u003c 1e-4)\r\nassert(abs(E_diff - 23.3014) \u003c 1e-4)\r\nassert(abs(r_l - 1.7010) \u003c 1e-4)\r\nassert(abs(r_u - .6298) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 12.4688) \u003c 1e-4)\r\nassert(abs(Ec_u - 29.8) \u003c 1e-4)\r\nassert(abs(E_diff - 17.3312) \u003c 1e-4)\r\nassert(abs(r_l - 1.3900) \u003c 1e-4)\r\nassert(abs(r_u - 0.5816) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 11.5607) \u003c 1e-4)\r\nassert(abs(Ec_u - 23.5) \u003c 1e-4)\r\nassert(abs(E_diff - 11.9393) \u003c 1e-4)\r\nassert(abs(r_l - 1.0327) \u003c 1e-4)\r\nassert(abs(r_u - 0.5081) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 14.2248) \u003c 1e-4)\r\nassert(abs(Ec_u - 307) \u003c 1e-4)\r\nassert(abs(E_diff - 292.7752) \u003c 1e-4)\r\nassert(abs(r_l - 20.5821) \u003c 1e-4)\r\nassert(abs(r_u - 0.9537) \u003c 1e-4)\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 12.7845) \u003c 1e-4)\r\nassert(abs(Ec_u - 227.8) \u003c 1e-4)\r\nassert(abs(E_diff - 215.0155) \u003c 1e-4)\r\nassert(abs(r_l - 16.8185) \u003c 1e-4)\r\nassert(abs(r_u - 0.9439) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_l,Ec_u,E_diff,r_l,r_u] = rule_of_mixtures_l_and_u_bound(Ef,Em,ff);\r\nassert(abs(Ec_l - 11.7440) \u003c 1e-4)\r\nassert(abs(Ec_u - 158.5) \u003c 1e-4)\r\nassert(abs(E_diff - 146.756) \u003c 1e-4)\r\nassert(abs(r_l - 12.4963) \u003c 1e-4)\r\nassert(abs(r_u - 0.9259) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":94,"test_suite_updated_at":"2014-12-16T22:53:00.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:43:12.000Z","updated_at":"2026-02-13T03:51:00.000Z","published_at":"2014-12-14T04:43:12.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\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[    Ef: elastic modulus of the fiber material\\n    Em: elastic modulus of the matrix material\\n    ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)]]\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 both bounds for various values. Also, return the difference between the modulus estimates and the ratios of this difference to both moduli estimates.\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":2775,"title":"Rule of mixtures (composites) - lower bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nWrite a function to calculate this bound for various values.","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eWrite a function to calculate this bound for various values.\u003c/p\u003e","function_template":"function Ec = rule_of_mixtures_lower_bound(Ef,Em,ff)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 13.6986) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.22;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 12.4688) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 11.5607) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 14.2248) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.22;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 12.7845) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nassert(abs(rule_of_mixtures_lower_bound(Ef,Em,ff) - 11.7440) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":183,"test_suite_updated_at":"2014-12-16T22:51:58.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-14T04:09:25.000Z","updated_at":"2026-02-13T03:46:16.000Z","published_at":"2014-12-14T04:14:32.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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 this bound for various values.\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":2779,"title":"Rule of mixtures (composites) - weighted bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nBased on these values, the lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n\r\nWrite a function to calculate the weighted Ec between both bounds, based on the provided weighting (wt) of the upper bound. (The lower bound will have the remainder of the weighting, or 1–wt.)\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e\u003cp\u003eWrite a function to calculate the weighted Ec between both bounds, based on the provided weighting (wt) of the upper bound. (The lower bound will have the remainder of the weighting, or 1–wt.)\u003c/p\u003e","function_template":"function [Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt)\r\n Ec = 1;\r\nend","test_suite":"%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 19.5240) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 25.3493) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 31.1747) \u003c 1e-4)\r\n\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 14.5455) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 17.5303) \u003c 1e-4)\r\n\r\n%%\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 20.5152) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 87.4186) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 160.6124) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.30;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 233.8062) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.25;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 48.4330) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.50;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 85.1220) \u003c 1e-4)\r\n\r\n%%\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\nwt = 0.75;\r\n[Ec] = rule_of_mixtures_wt_bound(Ef,Em,ff,wt);\r\nassert(abs(Ec - 121.8110) \u003c 1e-4)\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":94,"test_suite_updated_at":"2014-12-16T23:05:34.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-16T04:22:51.000Z","updated_at":"2026-02-13T07:13:31.000Z","published_at":"2014-12-16T04:22:51.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eBased on these values, the lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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\u003eOn the other hand, the upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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 weighted Ec between both bounds, based on the provided weighting (wt) of the upper bound. (The lower bound will have the remainder of the weighting, or 1–wt.)\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":2780,"title":"Rule of mixtures (composites) - other bound","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nYou are provided with the estimated elastic modulus at one bound. Determine if it is the lower or upper bound, based on the provided material properties, and return which bound was provided (0 = lower, 1 = upper) and the value for the other bound.\r\n\r\nThe lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em).\r\n\r\nThe upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou are provided with the estimated elastic modulus at one bound. Determine if it is the lower or upper bound, based on the provided material properties, and return which bound was provided (0 = lower, 1 = upper) and the value for the other bound.\u003c/p\u003e\u003cp\u003eThe lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\u003c/p\u003e\u003cp\u003eThe upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em.\u003c/p\u003e","function_template":"function [Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff)\r\n Ec_other = 1;\r\nend","test_suite":"%%\r\nEc = 37;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 13.6986) \u003c 1e-4)\r\nassert(u_or_l == 1)\r\n\r\n%%\r\nEc = 13.6986;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.30;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 37) \u003c 1e-4)\r\nassert(u_or_l == 0)\r\n\r\n%%\r\nEc = 23.5;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 11.5607) \u003c 1e-4)\r\nassert(u_or_l == 1)\r\n\r\n%%\r\nEc = 11.5607;\r\nEf = 100;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 23.5) \u003c 1e-4)\r\nassert(u_or_l == 0)\r\n\r\n%%\r\nEc = 11.7440;\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 158.5) \u003c 1e-4)\r\nassert(u_or_l == 0)\r\n\r\n%%\r\nEc = 158.5;\r\nEf = 1000;\r\nEm = 10;\r\nff = 0.15;\r\n[Ec_other,u_or_l] = rule_of_mixtures_opp_bound(Ec,Ef,Em,ff);\r\nassert(abs(Ec_other - 11.7440) \u003c 1e-4)\r\nassert(u_or_l == 1)\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":"2014-12-16T23:06:11.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-16T04:42:12.000Z","updated_at":"2026-02-13T07:37:07.000Z","published_at":"2014-12-16T04:42:12.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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eYou are provided with the estimated elastic modulus at one bound. Determine if it is the lower or upper bound, based on the provided material properties, and return which bound was provided (0 = lower, 1 = upper) and the value for the other bound.\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 lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em).\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 upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em.\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":2781,"title":"Rule of mixtures (composites) - reverse engineering","description":"The \u003chttp://en.wikipedia.org/wiki/Rule_of_mixtures rule of mixtures\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\r\n\r\n* Ef: elastic modulus of the fiber material\r\n* Em: elastic modulus of the matrix material\r\n* ff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\r\n\r\nSuppose that you are reverse engineering a composite article. You've tested coupons from the article to determine Ec and taken sections to determine the material properties and volume fraction for the fiber material. Using the known values, calculate modulus estimates for the matrix material based on both weightings of upper- and lower-bounds. Provide values for (upper-bound) weightings of 0, 1/4, 1/2, 3/4, and 1 (weighting is not related to fiber fraction or material volume).\r\n\r\nThe lower-bound estimate of elastic modulus is calculated by:\r\n\r\nEc = 1 / (ff / Ef + (1 – ff) / Em)   [eq.1]\r\n\r\nThe upper-bound (linear) estimate of elastic modulus is calculated by:\r\n\r\nEc = ff * Ef + (1 – ff) * Em   [eq.2]\r\n\r\nFor example, for each test case you will calculate Em_l, the lower-bound matrix elastic modulus extrapolated by eq.1, and Em_u, the upper-bound matrix elastic modulus extrapolated by eq.2. The weighted matrix elastic modulus is given by Em = wt * Em_u + (1-wt) * Em_l. For a weighting of 1/4, the weighted modulus is therefore given by Em = 0.25 * Em_u + 0.75 * Em_l.\r\n","description_html":"\u003cp\u003eThe \u003ca href = \"http://en.wikipedia.org/wiki/Rule_of_mixtures\"\u003erule of mixtures\u003c/a\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/p\u003e\u003cul\u003e\u003cli\u003eEf: elastic modulus of the fiber material\u003c/li\u003e\u003cli\u003eEm: elastic modulus of the matrix material\u003c/li\u003e\u003cli\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eSuppose that you are reverse engineering a composite article. You've tested coupons from the article to determine Ec and taken sections to determine the material properties and volume fraction for the fiber material. Using the known values, calculate modulus estimates for the matrix material based on both weightings of upper- and lower-bounds. Provide values for (upper-bound) weightings of 0, 1/4, 1/2, 3/4, and 1 (weighting is not related to fiber fraction or material volume).\u003c/p\u003e\u003cp\u003eThe lower-bound estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = 1 / (ff / Ef + (1 – ff) / Em)   [eq.1]\u003c/p\u003e\u003cp\u003eThe upper-bound (linear) estimate of elastic modulus is calculated by:\u003c/p\u003e\u003cp\u003eEc = ff * Ef + (1 – ff) * Em   [eq.2]\u003c/p\u003e\u003cp\u003eFor example, for each test case you will calculate Em_l, the lower-bound matrix elastic modulus extrapolated by eq.1, and Em_u, the upper-bound matrix elastic modulus extrapolated by eq.2. The weighted matrix elastic modulus is given by Em = wt * Em_u + (1-wt) * Em_l. For a weighting of 1/4, the weighted modulus is therefore given by Em = 0.25 * Em_u + 0.75 * Em_l.\u003c/p\u003e","function_template":"function [Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff)\r\n Em = ones(5,1);\r\nend","test_suite":"%%\r\nEc = 35.4;\r\nEf = 100;\r\nff = 0.30;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [7.7143   12.7168   17.7193   22.7218   27.7243])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 85.1;\r\nEf = 250;\r\nff = 0.20;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [43.8750   51.1696   58.4642   65.7589   73.0535])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 155.5;\r\nEf = 1000;\r\nff = 0.05;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [111.0526  120.5101  129.9676  139.4251  148.8826])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 27.6;\r\nEf = 100;\r\nff = 0.10;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [19.5556   21.0529   22.5503   24.0477   25.5450])) \u003c 1e-2)\r\n\r\n%%\r\nEc = 204.9;\r\nEf = 1000;\r\nff = 0.15;\r\n[Em] = rule_of_mixtures_rev_eng(Ec,Ef,ff);\r\nassert(sum(abs(sort(Em) - [64.5882   93.3631  122.1380  150.9128  179.6877])) \u003c 1e-2)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":6,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":"2014-12-16T23:18:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-12-16T05:33:10.000Z","updated_at":"2026-02-13T10:45:04.000Z","published_at":"2014-12-16T05:33: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\u003eThe\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://en.wikipedia.org/wiki/Rule_of_mixtures\\\"\u003e\u003cw:r\u003e\u003cw:t\u003erule of mixtures\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is used in the mechanical design of composite structures to estimate the elastic modulus (Ec) based on the following properties:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEf: elastic modulus of the fiber material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eEm: elastic modulus of the matrix material\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eff or fm: volume fraction of the fiber or matrix material (ff = 1 – fm)\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\u003eSuppose that you are reverse engineering a composite article. You've tested coupons from the article to determine Ec and taken sections to determine the material properties and volume fraction for the fiber material. Using the known values, calculate modulus estimates for the matrix material based on both weightings of upper- and lower-bounds. Provide values for (upper-bound) weightings of 0, 1/4, 1/2, 3/4, and 1 (weighting is not related to fiber fraction or material volume).\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 lower-bound estimate of elastic modulus is calculated by:\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\u003eEc = 1 / (ff / Ef + (1 – ff) / Em) [eq.1]\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 upper-bound (linear) estimate of elastic modulus is calculated by:\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\u003eEc = ff * Ef + (1 – ff) * Em [eq.2]\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\u003eFor example, for each test case you will calculate Em_l, the lower-bound matrix elastic modulus extrapolated by eq.1, and Em_u, the upper-bound matrix elastic modulus extrapolated by eq.2. The weighted matrix elastic modulus is given by Em = wt * Em_u + (1-wt) * Em_l. For a weighting of 1/4, the weighted modulus is therefore given by Em = 0.25 * Em_u + 0.75 * Em_l.\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":54755,"title":"List odd twin composites","description":"Twin primes, or prime numbers that differ by 2 (e.g., 17 and 19, 59 and 61, or 191 and 193), are the subject of several Cody problems: 248, 1096, 3016, and 52298. (See also Cody Problem 53740 for “almost twin primes”.)\r\nThis problem deals with twin composites. Because all even numbers are twin composites, let’s focus on odd twin composites, such as 25 and 27, 63 and 65, and 169 and 171. \r\nWrite a function that takes a number and produces a two-column matrix with the smaller number of the odd twin composite pair in the first column and the larger in the second column. \r\nOptional exercises: (a) prove that the number of odd twin composites is infinite, (b) prove that the number of twin primes is infinite. ","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: 195px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 97.5px; transform-origin: 407px 97.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; 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 21px; text-align: left; transform-origin: 384px 21px; 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: 383.775px 8px; transform-origin: 383.775px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTwin primes, or prime numbers that differ by 2 (e.g., 17 and 19, 59 and 61, or 191 and 193), are the subject of several Cody problems: \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/248\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e248\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/1096\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e1096\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 3.88333px 8px; transform-origin: 3.88333px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/3016\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e3016\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 17.5px 8px; transform-origin: 17.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, and \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/52298\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003e52298\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 35.3917px 8px; transform-origin: 35.3917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. (See also \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems/53740\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eCody Problem 53740\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 78.95px 8px; transform-origin: 78.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e for “almost twin primes”.)\u003c/span\u003e\u003c/span\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: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 349.95px 8px; transform-origin: 349.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem deals with twin composites. Because all even numbers are twin composites, let’s focus on odd twin composites, such as 25 and 27, 63 and 65, and 169 and 171. \u003c/span\u003e\u003c/span\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: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 380.667px 8px; transform-origin: 380.667px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that takes a number and produces a two-column matrix with the smaller number of the odd twin composite pair in the first column and the larger in the second column. \u003c/span\u003e\u003c/span\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: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 379.617px 8px; transform-origin: 379.617px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOptional exercises: (a) prove that the number of odd twin composites is infinite, (b) prove that the number of twin primes is infinite. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = twinComposites(n)\r\n  y = ~isprimes(1:2:n);\r\nend","test_suite":"%%\r\nn = 100;\r\ny = twinComposites(n);\r\ny_correct = [25 27; 33 35; 49 51; 55 57; 63 65; 75 77; 85 87; 91 93; 93 95];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nn = 1000;\r\ny = twinComposites(n);\r\nlen_correct = 200;\r\nmean_correct = [545.84 547.84];\r\nassert(isequal(length(y),len_correct) \u0026\u0026 isequal(mean(y),mean_correct))\r\n\r\n%%\r\nn = 10000;\r\ny = twinComposites(n);\r\nyi_correct = [121 123; 695 697; 1183 1185; 1659 1661; 2093 2095; 2523 2525; 2979 2981; 3383 3385; 3811 3813; 4213 4215; 4615 4617; 5035 5037; 5433 5435; 5871 5873; 6253 6255; 6655 6657; 7073 7075; 7429 7431; 7855 7857; 8249 8251; 8631 8633; 9051 9053; 9453 9455; 9863 9865];\r\nassert(isequal(y(13:117:2748,:),yi_correct))\r\n\r\n%%\r\nn = 100000;\r\ny = twinComposites(n);\r\nyi_correct = [1387 1389; 6921 6923; 12077 12079; 17161 17163; 22099 22101; 27007 27009; 31807 31809; 36615 36617; 41403 41405; 46161 46163; 50875 50877; 55569 55571; 60357 60359; 64973 64975; 69619 69621; 74303 74305; 78953 78955; 83583 83585; 88157 88159; 92797 92799; 97399 97401];\r\nassert(isequal(y(300:1543:length(y),:),yi_correct))\r\n\r\n%%\r\nn = 1e8;\r\ny = twinComposites(n);\r\nyi_correct = [165453 165455; 5402289 5402291; 10497039 10497041; 15545075 15545077; 20564337 20564339; 25562343 25562345; 30545611 30545613; 35513869 35513871; 40472875 40472877; 45421809 45421811; 50362465 50362467; 55295281 55295283; 60222207 60222209; 65142869 65142871; 70058737 70058739; 74969567 74969569; 79875045 79875047; 84776713 84776715; 89673895 89673897; 94567305 94567307; 99457437 99457439];\r\nassert(isequal(y(54321:1932439:length(y),:),yi_correct))\r\n\r\n%%\r\nn = 2500;\r\ny = twinComposites(n);\r\nz = twinComposites(y(900)^2);\r\na = prod(factor(z(654321,1))+factor(z(654321,2)));\r\na_correct = 17376480;\r\nassert(isequal(a,a_correct))\r\n\r\n%%\r\nfiletext = fileread('twinComposites.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp') || contains(filetext,'read'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2022-06-15T03:49:28.000Z","deleted_by":null,"deleted_at":null,"solvers_count":8,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-06-15T03:47:54.000Z","updated_at":"2025-09-30T08:35:42.000Z","published_at":"2022-06-15T03:49:28.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\u003eTwin primes, or prime numbers that differ by 2 (e.g., 17 and 19, 59 and 61, or 191 and 193), are the subject of several Cody problems: \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/248\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e248\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\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1096\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e1096\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\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3016\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e3016\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/52298\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e52298\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e. (See also \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/53740\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eCody Problem 53740\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e for “almost twin primes”.)\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\u003eThis problem deals with twin composites. Because all even numbers are twin composites, let’s focus on odd twin composites, such as 25 and 27, 63 and 65, and 169 and 171. \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\u003eWrite a function that takes a number and produces a two-column matrix with the smaller number of the odd twin composite pair in the first column and the larger in the second column. \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\u003eOptional exercises: (a) prove that the number of odd twin composites is infinite, (b) prove that the number of twin primes is infinite. \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:\"composites\"","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:\"composites\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"composites\"","","\"","composites","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f1021e37c80\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f1021e37be0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f1021e37320\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f1021e37f00\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f1021e37e60\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f1021e37dc0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f1021e37d20\u003e":"tag:\"composites\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f1021e37d20\u003e":"tag:\"composites\""},"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:\"composites\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"composites\"","","\"","composites","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f1021e37c80\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f1021e37be0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f1021e37320\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f1021e37f00\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f1021e37e60\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f1021e37dc0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f1021e37d20\u003e":"tag:\"composites\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f1021e37d20\u003e":"tag:\"composites\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2774,"difficulty_rating":"easy"},{"id":2777,"difficulty_rating":"easy"},{"id":2778,"difficulty_rating":"easy"},{"id":2776,"difficulty_rating":"easy"},{"id":2775,"difficulty_rating":"easy"},{"id":2779,"difficulty_rating":"easy"},{"id":2780,"difficulty_rating":"easy-medium"},{"id":2781,"difficulty_rating":"easy-medium"},{"id":54755,"difficulty_rating":"easy-medium"}]}}