Eulers Method Systems

## Description

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

\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: systems, 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.
`eulers_method`implements Euler’s method for finding a numerical solution of the first-order ODE $y′=f(x,y)$. - 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 16:16

Submitted by: Tom Judson