Description
eulers_method implements Euler’s method for finding a numerical solution of the first-order ODE $y′=f(x,y)$. The $x$ column of the table increments from $x_0$ to $x_1$ by $h$ (so $(x_1 − x_0)/h$ must be an integer). In the $y$ column, the new $y$-value equals the old $y$-value plus the corresponding entry in the last column. Euler's method is used primarily for pedagogical purposes. The following Sage commands use Euler's method to generate a solution for
(1)where $h = 1/2$ and $x$ ranges from $0$ to $1$.
Sage Cell
Code
x,y = PolynomialRing(QQ,2,"xy").gens()
eulers_method(5*x+y-5,0,1,1/2,1)
Options
Option
To generate a list of points instead of a table, we can use the following commands.
Code
x,y = PolynomialRing(QQ,2,"xy").gens()
eulers_method(5*x+y-5,0,1,1/2,1,algorithm="none")
Option
We can also generate solutions over the reals.
Code
RR = RealField(sci_not=0, prec=4, rnd='RNDU')
x,y=PolynomialRing(RR,2,"xy").gens()
eulers_method(5*x+y-5,0,1,1/2,1)
Tags
Primary Tags: Differential Equations
Secondary Tags: Numerical Methods: Euler
A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.
Related Cells
- desolve. Solving ordinary differential equations with desolve.
- desolve_odeint. Solving ordinary differential equations numerically with desolve_odeint.
- Euler's Method for Systems. eulers_method_2x2 implements Euler’s method for finding a numerical solution of a $2 \times 2$ system of first-order ODEs.
- desolve_laplace. Solving ordinary differential equations using Laplace transforms.
- Interact to plot direction fields and solutions for first order differential equations. A Sage interact for plotting direction fields for differential equations.
Attribute
Permalink:
Author: Sage Tutorial v8.1
Date: 13 Feb 2018 15:51
Submitted by: Tom Judson