Eulers Method Systems

## Description

eulers_method_2x2 implements Euler’s method for finding a numerical solution of the first-order system of ODEs,

(1)
\begin{align} \frac{dx}{dt} & = f(t, x, y) \\ \frac{dy}{dt} & = g(t, x, y) \\ x(t_0) & = x_0 \\ y(t_0) & = y_0, \end{align}

The following Sage commands use Euler's method to generate a solution for

(2)
\begin{align} \frac{dx}{dt} & = x + y + t \\ \frac{dy}{dt} & = x - y \\ x(0) & = 0 \\ y(0) & = 0, \end{align}

where $h = 1/3$ and $t$ ranges from $0$ to $1$. eulers_method_2x2 is primarily used for pedagogical purposes.

## Sage Cell

#### Code

t, x, y = PolynomialRing(QQ,3,"txy").gens()
f = x+y+t
g = x-y
eulers_method_2x2(f,g, 0, 0, 0, 1/3, 1)


## Options

#### Option

We can also generate a list of points instead of a table.

#### Code

t, x, y = PolynomialRing(QQ,3,"txy").gens()
f = x+y+t
g = x-y
eulers_method_2x2(f,g, 0, 0, 0, 1/3, 1, algorithm ="none")


#### Option

We can specify our solutions to be real instead of rational.

#### Code

RR = RealField(sci_not=0, prec=4, rnd='RNDU')
t, x, y=PolynomialRing(RR,3,"txy").gens()
f = x+y+t
g = x-y
eulers_method_2x2(f,g, 0, 0, 0, 1/3, 1)


## Tags

Primary Tags: Differential Equations

Secondary Tags: Numerical Methods: Systems; Euler

A list of possible tags can be found at The WeBWorK Open Problem Library. For linear algebra tags see the Curated Courses Project.

## Attribute

Permalink:

Author: Sage Tutorial v8.1

Date: 13 Feb 2018 16:16

Submitted by: Tom Judson

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License