{"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":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/zkNFgfmvSsDv2YOCWNrJBH3NpgoQM9xnsbKvX9j8uSBncAAf2tyDR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6j+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/HSvcBu4FNwBLgOnBhUTHw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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+0Vvi94P92LNl8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FSubZ3lJM5UkxoBHgAwWsFd9CJMkwycePAtwrwRmfRJiGlkDQu61rCkGjaPdgYcUcNbdytW1fQIdGUGUWezzqMhKN18+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":42807,"title":"Approximate e","description":"Given a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\r\n\r\nExample:\r\n\r\na = 1\r\n\r\nn = 1\r\n\r\nf = 2.71828","description_html":"\u003cp\u003eGiven a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003ea = 1\u003c/p\u003e\u003cp\u003en = 1\u003c/p\u003e\u003cp\u003ef = 2.71828\u003c/p\u003e","function_template":"function f = approx_e(a,n)\r\n  f = a * n;\r\nend","test_suite":"%%\r\na = 1;\r\nn = 1;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = 2^18;\r\nn = 0;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = pi;\r\nn = pi;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = -exp(1);\r\nn = exp(2);\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\nfiletext = fileread('approx_e.m');\r\nassert(isempty(strfind(filetext,'exp')))\r\nassert(isempty(strfind(filetext,'str')))\r\nassert(isempty(strfind(filetext,'cat')))\r\nassert(isempty(strfind(filetext,'feval')))\r\nassert(all(cellfun(@(z)str2num(z)==round(str2num(z)),regexp(filetext,'[0123456789.]+','match'))))\r\nassert(isempty(regexp(filetext,'\\d+e')))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2016-04-19T11:46:46.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-04-18T05:23:45.000Z","updated_at":"2026-02-19T10:15:47.000Z","published_at":"2016-04-18T05:24: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\",\"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\u003eGiven a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\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\u003eExample:\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\u003ea = 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ef = 2.71828\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":2909,"title":"Approximation of Pi (vector inputs)","description":"Pi (divided by 4) can be approximated by the following infinite series:\r\n\r\npi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\r\n\r\nFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\r\n\r\nThis problem is the same as \u003chttps://www.mathworks.com/matlabcentral/cody/problems/2908-approximation-of-pi Problem 2908\u003e, except that the test suite will pass vectors for the number of terms, rather than breaking each truncated infinite series into a separate test.","description_html":"\u003cp\u003ePi (divided by 4) can be approximated by the following infinite series:\u003c/p\u003e\u003cp\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\u003c/p\u003e\u003cp\u003eFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\u003c/p\u003e\u003cp\u003eThis problem is the same as \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/2908-approximation-of-pi\"\u003eProblem 2908\u003c/a\u003e, except that the test suite will pass vectors for the number of terms, rather than breaking each truncated infinite series into a separate test.\u003c/p\u003e","function_template":"function y = pi_approx(n)\r\n y = n;\r\nend","test_suite":"%%\r\nn = 1:5;\r\ny_correct = [-0.858407346410207 0.474925986923126 -0.325074013076874 0.246354558351698 -0.198089886092747];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\r\n\r\n%%\r\nn = 2:2:10;\r\ny_correct = [0.474925986923126 0.246354558351698 0.165546477543617 0.124520836517975 0.099753034660390];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\r\n\r\n%%\r\nn = 5:5:25;\r\ny_correct = [-0.198089886092747 0.099753034660390 -0.066592998672151 0.049968846921953 -0.039984031845239];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\r\n\r\n%%\r\nn = 10:10:100;\r\ny_correct = [0.099753034660390 0.049968846921953 0.033324086890846 0.024996096795960 0.019998000998782 0.016665509660796 0.014284985608559 0.012499511814072 0.011110768228485 0.009999750031239];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\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":276,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":29,"created_at":"2015-02-01T03:45:00.000Z","updated_at":"2026-04-01T09:59:49.000Z","published_at":"2015-02-01T03:45:00.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\u003ePi (divided by 4) can be approximated by the following infinite series:\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\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\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 a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\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\u003eThis problem is the same as\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/2908-approximation-of-pi\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2908\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, except that the test suite will pass vectors for the number of terms, rather than breaking each truncated infinite series into a separate test.\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":2908,"title":"Approximation of Pi","description":"Pi (divided by 4) can be approximated by the following infinite series:\r\npi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\r\nFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\r\nAlso, try Problem 2909, a slightly harder variant of this problem.","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: 132px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 66px; transform-origin: 407px 66px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 215px 8px; transform-origin: 215px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePi (divided by 4) can be approximated by the following infinite series:\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: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 88.5px 8px; transform-origin: 88.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\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: 360px 8px; transform-origin: 360px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\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: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAlso, try\u003c/span\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: 2px 8px; transform-origin: 2px 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/2909-approximation-of-pi-vector-inputs\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 2909\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: 128.5px 8px; transform-origin: 128.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, a slightly harder variant of this problem.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = pi_approx(n)\r\n y = n;\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = -0.858407346410207;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 2;\r\ny_correct = 0.474925986923126;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps)) \r\n\r\n%%\r\nn = 4;\r\ny_correct = 0.246354558351698;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 7;\r\ny_correct = -0.142145830148691;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 10;\r\ny_correct = 0.099753034660390;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 14;\r\ny_correct = 0.071338035810608;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 17;\r\ny_correct = -0.058772861819756;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 20;\r\ny_correct = 0.049968846921953;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 25;\r\ny_correct = -0.039984031845239;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 42;\r\ny_correct = 0.023806151830915;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n","published":true,"deleted":false,"likes_count":18,"comments_count":0,"created_by":26769,"edited_by":223089,"edited_at":"2022-09-05T17:21:56.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1408,"test_suite_updated_at":"2022-09-05T17:21:56.000Z","rescore_all_solutions":false,"group_id":29,"created_at":"2015-02-01T03:29:10.000Z","updated_at":"2026-04-07T02:00:48.000Z","published_at":"2015-02-01T03:29:10.000Z","restored_at":null,"restored_by":null,"spam":false,"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\u003ePi (divided by 4) can be approximated by the following infinite series:\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\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\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\u003eFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\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\u003eAlso, try\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/2909-approximation-of-pi-vector-inputs\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2909\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, a slightly harder variant of this problem.\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":44359,"title":"5th Time's a Charm","description":"Write a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\r\n\r\nFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.","description_html":"\u003cp\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\u003c/p\u003e\u003cp\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\u003c/p\u003e","function_template":"function y = fifth_times_a_charm(x)\r\n y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = -1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = 42;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = i;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))","published":true,"deleted":false,"likes_count":7,"comments_count":5,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":193,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-03T17:35:55.000Z","updated_at":"2026-03-13T03:06:49.000Z","published_at":"2017-10-16T01:51:00.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\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\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\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\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":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/77T2fzLoHt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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,iVBOR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mLBeYDPaS1r+Y3m6nkDfl3rea/khDW6cC+Kms2rWnn4MDkX8E2ry3XS5gG+Nrmrtfh1BR4lJzG28JmqYrx36tTVe4aSbcDgjmqB9+GjFvhScldTRnrX2sfvzbAac+NeOWqBr07umkKxLLxkdVZPl2J8bS3q3VWuWQG/iyR3fVECa0TBTwpU39SqBd5XZNVHr7zwYajkSmvKOd/AyQHqFWSC+QhSAE9czPUPUgD3Ibnz/Xf4TBlPrUxMQaZa4jVZvTFD98zKiJI119bT1rLNhQ/vaUpv6QCv5BX6DDxy+0Fk9XwqtPmWba6plZRvDfAw87WIFyQWWzxDsSNQppG5li0AeLeWKsGs31zq2pkHKXmFvrj0Jh9UJHtEVEu0nGl5MwwjvC49FSubZ3lJM5UkxoBHgAwWsFd9CJMkwycePAtwrwRmfRJiGlkDQu61rCkGjaPdgYcUcNbdytW1fQIdGUGUWezzqMhKN18+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":42807,"title":"Approximate e","description":"Given a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\r\n\r\nExample:\r\n\r\na = 1\r\n\r\nn = 1\r\n\r\nf = 2.71828","description_html":"\u003cp\u003eGiven a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cp\u003ea = 1\u003c/p\u003e\u003cp\u003en = 1\u003c/p\u003e\u003cp\u003ef = 2.71828\u003c/p\u003e","function_template":"function f = approx_e(a,n)\r\n  f = a * n;\r\nend","test_suite":"%%\r\na = 1;\r\nn = 1;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = 2^18;\r\nn = 0;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = pi;\r\nn = pi;\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\na = -exp(1);\r\nn = exp(2);\r\nf_correct = a*exp(n);\r\nassert(abs(approx_e(a,n)-f_correct)\u003c.001)\r\n\r\n%%\r\nfiletext = fileread('approx_e.m');\r\nassert(isempty(strfind(filetext,'exp')))\r\nassert(isempty(strfind(filetext,'str')))\r\nassert(isempty(strfind(filetext,'cat')))\r\nassert(isempty(strfind(filetext,'feval')))\r\nassert(all(cellfun(@(z)str2num(z)==round(str2num(z)),regexp(filetext,'[0123456789.]+','match'))))\r\nassert(isempty(regexp(filetext,'\\d+e')))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":15521,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2016-04-19T11:46:46.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-04-18T05:23:45.000Z","updated_at":"2026-02-19T10:15:47.000Z","published_at":"2016-04-18T05:24: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\",\"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\u003eGiven a and n, compute and approximation to f = a * e ^ n, without the use of exp, string operations, or floating point numbers.\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\u003eExample:\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\u003ea = 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003en = 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ef = 2.71828\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":2909,"title":"Approximation of Pi (vector inputs)","description":"Pi (divided by 4) can be approximated by the following infinite series:\r\n\r\npi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\r\n\r\nFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\r\n\r\nThis problem is the same as \u003chttps://www.mathworks.com/matlabcentral/cody/problems/2908-approximation-of-pi Problem 2908\u003e, except that the test suite will pass vectors for the number of terms, rather than breaking each truncated infinite series into a separate test.","description_html":"\u003cp\u003ePi (divided by 4) can be approximated by the following infinite series:\u003c/p\u003e\u003cp\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\u003c/p\u003e\u003cp\u003eFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\u003c/p\u003e\u003cp\u003eThis problem is the same as \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/2908-approximation-of-pi\"\u003eProblem 2908\u003c/a\u003e, except that the test suite will pass vectors for the number of terms, rather than breaking each truncated infinite series into a separate test.\u003c/p\u003e","function_template":"function y = pi_approx(n)\r\n y = n;\r\nend","test_suite":"%%\r\nn = 1:5;\r\ny_correct = [-0.858407346410207 0.474925986923126 -0.325074013076874 0.246354558351698 -0.198089886092747];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\r\n\r\n%%\r\nn = 2:2:10;\r\ny_correct = [0.474925986923126 0.246354558351698 0.165546477543617 0.124520836517975 0.099753034660390];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\r\n\r\n%%\r\nn = 5:5:25;\r\ny_correct = [-0.198089886092747 0.099753034660390 -0.066592998672151 0.049968846921953 -0.039984031845239];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\r\n\r\n%%\r\nn = 10:10:100;\r\ny_correct = [0.099753034660390 0.049968846921953 0.033324086890846 0.024996096795960 0.019998000998782 0.016665509660796 0.014284985608559 0.012499511814072 0.011110768228485 0.009999750031239];\r\nanswers = pi_approx(n);\r\nfor i = 1:numel(n)\r\n assert(abs(answers(i)-y_correct(i))\u003c(100*eps))\r\nend\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":276,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":29,"created_at":"2015-02-01T03:45:00.000Z","updated_at":"2026-04-01T09:59:49.000Z","published_at":"2015-02-01T03:45:00.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\u003ePi (divided by 4) can be approximated by the following infinite series:\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\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\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 a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\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\u003eThis problem is the same as\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/2908-approximation-of-pi\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2908\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, except that the test suite will pass vectors for the number of terms, rather than breaking each truncated infinite series into a separate test.\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":2908,"title":"Approximation of Pi","description":"Pi (divided by 4) can be approximated by the following infinite series:\r\npi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\r\nFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\r\nAlso, try Problem 2909, a slightly harder variant of this problem.","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: 132px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 66px; transform-origin: 407px 66px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 215px 8px; transform-origin: 215px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ePi (divided by 4) can be approximated by the following infinite series:\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: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 88.5px 8px; transform-origin: 88.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\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: 360px 8px; transform-origin: 360px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\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: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAlso, try\u003c/span\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: 2px 8px; transform-origin: 2px 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/2909-approximation-of-pi-vector-inputs\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eProblem 2909\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: 128.5px 8px; transform-origin: 128.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, a slightly harder variant of this problem.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = pi_approx(n)\r\n y = n;\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = -0.858407346410207;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 2;\r\ny_correct = 0.474925986923126;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps)) \r\n\r\n%%\r\nn = 4;\r\ny_correct = 0.246354558351698;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 7;\r\ny_correct = -0.142145830148691;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 10;\r\ny_correct = 0.099753034660390;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 14;\r\ny_correct = 0.071338035810608;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 17;\r\ny_correct = -0.058772861819756;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 20;\r\ny_correct = 0.049968846921953;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 25;\r\ny_correct = -0.039984031845239;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n\r\n%%\r\nn = 42;\r\ny_correct = 0.023806151830915;\r\nassert(abs(pi_approx(n)-y_correct)\u003c(100*eps))\r\n","published":true,"deleted":false,"likes_count":18,"comments_count":0,"created_by":26769,"edited_by":223089,"edited_at":"2022-09-05T17:21:56.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1408,"test_suite_updated_at":"2022-09-05T17:21:56.000Z","rescore_all_solutions":false,"group_id":29,"created_at":"2015-02-01T03:29:10.000Z","updated_at":"2026-04-07T02:00:48.000Z","published_at":"2015-02-01T03:29:10.000Z","restored_at":null,"restored_by":null,"spam":false,"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\u003ePi (divided by 4) can be approximated by the following infinite series:\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\u003epi/4 = 1 - 1/3 + 1/5 - 1/7 + ...\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\u003eFor a given number of terms (n), return the difference between the actual value of pi and this approximation of the constant.\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\u003eAlso, try\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=\\\"https://www.mathworks.com/matlabcentral/cody/problems/2909-approximation-of-pi-vector-inputs\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2909\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, a slightly harder variant of this problem.\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":44359,"title":"5th Time's a Charm","description":"Write a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\r\n\r\nFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.","description_html":"\u003cp\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\u003c/p\u003e\u003cp\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\u003c/p\u003e","function_template":"function y = fifth_times_a_charm(x)\r\n y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = -1;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = 42;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))\r\n\r\n%%\r\nx = i;\r\ny1 = fifth_times_a_charm(x);\r\nassert(~isequal(y1,x))\r\n\r\ny2 = fifth_times_a_charm(x);\r\nassert(~isequal(y2,x))\r\nassert(abs(x-y2)\u003cabs(x-y1))\r\n\r\ny3 = fifth_times_a_charm(x);\r\nassert(~isequal(y3,x))\r\nassert(abs(x-y3)\u003cabs(x-y2))\r\n\r\ny4 = fifth_times_a_charm(x);\r\nassert(~isequal(y4,x))\r\nassert(abs(x-y4)\u003cabs(x-y3))\r\n\r\ny5 = fifth_times_a_charm(x);\r\nassert(isequal(y5,x))","published":true,"deleted":false,"likes_count":7,"comments_count":5,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":193,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":35,"created_at":"2017-10-03T17:35:55.000Z","updated_at":"2026-03-13T03:06:49.000Z","published_at":"2017-10-16T01:51:00.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\u003eWrite a function that will return the input value. However, your function must fail the first four times, only functioning properly every fifth time. Furthermore, the first four times the function is called, successively closer, but not correct, values must be supplied by the function.\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\u003eFor example, if x = 10, you may return any number not equal to 10 the first function call. Here, we will return 27. Then, the second function call must return a value between 27 and 10, but not equal to either, and so on, until 10 is returned the fifth time.\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:\"approximation\"","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:\"approximation\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"approximation\"","","\"","approximation","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f6cb35aca90\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f6cb35ac630\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f6cb35abaf0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f6cb35acd10\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f6cb35acc70\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f6cb35acbd0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f6cb35acb30\u003e":"tag:\"approximation\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f6cb35acb30\u003e":"tag:\"approximation\""},"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:\"approximation\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"approximation\"","","\"","approximation","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f6cb35aca90\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f6cb35ac630\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f6cb35abaf0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f6cb35acd10\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f6cb35acc70\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f6cb35acbd0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f6cb35acb30\u003e":"tag:\"approximation\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f6cb35acb30\u003e":"tag:\"approximation\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":59671,"difficulty_rating":"easy"},{"id":42807,"difficulty_rating":"easy-medium"},{"id":2909,"difficulty_rating":"easy-medium"},{"id":2908,"difficulty_rating":"easy-medium"},{"id":44359,"difficulty_rating":"medium"}]}}