{ "metadata": { "name": "", "signature": "sha256:090505bbb2131c53c541b05bda489a4e1dc491def5fbeaccbe30873e0ba71f01" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## M\u00e9todo de Euler\n", "Tomamos o problema de Cauchy:\n", "$$\\begin{gather}\n", "\\dot{x}=f(x,t) \\\\\n", "x(t_0) =x_0\n", "\\end{gather}$$\n", "e um conjunto de n\u00f3s $\\{t_0,t_1,\\dots,t_n\\} \\subset \\mathbb{R}$ tal que $t_i = t_0+i*h$. Chamaremos o n\u00famero real $h$ de passo do processo num\u00e9rico. O objetivo \u00e9 dar um m\u00e9todo num\u00e9rico que produza uma estimativa da solu\u00e7\u00e3o nos n\u00f3s, isto \u00e9, deveremos produzir uma estimativa $\\{x_0,x_1,\\dots,x_n\\}$ tal que $x_i \\approx x(t_i)$ se $x(t)$ for a solu\u00e7\u00e3o do problema de Cauchy." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "O m\u00e9todo mais simples de fazermos esta estimativa \u00e9 o *m\u00e9todo de Euler* que podemos derivar da s\u00e9rie de Taylor\n", "$$ \\begin{gather}\n", "x_{i+1} \\approx x(t_{i+1}) = x(t_i + h) = x(t_i) + f(x(t_i), t_i).h + \\mathcal{o}(h^2) \\\\\n", "x_{i+1} \\approx x_i + f(x_i,t_i)h\n", "\\end{gather}$$\n", "O que nos d\u00e1 um m\u00e9todo de avan\u00e7o\n", "$$ x_{i+1} = x_i + f(x_i,t_i)h $$" ] }, { "cell_type": "code", "collapsed": false, "input": [ "def edoeuler(func,t0,x0,tf,h):\n", " ''' M\u00e9todo de Euler para equa\u00e7\u00f5es diferenciais ordin\u00e1rias\n", " func - fun\u00e7\u00e3o do lado direito\n", " t0 - tempo inicial\n", " x0 - estado inicial\n", " tf - tempo final\n", " h - passo do tempo '''\n", " sol = [x0]\n", " told = t0\n", " tnovo = told + h\n", " while tnovo <= tf :\n", " x = sol[-1] + func(sol[-1],told)*h\n", " sol.append(x)\n", " [told,tnovo]=[tnovo,tnovo+h]\n", " return sol" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }