{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Euler's Method for Initial-Value Problems\n", "\n", "## Overview, Objectives, and Key Terms\n", " \n", "In this lecture, we review the basics of *first-order*, *ordinary differential equations* (ODEs) and their role in *initial value problems* (IVPs). Engineering is full of such IVPs, and we can tackle them using the finite-difference approximations and nonlinear solvers we've already seen.\n", "\n", "\n", "### Objectives\n", "\n", "By the end of this lesson, you should be able to\n", "\n", "- Define first-order IVPs given engineering input (e.g., a description of some system)\n", "- Solve first-order IVPs analytically (prior knowledge in part)\n", "- Solve first-order IVPs numerically using the forward-Euler and backward-Euler methods.\n", "\n", "### Prerequisites\n", "\n", "You should already have a basic comprehension of ODEs, especially IVPs, at the level covered in MATH 340 (now a pre-requisite for this course). That includes deducing general solutions, applying initial conditions, and determining complete solutions. In fact, you should also know something about Laplace transforms and Euler's method, the latter technique which is the focus of this lesson. Specifically, you should, given a day or two of review, be able to sit down and complete a good chunk of an exam like [this one](https://www.math.ksu.edu/courses/exam-archive/math240/Math240fxS17.pdf) at a passing level. If that is *not* the case, see an instructor in office hours and/or begin to review the [MATH 340 textbook](https://www.math.ksu.edu/math240/book/).\n", "\n", "\n", "### Key Terms\n", "\n", "- differential equation\n", "- ordinary\n", "- linear\n", "- ODE\n", "- initial value problem\n", "- boundary value problem" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Differential Equations\n", "\n", "A *differential equation* is any equation in which an unknown function $f$ appears with one of more of its derivatives. When $f$ is a function of only one variable, the derivatives are *ordinary* (as opposed to *partial*), and the equation is an *ordinary differential equation* (ODE). In compact notation, such an equation may be written $\\mathcal{L}f(x)=q(x)$, where $\\mathcal{L}$ is a differential operator. If $\\mathcal{L}$ contains only *linear combinations* of $f(x)$ and its derivates, then $\\mathcal{L}$ is a *linear operator*, and the equation is a *linear* ODE. If $q(x) = 0$, the equation is *homogeneous* and is otherwise *inhomogeneous*. If the highest derivative of $f(x)$ present in $\\mathcal{L}f$ is $n$ (i.e., $d^n f/dx^n$), then the equation is called an *n*th-order equation.\n", "\n", "Examples of linear operators include $\\mathcal{L}f = \\frac{df}{dx}$ and $\\mathcal{L}f = a(x) \\frac{d^2f}{dx^2} + b(x)$, where $a(x)$ and $b(x)$ are arbitrary functions of $x$ (but not of $f(x)$). For comparison, a nonlinear example is $\\mathcal{L}f = \\left ( \\frac{df}{dx} \\right )^2 - \\sqrt{f(x)}$, which includes nonlinear functions of $f$ and its first derivative.\n", "\n", "Our focus here and the next module is entirely on *ordinary differential equations* (both linear and nonlinear) and their solution by analytic and numerical techniques." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Where Does the Standard First-Order Linear IVP Come From?\n", "\n", "Consider problems of the form\n", "\n", "$$\n", " \\frac{dy}{dt} + p(t)y(t) = q(t) \\, , \\qquad y(0) = y_0 \\, .\n", "$$\n", "\n", "This is the canonical way to represent a **first-order**, **linear**, **initial-value problem** (IVP). It is first order because there is only a first derivative. It is an initial-value problem because the unknown (here, $y(t)$) is specified at some \"initial\" time. It is linear because $p(t)$ does not depend on $y(t)$.\n", "\n", "A first-order IVP can be used to represent of a number of physical phenomena. The first that comes to mind (to me, as a nuclear engineer) is [radioactive decay](https://en.wikipedia.org/wiki/Exponential_decay) with external production, usually written $N' = -\\lambda N(t) + R(t)$, where $N(t)$ is the number of radioactive nuclei at time $t$, $\\lambda$ is the decay constant (with units of inverse seconds), and $R(t)$ is the number of new nuclei born per second. The time rate of change of $N(t)$ is a balance of those new nuclei from $R(t)$ against the number $-\\lambda N(t)$ lost by decay. For sufficiently long times, $dy/dt \\to 0$, and $y = R/\\lambda$, a *steady state* in which losses are exactly balanced by gains.\n", "\n", "An equally good example is the case of an object of mass $m$ in [free fall through a viscuous medium](http://hyperphysics.phy-astr.gsu.edu/hbase/lindrg.html), e.g., the atmosphere. If some object is held a distance above the earth and dropped, its acceleration at any point in time is related to the net forces acting on the body. These forces include the gravitational force $F_g = -m g$ (i.e., downward) and the air resistance $F_r$. A simple resistance model is $F_r = cv$, where $c$ is a (positive) constant and $v$ is the velocity directed toward Earth. Hence,\n", "the downward force is \n", "\n", "$$\n", " F(t) = -cv(t) + m g \\, .\n", "$$\n", "\n", "From Newton's second law, $F = ma$, so we have\n", "\n", "$$\n", " ma(t) = m \\frac{dv}{dt} = -cv(t) + mg \\, ,\n", "$$\n", "\n", "or\n", "\n", "$$\n", " v' = -\\frac{c}{m} v(t) + g \\, .\n", "$$\n", "\n", "The positive $c/m$ has the same effect as a positive $\\lambda$ in radioactive decay: the larger the velocity $v$, the larger the retardation force $cv$ (just like the larger the number of nuclei $N$, the larger the number $\\lambda N$ decaying per unit time). For the free-fall case, the steady-state condition $v'=0$ has a special name: *terminal velocity*. \n", "\n", "Lots of phenomena have this sort of behavior, this natural *negative feedback*, and such feedback can help us when we solve these problems numerically. In those cases where the feedback is *positive*, we expect the number of nuclei to *grow* more and more (or, equivalently, for a falling object to keep accelerating toward earth). The former happens when pythons (or neutrons) multiply in nature; thankfully, the [hail of northeastern Kansas](https://en.wikipedia.org/wiki/April_10%E2%80%9311,_2001_tornado_outbreak#Tri-state_hailstorm) does reach a terminal velocity. Oh, and I'm not joking about pythons: combine the [Malthusian model](https://en.wikipedia.org/wiki/Malthusian_growth_model) with the fact there is an artificial source term due to pet owners releasing their larger-than-expected pets into the [Florida Everglades](https://en.wikipedia.org/wiki/Burmese_pythons_in_Florida)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "