{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2026-04-06T00: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":43129,"title":"Find the coefficients for numerical integration using Simpson's rule","description":"For using numerical integration using Simpson's rule, we need some coefficients to be determined first.\r\nSuppose the n is the number of divisions between a and b the limits of integration. First of all n should be even so for odd numbers the program return empty vector []. For n=2 the coefficients are [1 4 1] and for n=4, coefficients are [1 4 2 4 1]. The first and the last elements are 1 and the remaining elements are 4 and 2. Also zero or negative n has meaning. ","description_html":"\u003cp\u003eFor using numerical integration using Simpson's rule, we need some coefficients to be determined first.\r\nSuppose the n is the number of divisions between a and b the limits of integration. First of all n should be even so for odd numbers the program return empty vector []. For n=2 the coefficients are [1 4 1] and for n=4, coefficients are [1 4 2 4 1]. The first and the last elements are 1 and the remaining elements are 4 and 2. Also zero or negative n has meaning.\u003c/p\u003e","function_template":"function y=sym_gen(n)\r\n    y=[];\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = [1 4 1];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = [1 4 2 4 1];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = [1 4 2 4 2 4 1];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = -2;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = -1;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94830,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-06T15:07:11.000Z","updated_at":"2025-06-24T19:56:27.000Z","published_at":"2016-10-06T15:07:56.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eFor using numerical integration using Simpson's rule, we need some coefficients to be determined first. Suppose the n is the number of divisions between a and b the limits of integration. First of all n should be even so for odd numbers the program return empty vector []. For n=2 the coefficients are [1 4 1] and for n=4, coefficients are [1 4 2 4 1]. The first and the last elements are 1 and the remaining elements are 4 and 2. Also zero or negative n has meaning.\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":59671,"title":"Write a code to implement Euler's method to integrate a simple function","description":"Euler's method approximates the solution to a differential equation as\r\n\r\nwhere . The challenge is to write a code that can take some arbitrary function, f(t,x), and use Euler's method to integrate over  equally-spaced points ( equal intervals) between times  and . You must implement the boundary condition . ","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: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 124px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 62px; transform-origin: 408px 62px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 213.992px 8px; transform-origin: 213.992px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eEuler's method approximates the solution to a differential equation as\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWIAAAAlCAYAAAB4duMaAAAMUUlEQVR4Xu2dW+hv2xTH93kntycS5Xgg91zrRFEoKUnupf3k8iB5oI48SYd4kDy4RO08HLc8SCmSU0SuRZx4QJR4cot3xofft0aztdYcY6451+/323uuGrX3/7fWXHOO+R3fOcaYY6111415TA1MDUwNTA2cVQN3nfXu8+ZTA1MDUwNTAzcmEU8QTA1MDUwNnFkDk4jPPAHz9lMDUwNTA0cS8XNN3U8w+dJUe1oDb7crvmzyt/SVt/8F99oQP53Uzd12/nMmFq8OHNfAIU3YOoqIUeAnTF6RNJirQ8qgDkt/77T2fzLoHtfYLIv6Ayafauj8R+yax5u8vuHaecnxGrgmDklj6wgiRoGfN7lnkvAu9KLHr5m8apLx//QICf/c5EM7tKro7NrJGGz87krsC4/xbSYvMvmjyedMvlWZw2vkkBS2RhPxI0/Kfk1A2Tvs6SIuJX3wUZOHDuzNy6ztj89F7QYeB4b8gg66/qG1ccukxavucPumJsDas0yeYfL8UwsvvwIbY8H7rMk3TN5h8n2TJ5m8wWQtZXnNHBLG1mgipiOsetfucUSshbFiFO8z2eOl1e71TTvhDyZ4FXfiwWKEDp5oghe498Db+o7JMzu1t7c/0evxLL9n8miTf5uQZrnkPQTp+UHrp1KU/zkNFgfmvSsDv2YOCWNrJBH3NpgoQM9xnsbKvX9j8uSBncAAf2tyDR7QCDWMMEy8MYish4c9Ys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Vxmct35q9MWTcm0Owqw+avL8zCaexdRQRi4zLVxtmJ+NOPR+vL7LpdCfqh0gh+1rD8tWtd6Leeo1ZFTEQL5uEbMBDmCp57XWfa+GQJmwdScQ9J2S2NTUwNXAZGlBo/1jrzoMmt06EfI7a5cvQSEMvJhE3KG1eMjUwNTA10FMDk4h7anO2NTUwNTA10KCBScQNSpuXTA1MDUwN9NTAJOKe2pxtTQ1MDUwNNGjgv1bqplPdSbeoAAAAAElFTkSuQmCC\" width=\"177\" height=\"18.5\" style=\"width: 177px; height: 18.5px;\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 64px; 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: 385px 32px; text-align: left; transform-origin: 385px 32px; white-space-collapse: preserve; 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: 21.0083px 8px; transform-origin: 21.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ewhere \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAAAAkCAYAAADit5awAAADl0lEQVRoQ+1ZOasWMRR9r1fcKhsttFC0sHEBUUREQbASXP6ASyFioaCFpYJWVi5YCi6djaCFjSBupaKFFjZaKYj2eg7mwH2ZzCTzzUy++R4JHMb3XpJ7c3LuzU2cnyttcAbmB7dQDMwVkjOIoJBcSM7AQAYTRckjI3md8+dLBr8WlYkmJe/HSvcBu4FNwBLgOnBhUTHwfzEPgeXAgSHWFksXK2H0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e\u003c/span\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: 322.2px 8px; transform-origin: 322.2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. The challenge is to write a code that can take some arbitrary function, f(t,x), and use Euler's method to integrate over \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eN\u003c/span\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: 73.9167px 8px; transform-origin: 73.9167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e equally-spaced points (\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE8AAAAkCAYAAADIB2cfAAACk0lEQVRoQ+2Yuy9EQRTGd3sKVCoFhQKdRyKRaEgkWq8/wKNUEJQKhELpUWvoNBJKlUepoKBRUJEIPd+XzEkmd+/Mve7MZmeZSU527J45c+bnzDkzUy7FVphAufDIOLAU4TkEQYQX4TkQcBgaIy/CcyDgMDRP5G3D/hCkX5tnCv1jw7zz+H4YMqH9fo3+rmWMwxK8Dx2BxXXIKWTTZj0PPBl/pQG8QH80w23CJUDqTkPevS/Tr0GBJkGy5hPeAYzNav52oP9k8V/gETIBhtqa4dgKpA3SA+lUjnqFd68Zpv0dyLKFyIv6rSvwqCM8Nu4MRt+5b3ic4A1yApFc9oV+owFeO75/VPqToYZcil9VgccisAfhFmQylbxgKhyivwDd/f8Oj/lrDMK8wMgjSDZW0YEUOJLvWtR2qBd+VYk85q87FXkEwb9bFZE+fN4m6PD3ZwPYkEF6h9eL1d5A9OrDs9+SonCIzzmNiOhnFZQQIXqHt4pVbkD0CJMCQgDJwpGmHyKoNJ+8w2Pp7oYkjxyS1+iEXhhM+vUA0Du8b6w67UahT6QXjk/on0GKHlH0m0xR4Gl5OI8tr/DEmOnIoR+c6XAThJHnckT5M/DkSma6isl5jv9VFo4PBY5HmtDvslXPeYwstkELDG7TBqXH7cuWdvbLs21qreNt2+a9YiUfDDIv1LUmZJnfG7y8VyyBLD4VTdYhMPUGTxJ31tMTF80iwYkfMrZ4CIBsPniBpxvJA0/0+epS9IgSAljbzanCv7SXZOawGa0IvKJ/BLG93dEw77OLENPzfAhwTD4Q2jhEHkJFjwXwErIFqTg9/OYZPuTF18S3CM8Be4QX4TkQcBgaIy/CcyDgMDRGXoTnQMBhaIw8B3g/5EaTJZKteUUAAAAASUVORK5CYII=\" width=\"39.5\" height=\"18\" style=\"width: 39.5px; height: 18px;\"\u003e\u003c/span\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: 98.4167px 8px; transform-origin: 98.4167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e equal intervals) between times \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAoCAYAAADkDTpVAAABvklEQVRIS+1Vuy5FQRS9t6dARaOgIJHQeCSi5Q+8arn4ABI/oOADPKISBRqFikYhxKNRSChoFFREQs9asreMyZyZM5NzC8k5ycpMzt1nrT1r79m3WqnzU60zf6UUCDpcWlRa9OtAP3ZNwHHQEysgTxc145tbYAdYLFqA5GdAFzAAXBcpMAGyLaABeAF6gLciBDpAcgq0ZpB14v1jXiFfDVjYKyGax7qel9SM8wksIXBZgqOyzitwhMBR4B4YTvGfQr4TfEkmm1hnU+zxCTBznoDPJLBXtMAKCBeAT6A91R7fCe7wIy/XJTCUmn2WAG/vq5CuYo0eD6Eu4g3elaAxrBxwrAHfRz+uLtoASw3Q8bCG/Qngumi89dphvdgf2HEugQsEDUqBz7G+Z2TPRKaBGTmhdt6+Ge87ATuIN5lE9pCjZeOA3cJ6d1r0mzz/B7bvc3hB21wdRgEm1gf8DMQUgWd8x0mrDaAJaHNwtHTry1gBFvUBYAOMaJZCprb9mbyxAlpICrQZ3uloZ0tPmTWLFSDnhxA3yqp/q082eWoNmO22kB9i5ay6AVzdllRkw5nwNsWiMKsRUQoE7fr/Fn0DztxQKUTpZKkAAAAASUVORK5CYII=\" width=\"12\" height=\"20\" style=\"width: 12px; height: 20px;\"\u003e\u003c/span\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: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAoCAYAAADt5povAAAB20lEQVRYR+2WOy8FQRiGz+mJ0KkkKEgUGpfQKfgH+AUupYKgUpFQKlyiFKFU0iiEuLQSCiQaKkLoeV6ZSZyT3dnZPbOnkLPJkznZ8828+13mmykWqvwUq6xXqAkGj3gtpLWQpo6Ab9H0sHIjHKdWKJvgI9jEnBvYhbm8BSV2Bh3QC9d5Co6x+A7UwQt0wVsegm0segrNMYu38/4hq7ArhyqUK7PwNONmVpG/81yCCxguG+OKvPIVPMJwGO5gMET+JOzy8Nt82TbjZIhwugTlmTzUMw4HKQRVdKOgRrFVXmBxHq5iOAtf0JIinCq0Q5iBJdD+LdGIE7w1xpeM/Z7eqUk8wZ5JwRRjK5R0pyhBTXw1ImvlExziNioj2MT23ChBdZh9s7CdrBzqvet5Nn86O1KUoBI9AbadbfD7BKI2vqIxDw1mjjQVlccY+8htcYFxH6hgzuHdwzsbzsQUuDyUoDqNPE5q2rZJOPMn933Ow4TU/f79aYy6GZ2NPYSgNvo9qAV2Jn1dCEFb1V4tMISgLRivIyyEoK1qryMshKBOFa/8hahSeytI3H+2mCr1ULeCRRgCrxtdFkFt8gGoB/XPdVhJ2g6VeKhjRyHUMfQBqS7HWTz0dSbS7v8L/gD7WFMpZFbYcAAAAABJRU5ErkJggg==\" width=\"14\" height=\"20\" style=\"width: 14px; height: 20px;\"\u003e\u003c/span\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: 111.767px 8px; transform-origin: 111.767px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. You must implement the boundary condition \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH4AAAAlCAYAAACEal28AAAFpklEQVR4Xu2bPagcVRTH3+sVUauIRIgWCoFYqBGCgkIURBEJJIrNq9QUIZUhSSUWEZIqpIhaioUKFiEgaJFCSYhaCYIWKipiqnyI6fX/g3vg7Oz92t2Z3dk3c+Gw+3Zm7j33/M/33Le5MY5BSmBzkLseN70xAj9QJRiBH4HvXAKPa4Vdok9bWuktzfOZ6EZL8w1qmmVZPKCfE73QIlA25xHN+f2gUGths8sAHoA+Eu1rEXTbOnNfEL08gj+bNnQN/D1i5w/RAdFXBdZw3Vvunp36/rHoWOG553T9bEeKNZs0V3M3Mj4uejosf1f4fEefybDaNfBXA/CHMjKB8cui+0Vvi94P92LNl8L3R/X5a2aOL3Xtd9G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WsFd9CJMkwycePAtwrwRmfRJiGlkDQu61rCkGjaPdgYcUcNbdytW1fQIdGUGUWezzqMhKN18+E1YBnFNMvrQrvZY1xah6LevjLnHhr8ZiniHA4DVorM5EwADKmHgrFJG8dQEpYbxmpg4ZpMDDrdHKzB366BPw5smQM8OfUmqWz9y7FZTE7yF1WMUMBs8cPefYtHg00PrAPPS6qNk8MAtNXTfGag9icL8dH3opPIxCkaQRYrDk3OkbHmEt2sqlHKBPwJscMaAYqNaMSl23vYAZh1Vo6/4Z5Ib8OIuIh4529Wpi/CLCYmHiVsnqF1mDZ8k9LopK5/MWXWfbPN818ObGOQxpb/XaFh6WQRbctXK1zfdK5+saeDYH+D+KujgCPfQTtnMrzzKAN/C/0Jc2//mhi3/SmFuQ6/bgsoA38O21YhtyIntv69+x2uBnreZYJvBrJZjtzuwI/HZHOLG/EfgR+IFKYKDbHi1+oMD/DyIPdjVz/lGwAAAAAElFTkSuQmCC\" width=\"63\" height=\"18.5\" style=\"width: 63px; height: 18.5px;\"\u003e\u003c/span\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\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [t,x] = EulerIntegration(t0,tf,N,x0,func)\r\n  t = 0;\r\n  x = 0;\r\nend","test_suite":"%%\r\nt0=0; tf=1.5; \r\nfunc = @(t,x) 2*x.*t;\r\nN=50;\r\nt = linspace(t0,tf,N);\r\nh = (tf-t0)/N;\r\nnum_steps = length(t) - 1;\r\nx = zeros(1,num_steps + 1);\r\nx(1) = 1;\r\nfor i = 1:num_steps\r\n    x(i+1) = x(i) + h*func(t(i),x(i));\r\nend\r\n\r\nx0=1;\r\n[t2,x2] = EulerIntegration(t0,tf,N,x0,func)\r\n\r\nassert(isequal(x(1),x2(1)))\r\nn1 = length(x);\r\nn2 = length(x2);\r\nassert(isequal(x(n1),x2(n2)))\r\nassert(isequal(n1,n2))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":5,"created_by":4078801,"edited_by":223089,"edited_at":"2025-10-10T13:57:39.000Z","deleted_by":null,"deleted_at":null,"solvers_count":21,"test_suite_updated_at":"2025-10-10T13:57:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2024-02-28T23:15:52.000Z","updated_at":"2026-03-23T10:41:43.000Z","published_at":"2024-02-28T23:15:52.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\u003eEuler's method approximates the solution to a differential equation as\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex(t+\\\\Delta t) = x(t) + h \\\\cdot f(x, t )\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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\u003ewhere \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eh = \\\\Delta t\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. The challenge is to write a code that can take some arbitrary function, f(t,x), and use Euler's method to integrate over \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e equally-spaced points (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eN-1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e equal intervals) between times \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003et_o\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003et_f\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. You must implement the boundary condition \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex(0)=x0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1197,"title":"Numerical Integration","description":"Input\r\n\r\n* |x0|, a real number greater than 0\r\n\r\nOutput\r\n\r\n* |I|, a numerical estimate of the integral\r\n\r\n      x0\r\n      /\r\n  I = |  cosh(x) / sqrt(cosh(x0) - cosh(x)) dx\r\n      /\r\n      0\r\n\r\nExample:\r\n\r\n   x0=1.0  --\u003e  I = 2.6405789412796\r\n\r\n\r\nRemarks:\r\n\r\n* Aim at a relative precision better than 1e-10\r\n* The problem arises studying the frictionless movement of a mass point on a hanging wire, which follows the curve cosh(x).","description_html":"\u003cp\u003eInput\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ctt\u003ex0\u003c/tt\u003e, a real number greater than 0\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOutput\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ctt\u003eI\u003c/tt\u003e, a numerical estimate of the integral\u003c/li\u003e\u003c/ul\u003e\u003cpre\u003e      x0\r\n      /\r\n  I = |  cosh(x) / sqrt(cosh(x0) - cosh(x)) dx\r\n      /\r\n      0\u003c/pre\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e   x0=1.0  --\u003e  I = 2.6405789412796\u003c/pre\u003e\u003cp\u003eRemarks:\u003c/p\u003e\u003cul\u003e\u003cli\u003eAim at a relative precision better than 1e-10\u003c/li\u003e\u003cli\u003eThe problem arises studying the frictionless movement of a mass point on a hanging wire, which follows the curve cosh(x).\u003c/li\u003e\u003c/ul\u003e","function_template":"function I = coshint(x0)\r\n  I = x0;\r\nend","test_suite":"%%\r\nx0 = 1;\r\nI_correct = 2.6405789412796;\r\nfprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\nassert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\n\r\n%%\r\nx0 = 2;\r\nI_correct = 3.9464053536380;\r\nfprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\nassert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\n\r\n%%\r\nx0 = 13;\r\nI_correct = 9.4065231838369e+02;\r\nfprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\nassert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\n\r\n%% randomized test for small values of x0 where \r\n % cosh(x) ~ 1 + x^2/2 + ...\r\n % and up to x0=1e-5 Integrating (analytically) the approximation is\r\n % accurate enough\r\nfor l=1:5\r\n   x0 = 1e-6 * (1+rand);\r\n   I_correct = pi*(4+x0^2)/4/sqrt(2);\r\n   fprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\n   assert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":9,"created_by":203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":106,"test_suite_updated_at":"2013-01-11T15:08:44.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-01-11T14:11:17.000Z","updated_at":"2026-03-13T22:59:58.000Z","published_at":"2013-01-11T15:08:44.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\u003eInput\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, a real number greater than 0\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\u003eOutput\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eI\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, a numerical estimate of the integral\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[      x0\\n      /\\n  I = |  cosh(x) / sqrt(cosh(x0) - cosh(x)) dx\\n      /\\n      0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\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[   x0=1.0  --\u003e  I = 2.6405789412796]]\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\u003eRemarks:\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\u003eAim at a relative precision better than 1e-10\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\u003eThe problem arises studying the frictionless movement of a mass point on a hanging wire, which follows the curve cosh(x).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":43129,"title":"Find the coefficients for numerical integration using Simpson's rule","description":"For using numerical integration using Simpson's rule, we need some coefficients to be determined first.\r\nSuppose the n is the number of divisions between a and b the limits of integration. First of all n should be even so for odd numbers the program return empty vector []. For n=2 the coefficients are [1 4 1] and for n=4, coefficients are [1 4 2 4 1]. The first and the last elements are 1 and the remaining elements are 4 and 2. Also zero or negative n has meaning. ","description_html":"\u003cp\u003eFor using numerical integration using Simpson's rule, we need some coefficients to be determined first.\r\nSuppose the n is the number of divisions between a and b the limits of integration. First of all n should be even so for odd numbers the program return empty vector []. For n=2 the coefficients are [1 4 1] and for n=4, coefficients are [1 4 2 4 1]. The first and the last elements are 1 and the remaining elements are 4 and 2. Also zero or negative n has meaning.\u003c/p\u003e","function_template":"function y=sym_gen(n)\r\n    y=[];\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = [1 4 1];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = [1 4 2 4 1];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = [1 4 2 4 2 4 1];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = -2;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n%%\r\nx = -1;\r\ny_correct = [];\r\nassert(isequal(sym_gen(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94830,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-06T15:07:11.000Z","updated_at":"2025-06-24T19:56:27.000Z","published_at":"2016-10-06T15:07:56.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eFor using numerical integration using Simpson's rule, we need some coefficients to be determined first. Suppose the n is the number of divisions between a and b the limits of integration. First of all n should be even so for odd numbers the program return empty vector []. For n=2 the coefficients are [1 4 1] and for n=4, coefficients are [1 4 2 4 1]. The first and the last elements are 1 and the remaining elements are 4 and 2. Also zero or negative n has meaning.\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":59671,"title":"Write a code to implement Euler's method to integrate a simple function","description":"Euler's method approximates the solution to a differential equation as\r\n\r\nwhere . The challenge is to write a code that can take some arbitrary function, f(t,x), and use Euler's method to integrate over  equally-spaced points ( equal intervals) between times  and . You must implement the boundary condition . ","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: none; white-space: normal; \"\u003e\u003cdiv style=\"block-size: 124px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 408px 62px; transform-origin: 408px 62px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; 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: 213.992px 8px; transform-origin: 213.992px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eEuler's method approximates the solution to a differential equation as\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 385px 10.5px; text-align: left; transform-origin: 385px 10.5px; white-space-collapse: preserve; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWIAAAAlCAYAAAB4duMaAAAMUUlEQVR4Xu2dW+hv2xTH93kntycS5Xgg91zrRFEoKUnupf3k8iB5oI48SYd4kDy4RO08HLc8SCmSU0SuRZx4QJR4cot3xofft0aztdYcY6451+/323uuGrX3/7fWXHOO+R3fOcaYY6111415TA1MDUwNTA2cVQN3nfXu8+ZTA1MDUwNTAzcmEU8QTA1MDUwNnFkDk4jPPAHz9lMDUwNTA0cS8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dw62JFgjXwM29+OYY3iL3ingtGUD0NALu68vRMv0oz/XejF/YKF2DmGuGw7h45DyaHtnT117X+jKmm9ZoGSprQcJYln73/aCtra+++GL+d9u5kTSX8tXRt7pF9dITg7WHfvx7ECBioswalqLjyJ7XWglU3qfGIcLNEgnTlnTCv0uS5m/eEeL/tU3FYdiK5Iizk+DPJ5VBLjBaQrTnXuW1eik3fz/H/XuOxbcFGL5uUst5jrr/udvVAt7rO4gy1hFpntsVgzUMaNHo8eKhozgEb7d3pUkYW6OJWC8HioSHtcmdv/9/Be/10cxr1qfyzJE0ztY4r/nDlJc8f0oZ9Mi5H8EheN5wVEsp6No8pLA1mojpJB36lUnP/O8lg3BU3wSWveQzqn9Ht8uihBdb29jc6hcpiVsmtRzy0WO7tvsRpSgNopx/7VUImTGO5BC9C/wt1qFe79hgbClsHUHEIuPo7nVmgu6UcxXinmsH/FL1jGccqTJZ6j+54wcmCe+eWuVNlV/Vxmct35q9MWTcm0Owqw+avL8zCaexdRQRi4zLVxtmJ+NOPR+vL7LpdCfqh0gh+1rD8tWtd6Leeo1ZFTEQL5uEbMBDmCp57XWfa+GQJmwdScQ9J2S2NTUwNXAZGlBo/1jrzoMmt06EfI7a5cvQSEMvJhE3KG1eMjUwNTA10FMDk4h7anO2NTUwNTA10KCBScQNSpuXTA1MDUwN9NTAJOKe2pxtTQ1MDUwNNGjgv1bqplPdSbeoAAAAAElFTkSuQmCC\" width=\"177\" height=\"18.5\" style=\"width: 177px; height: 18.5px;\"\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 64px; 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: 385px 32px; text-align: left; transform-origin: 385px 32px; white-space-collapse: preserve; 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: 21.0083px 8px; transform-origin: 21.0083px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ewhere \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFkAAAAkCAYAAADit5awAAADl0lEQVRoQ+1ZOasWMRR9r1fcKhsttFC0sHEBUUREQbASXP6ASyFioaCFpYJWVi5YCi6djaCFjSBupaKFFjZaKYj2eg7mwH2ZzCTzzUy++R4JHMb3XpJ7c3LuzU2cnyttcAbmB7dQDMwVkjOIoJBcSM7AQAYTRckjI3md8+dLBr8WlYkmJe/HSvcBu4FNwBLgOnBhUTHwfzEPgeXAgSHWFksXK2H0PkDC2ejEsyEcmeKcXONXJ6Jt+L7t25cYydrlI/jHd2Az8LNvJ6Y83zXYP+98uIPvyb79SSH5G4yudgoeJJz6XlTL+bQ+DVvVQUhHMfYdsODcipG8FQPeOOun8b3VcgFj734KDt50UUohsU2qZnFVSakxki/C6BVnfL2/Q2NnMMG/j67PWXyfmv4xXvypSfBz4DdQSamxyWiYh94nYGeHMEpYb/YuXBfXdwxgdWHTxiX8fDXRI5vTWRRUUmqMZO4MSzcbQnTuBrAB+APsBXo/kRMX2KXbKwxeY5Sn1ME5ua6lkcmZf+86fvyuC0QZq5MVQtrt25jtEHAPYI7mBrwGdiSuVupJ7F7brY3SQpPwYvUZ8OeRqDgm9QyKptQmkhUG3NW1AA8INjrG01PhNYskMz0cBLa4tWgjbOhTjRsT1BBNqU0kM5y2O6U+xncPcBxgnWyrjklP4wT/B+nCy8cPIOS3/ibDiuAmR6T+R+jEFFJpdSRbYxy8y0H1nw2RFEcGYWvCSalWpgJfxZqOKufliy2mZpv+anmoI5k78sAswq/9FCJKJbN0C6TyXgJ1Fyvlay2/6apt00vtJaaOZB5wJ5yVUFgpRNrk4wmF1+swVhB85DoMNL3BSEQ0HizLnFc2pdYe/nUk61CjUv2wsvm47Sk/7eqC6/oFxA4038+Qmm1KbXydDJFswyWUzKMlS4P2pkmyUmDqGcLbIO8CbKFotim18XUyRLItykODFUpKFVQ2351Tb0i9xn+LyRjayxJUrCktD/ydn3OVUnUurUAfvuBV3ttDJOt0rXvaVD5mqqCh9wCrjzH/j4lSHAn50GJjWMKq+WqW0pmzWdo+Ac4AldtviGSRGEr4Nh9TyWyXgbE/5NuyrAXHla6Wr7/uryzz2PjUEHyl9EmOPW0yX78A+CxIkmeBYL8k60KyPeilZEb8OYAbGWyxB6IuDpWxjoFCcgYpFJILyRkYyGCiKLmQnIGBDCaKkgvJGRjIYKIoOQPJ/wCPycQl0qakBgAAAABJRU5ErkJggg==\" width=\"44.5\" height=\"18\" style=\"width: 44.5px; height: 18px;\"\u003e\u003c/span\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: 322.2px 8px; transform-origin: 322.2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. The challenge is to write a code that can take some arbitrary function, f(t,x), and use Euler's method to integrate over \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"font-family: \u0026quot;STIXGeneral\u0026quot;, \u0026quot;STIXGeneral-webfont\u0026quot;, serif; font-style: italic; font-weight: 400; color: rgb(0, 0, 0);\"\u003eN\u003c/span\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: 73.9167px 8px; transform-origin: 73.9167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e equally-spaced points (\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE8AAAAkCAYAAADIB2cfAAACk0lEQVRoQ+2Yuy9EQRTGd3sKVCoFhQKdRyKRaEgkWq8/wKNUEJQKhELpUWvoNBJKlUepoKBRUJEIPd+XzEkmd+/Mve7MZmeZSU527J45c+bnzDkzUy7FVphAufDIOLAU4TkEQYQX4TkQcBgaIy/CcyDgMDRP5G3D/hCkX5tnCv1jw7zz+H4YMqH9fo3+rmWMwxK8Dx2BxXXIKWTTZj0PPBl/pQG8QH80w23CJUDqTkPevS/Tr0GBJkGy5hPeAYzNav52oP9k8V/gETIBhtqa4dgKpA3SA+lUjnqFd68Zpv0dyLKFyIv6rSvwqCM8Nu4MRt+5b3ic4A1yApFc9oV+owFeO75/VPqToYZcil9VgccisAfhFmQylbxgKhyivwDd/f8Oj/lrDMK8wMgjSDZW0YEUOJLvWtR2qBd+VYk85q87FXkEwb9bFZE+fN4m6PD3ZwPYkEF6h9eL1d5A9OrDs9+SonCIzzmNiOhnFZQQIXqHt4pVbkD0CJMCQgDJwpGmHyKoNJ+8w2Pp7oYkjxyS1+iEXhhM+vUA0Du8b6w67UahT6QXjk/on0GKHlH0m0xR4Gl5OI8tr/DEmOnIoR+c6XAThJHnckT5M/DkSma6isl5jv9VFo4PBY5HmtDvslXPeYwstkELDG7TBqXH7cuWdvbLs21qreNt2+a9YiUfDDIv1LUmZJnfG7y8VyyBLD4VTdYhMPUGTxJ31tMTF80iwYkfMrZ4CIBsPniBpxvJA0/0+epS9IgSAljbzanCv7SXZOawGa0IvKJ/BLG93dEw77OLENPzfAhwTD4Q2jhEHkJFjwXwErIFqTg9/OYZPuTF18S3CM8Be4QX4TkQcBgaIy/CcyDgMDRGXoTnQMBhaIw8B3g/5EaTJZKteUUAAAAASUVORK5CYII=\" width=\"39.5\" height=\"18\" style=\"width: 39.5px; height: 18px;\"\u003e\u003c/span\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: 98.4167px 8px; transform-origin: 98.4167px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e equal intervals) between times \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAoCAYAAADkDTpVAAABvklEQVRIS+1Vuy5FQRS9t6dARaOgIJHQeCSi5Q+8arn4ABI/oOADPKISBRqFikYhxKNRSChoFFREQs9asreMyZyZM5NzC8k5ycpMzt1nrT1r79m3WqnzU60zf6UUCDpcWlRa9OtAP3ZNwHHQEysgTxc145tbYAdYLFqA5GdAFzAAXBcpMAGyLaABeAF6gLciBDpAcgq0ZpB14v1jXiFfDVjYKyGax7qel9SM8wksIXBZgqOyzitwhMBR4B4YTvGfQr4TfEkmm1hnU+zxCTBznoDPJLBXtMAKCBeAT6A91R7fCe7wIy/XJTCUmn2WAG/vq5CuYo0eD6Eu4g3elaAxrBxwrAHfRz+uLtoASw3Q8bCG/Qngumi89dphvdgf2HEugQsEDUqBz7G+Z2TPRKaBGTmhdt6+Ge87ATuIN5lE9pCjZeOA3cJ6d1r0mzz/B7bvc3hB21wdRgEm1gf8DMQUgWd8x0mrDaAJaHNwtHTry1gBFvUBYAOMaJZCprb9mbyxAlpICrQZ3uloZ0tPmTWLFSDnhxA3yqp/q082eWoNmO22kB9i5ay6AVzdllRkw5nwNsWiMKsRUQoE7fr/Fn0DztxQKUTpZKkAAAAASUVORK5CYII=\" width=\"12\" height=\"20\" style=\"width: 12px; height: 20px;\"\u003e\u003c/span\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: 15.5583px 8px; transform-origin: 15.5583px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e and \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-6px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAoCAYAAADt5povAAAB20lEQVRYR+2WOy8FQRiGz+mJ0KkkKEgUGpfQKfgH+AUupYKgUpFQKlyiFKFU0iiEuLQSCiQaKkLoeV6ZSZyT3dnZPbOnkLPJkznZ8828+13mmykWqvwUq6xXqAkGj3gtpLWQpo6Ab9H0sHIjHKdWKJvgI9jEnBvYhbm8BSV2Bh3QC9d5Co6x+A7UwQt0wVsegm0segrNMYu38/4hq7ArhyqUK7PwNONmVpG/81yCCxguG+OKvPIVPMJwGO5gMET+JOzy8Nt82TbjZIhwugTlmTzUMw4HKQRVdKOgRrFVXmBxHq5iOAtf0JIinCq0Q5iBJdD+LdGIE7w1xpeM/Z7eqUk8wZ5JwRRjK5R0pyhBTXw1ImvlExziNioj2MT23ChBdZh9s7CdrBzqvet5Nn86O1KUoBI9AbadbfD7BKI2vqIxDw1mjjQVlccY+8htcYFxH6hgzuHdwzsbzsQUuDyUoDqNPE5q2rZJOPMn933Ow4TU/f79aYy6GZ2NPYSgNvo9qAV2Jn1dCEFb1V4tMISgLRivIyyEoK1qryMshKBOFa/8hahSeytI3H+2mCr1ULeCRRgCrxtdFkFt8gGoB/XPdVhJ2g6VeKhjRyHUMfQBqS7HWTz0dSbS7v8L/gD7WFMpZFbYcAAAAABJRU5ErkJggg==\" width=\"14\" height=\"20\" style=\"width: 14px; height: 20px;\"\u003e\u003c/span\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: 111.767px 8px; transform-origin: 111.767px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e. You must implement the boundary condition \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"vertical-align:-5px\"\u003e\u003cimg src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH4AAAAlCAYAAACEal28AAAFpklEQVR4Xu2bPagcVRTH3+sVUauIRIgWCoFYqBGCgkIURBEJJIrNq9QUIZUhSSUWEZIqpIhaioUKFiEgaJFCSYhaCYIWKipiqnyI6fX/g3vg7Oz92t2Z3dk3c+Gw+3Zm7j33/M/33Le5MY5BSmBzkLseN70xAj9QJRiBH4HvXAKPa4Vdok9bWuktzfOZ6EZL8w1qmmVZPKCfE73QIlA25xHN+f2gUGths8sAHoA+Eu1rEXTbOnNfEL08gj+bNnQN/D1i5w/RAdFXBdZw3Vvunp36/rHoWOG553T9bEeKNZs0V3M3Mj4uejosf1f4fEefybDaNfBXA/CHMjKB8cui+0Vvi94P92LNl8L3R/X5a2aOL3Xtd9Gbq5H9ylY1Gf0rDrzXw4jOi34WPRLjrkvgsUQAeagAGsqxV/RhBLgT+u2U6Lbozox4H9S1X0TPi0qeZWUotbywedM7NO+roqZ1I3swQB7IZWJ0CXyNtZtmAuyzoliShjazuTOinNtnvX9im2xZ4H2ZDqAPiq6J7oswhTf4Lvw+ZRBdAW+LxjTR8/i3/tiRYZ57TXP5nuPXlKjkYfoC3CJ8mIdjDkraVCg1o/lW9zzpF+wK+A+0yBuie0WpOttrZNQdBUZP65PYz8gpkgnjpO57bxGprsGzFgJhNbdfC6PcN4FFV8D/FIQXTSwigOaYt1yBx2J5gMcJDb8imoppawDmLCx6QJ/Qg6k+RtJocsCTPBBDnhE9JcIlHxZZ1s11MsdYnPlPv0+5l8bOLEaVtNYDX5oTgVAGxmLeLIJd9r24anIcSrKHRU33DYDInlyHUPZNwAM+a4GfyJFywCPwu0U3RZ+HRS2RsBKMhWGUYbHVXHhNMkY2PwvwpezeLGEeT4ayLjpyISs1NyFqv+g30bsik4nJEwPB8KhqAB4FwOBs1AI/wVutgCxm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cspan 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\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function [t,x] = EulerIntegration(t0,tf,N,x0,func)\r\n  t = 0;\r\n  x = 0;\r\nend","test_suite":"%%\r\nt0=0; tf=1.5; \r\nfunc = @(t,x) 2*x.*t;\r\nN=50;\r\nt = linspace(t0,tf,N);\r\nh = (tf-t0)/N;\r\nnum_steps = length(t) - 1;\r\nx = zeros(1,num_steps + 1);\r\nx(1) = 1;\r\nfor i = 1:num_steps\r\n    x(i+1) = x(i) + h*func(t(i),x(i));\r\nend\r\n\r\nx0=1;\r\n[t2,x2] = EulerIntegration(t0,tf,N,x0,func)\r\n\r\nassert(isequal(x(1),x2(1)))\r\nn1 = length(x);\r\nn2 = length(x2);\r\nassert(isequal(x(n1),x2(n2)))\r\nassert(isequal(n1,n2))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":5,"created_by":4078801,"edited_by":223089,"edited_at":"2025-10-10T13:57:39.000Z","deleted_by":null,"deleted_at":null,"solvers_count":21,"test_suite_updated_at":"2025-10-10T13:57:39.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2024-02-28T23:15:52.000Z","updated_at":"2026-03-23T10:41:43.000Z","published_at":"2024-02-28T23:15:52.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\u003eEuler's method approximates the solution to a differential equation as\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:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"true\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex(t+\\\\Delta t) = x(t) + h \\\\cdot f(x, t )\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\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\u003ewhere \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eh = \\\\Delta t\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. The challenge is to write a code that can take some arbitrary function, f(t,x), and use Euler's method to integrate over \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e equally-spaced points (\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003eN-1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e equal intervals) between times \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003et_o\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003et_f\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. You must implement the boundary condition \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:customXml w:element=\\\"equation\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"displayStyle\\\" w:val=\\\"false\\\"/\u003e\u003c/w:customXmlPr\u003e\u003cw:r\u003e\u003cw:t\u003ex(0)=x0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:customXml\u003e\u003cw:r\u003e\u003cw:t\u003e. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":1197,"title":"Numerical Integration","description":"Input\r\n\r\n* |x0|, a real number greater than 0\r\n\r\nOutput\r\n\r\n* |I|, a numerical estimate of the integral\r\n\r\n      x0\r\n      /\r\n  I = |  cosh(x) / sqrt(cosh(x0) - cosh(x)) dx\r\n      /\r\n      0\r\n\r\nExample:\r\n\r\n   x0=1.0  --\u003e  I = 2.6405789412796\r\n\r\n\r\nRemarks:\r\n\r\n* Aim at a relative precision better than 1e-10\r\n* The problem arises studying the frictionless movement of a mass point on a hanging wire, which follows the curve cosh(x).","description_html":"\u003cp\u003eInput\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ctt\u003ex0\u003c/tt\u003e, a real number greater than 0\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOutput\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ctt\u003eI\u003c/tt\u003e, a numerical estimate of the integral\u003c/li\u003e\u003c/ul\u003e\u003cpre\u003e      x0\r\n      /\r\n  I = |  cosh(x) / sqrt(cosh(x0) - cosh(x)) dx\r\n      /\r\n      0\u003c/pre\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e   x0=1.0  --\u003e  I = 2.6405789412796\u003c/pre\u003e\u003cp\u003eRemarks:\u003c/p\u003e\u003cul\u003e\u003cli\u003eAim at a relative precision better than 1e-10\u003c/li\u003e\u003cli\u003eThe problem arises studying the frictionless movement of a mass point on a hanging wire, which follows the curve cosh(x).\u003c/li\u003e\u003c/ul\u003e","function_template":"function I = coshint(x0)\r\n  I = x0;\r\nend","test_suite":"%%\r\nx0 = 1;\r\nI_correct = 2.6405789412796;\r\nfprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\nassert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\n\r\n%%\r\nx0 = 2;\r\nI_correct = 3.9464053536380;\r\nfprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\nassert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\n\r\n%%\r\nx0 = 13;\r\nI_correct = 9.4065231838369e+02;\r\nfprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\nassert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\n\r\n%% randomized test for small values of x0 where \r\n % cosh(x) ~ 1 + x^2/2 + ...\r\n % and up to x0=1e-5 Integrating (analytically) the approximation is\r\n % accurate enough\r\nfor l=1:5\r\n   x0 = 1e-6 * (1+rand);\r\n   I_correct = pi*(4+x0^2)/4/sqrt(2);\r\n   fprintf('Relative difference to reference solution: %e\\n',norm(coshint(x0)-I_correct)/I_correct)\r\n   assert(norm(coshint(x0)-I_correct)/I_correct \u003c= 1e-10)\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":9,"created_by":203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":106,"test_suite_updated_at":"2013-01-11T15:08:44.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-01-11T14:11:17.000Z","updated_at":"2026-03-13T22:59:58.000Z","published_at":"2013-01-11T15:08:44.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\u003eInput\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ex0\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, a real number greater than 0\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\u003eOutput\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:rPr\u003e\u003cw:rFonts w:cs=\\\"monospace\\\"/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eI\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, a numerical estimate of the integral\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[      x0\\n      /\\n  I = |  cosh(x) / sqrt(cosh(x0) - cosh(x)) dx\\n      /\\n      0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\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[   x0=1.0  --\u003e  I = 2.6405789412796]]\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\u003eRemarks:\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\u003eAim at a relative precision better than 1e-10\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\u003eThe problem arises studying the frictionless movement of a mass point on a hanging wire, which follows the curve cosh(x).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"numerical integration\"","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:\"numerical integration\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"numerical integration\"","","\"","numerical integration","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f2370bb0518\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f2370bb0478\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f2370bedd50\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f2370bb2e58\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f2370bb2d18\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f2370bb2c78\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f2370bb15f8\u003e":"tag:\"numerical integration\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f2370bb15f8\u003e":"tag:\"numerical integration\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"cody-search","password":"78X075ddcV44","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"numerical integration\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"numerical integration\"","","\"","numerical integration","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f2370bb0518\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f2370bb0478\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f2370bedd50\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f2370bb2e58\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f2370bb2d18\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f2370bb2c78\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f2370bb15f8\u003e":"tag:\"numerical integration\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f2370bb15f8\u003e":"tag:\"numerical integration\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":43129,"difficulty_rating":"easy"},{"id":59671,"difficulty_rating":"easy"},{"id":1197,"difficulty_rating":"medium"}]}}