{"id":904,"date":"2015-01-17T15:04:49","date_gmt":"2015-01-17T21:04:49","guid":{"rendered":"http:\/\/www.ssc.wisc.edu\/~jfrees\/?page_id=904"},"modified":"2015-02-20T18:10:46","modified_gmt":"2015-02-21T00:10:46","slug":"eulers-method-for-solving-ordinary-differential-equations","status":"publish","type":"page","link":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/actuarial-mathematics\/policy-values\/6-policy-values-with-continuous-cash-flows\/eulers-method-for-solving-ordinary-differential-equations\/","title":{"rendered":"Euler&#8217;s Method for Solving Ordinary Differential Equations"},"content":{"rendered":"<p>Wish to evaluate a generic function f\\((t\\)). Suppose we know a starting value, for example, f(0) = \\(c\\). We also know that we can express f\\((\\cdot\\)) through the ordinary differential equation<br \/>\n\\begin{eqnarray*}<br \/>\n\\frac{\\partial}{\\partial t} \\textrm{f}(t) = \\textrm{g}(\\textrm{f}(t)),<br \/>\n\\end{eqnarray*}<br \/>\nwhere \\(\\textrm{g}(\\cdot)\\) is a known function. Occasionally, we can solve the ordinary differential equation analytically. More often, a numerical solution is available. The easiest to explain and to implement is Euler&#8217;s method. To see this, consider a small \\(h\\) and use a straight line approximation for the derivative<br \/>\n\\begin{eqnarray*}<br \/>\n\\frac{\\partial}{\\partial t} \\textrm{f}(t) \\approx \\frac{\\textrm{f}(t+h)-\\textrm{f}(t)}{h}.<br \/>\n\\end{eqnarray*}<br \/>\nWith this, we have an approximation to the ordinary differential equation<br \/>\n\\begin{eqnarray*}<br \/>\n\\textrm{f}(t+h) \\approx \\textrm{f}(t) + h \\textrm{g}(\\textrm{f}(t))<br \/>\n\\end{eqnarray*}<br \/>\nthat we can evaluate recursively. <\/p>\n<p><strong>Example &#8211; Interest Theory<\/strong><br \/>\nSuppose that \\(\\textrm{g}(t) = 0.05 t\\), a line, and f(0) = 1. Then, if \\(h=0.001\\), we have<br \/>\n\\begin{eqnarray*}<br \/>\n\\textrm{f}(t+h) \\approx \\textrm{f}(t) + (0.001) (0.05) \\textrm{f}(t) .<br \/>\n\\end{eqnarray*}<\/p>\n<table>\n<tr>\n<td>t<\/td>\n<td>Approximate f(<i>t<\/i>)<\/td>\n<td>Exact f(<i>t<\/i>)<\/td>\n<td>Error <\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>1.0000000000<\/td>\n<td>1.0000000000<\/td>\n<td>0.0000000000<\/td>\n<\/tr>\n<tr>\n<td>0.001<\/td>\n<td>1.0000500000<\/td>\n<td>1.0000500013<\/td>\n<td>0.0000000013<\/td>\n<\/tr>\n<tr>\n<td>0.002<\/td>\n<td>1.0001000025<\/td>\n<td>1.0001000050<\/td>\n<td>0.0000000025<\/td>\n<\/tr>\n<tr>\n<td>0.998<\/td>\n<td>1.0511646632<\/td>\n<td>1.0511659745<\/td>\n<td>0.0000013113<\/td>\n<\/tr>\n<tr>\n<td>0.999<\/td>\n<td>1.0512172215<\/td>\n<td>1.0512185341<\/td>\n<td>0.0000013127<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1.0512697823<\/td>\n<td>1.0512710964<\/td>\n<td>0.0000013140<\/td>\n<\/tr>\n<\/table>\n<p>For this example, we can evaluate f(\\(\\cdot\\)) analytically, in that<br \/>\n\\begin{eqnarray*}<br \/>\n\\frac{\\partial}{\\partial t} \\textrm{f}(t) = 0.05 \\textrm{f}(t) \\ \\ \\ \\ \\Rightarrow \\ \\ \\ \\ \\frac{\\partial}{\\partial t} \\ln \\textrm{f}(t) = 0.05 ,<br \/>\n\\end{eqnarray*}<br \/>\nand so that, with f(0) = 1, we have \\( \\textrm{f}(t) = e^{0.05 t}\\). <\/p>\n<p><div class=\"alignleft\"><a href=\"https:\/\/users.ssc.wisc.edu\/~ewfrees\/actuarial-mathematics\/policy-values\/6-policy-values-with-continuous-cash-flows\/\" title=\"6. Policy Values with Continuous Cash Flows\">&#9668 Previous page<\/a><\/div><div class=\"alignright\"><a href=\"https:\/\/users.ssc.wisc.edu\/~ewfrees\/actuarial-mathematics\/policy-values\/6-policy-values-with-continuous-cash-flows\/example-inflation-indexed-benefits-and-premiums\/\" title=\"Example. Inflation Indexed Benefits and Premiums.\">Next page &#9658<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Wish to evaluate a generic function f\\((t\\)). Suppose we know a starting value, for example, f(0) = \\(c\\). We also know that we can express f\\((\\cdot\\)) through the ordinary differential equation \\begin{eqnarray*} \\frac{\\partial}{\\partial t} \\textrm{f}(t) &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":897,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"jetpack_post_was_ever_published":false},"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P8cLPd-eA","acf":[],"_links":{"self":[{"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/pages\/904"}],"collection":[{"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/comments?post=904"}],"version-history":[{"count":3,"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/pages\/904\/revisions"}],"predecessor-version":[{"id":1576,"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/pages\/904\/revisions\/1576"}],"up":[{"embeddable":true,"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/pages\/897"}],"wp:attachment":[{"href":"https:\/\/users.ssc.wisc.edu\/~ewfrees\/wp-json\/wp\/v2\/media?parent=904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}