## 2280 8:05am Lectures Week 4 S2018

Last Modified: February 05, 2018, 10:49 MST.    Today: September 23, 2018, 13:49 MDT.
```Topics
The textbook definitions and theoremsEdwards-Penney 2.4, 2.5, 2.6 (11.3 K, txt, 18 Dec 2013)Edwards-Penney 3.1, 3.2, 3.3, 3.4 (16.5 K, txt, 04 Jan 2015)   ```

### Mon-Tue: Newton Kinematic Models. Projectiles. Jules Verne. Section 2.3.

```Partial Fraction Theory

Separation of variables and partial fractions (Delayed from week 2)
Exercise solution problem 2.1-8
The equation y'=7y(y-13), y(0)=17
F(x) = 7, G(y) = y(y-13)
Separated form y'/G(y) = F(x)
Answer check using the Verhulst solution
P(t) = aP_0/(bP_0 + (a-b P_0)exp(-at))
Separation of variables details.
Partial fraction details for 1/((u(u-13)) = A/u + B/(u-13)
```
```Section 2.3: Newton's force and friction models
Isaac Newton ascent and descent kinematic models.
Free fall with no air resistance F=0.
Linear air resistance models F=kx'.
Non-linear air resistance models F=k|x'|^2.
The tennis ball problem.
Does it take longer to rise or longer to fall?Text: Bolt shot Example 2.3-3 (1.0 K, txt, 16 Dec 2012)Slides: Newton kinematics with air resistance. Projectiles. (134.8 K, pdf, 30 Jan 2018)
A rocket from the earth to the moonSlides: Jules Verne Problem (124.2 K, pdf, 01 Jan 2015)
Proofs of 2.3 theorems in the textbook and derivation of details for
the rise and fall equations with air resistance.Problem notes for Chapter 2 (10.8 K, txt, 22 Dec 2014)

Numerical Solution of y'=f(x,y)
Two problems will be studied.
First problem
y' = -2xy, y(0)=2
Symbolic solution y = 2 exp(-x^2)
This problem appears in the Week 3 homework.
Second problem
y' = (1/2)(y-1)^2, y(0)=2
Symbolic solution y = (x-4)/(x-2)
Not assigned, only a lecture example.
Numerical Solution of y'=F(x)
Example: y'=2x+1, y(0)=1
Symbolic solution y=x^2 + x + 1.
Dot table. Connect the dots graphic.
The exact answers for y(x)=x^2+x+1 are
(x,y) = [0., 1.], [.1, 1.11], [.2, 1.24], [.3, 1.39],
[.4, 1.56], [.5, 1.75], [.6, 1.96], [.7, 2.19], [.8,
2.44], [.9, 2.71], [1.0, 3.00]
Maple support for making a connect-the-dots graphic.
Example: L:=[[0., 1.], [2,3], [3,-1], [4,4]]; plot(L);JPG Image: connect-the-dots graphic (11.2 K, jpg, 11 Sep 2010)
Example: Find y(2) when y'=x exp(x^3), y(0)=1.
No symbolic solution!
How to draw a graphic with no solution formula?
Make the dot table by approximation of the integral of F(x).
REFERENCE:Slides: Numerical methods (136.2 K, pdf, 16 Mar 2018)
RECTANGULAR RULE
int(F(x),x=a..b) = F(a)(b-a) approximately
for small intervals [a,b]
Geometry and the Rectangular Rule
Example: y'=2x+1, y(0)=1
Rectangular rule applied to y(1)=1+int(F(x),x=0..1)
for y'=F(x), in the case F(x)=2x+1.
Dot table steps for h=0.1, using the rule 10 times.
Answers: (x,y) = [0, 1], [.1, 1.1], [.2, 1.22], [.3, 1.36],
[.4, 1.52], [.5, 1.70], [.6, 1.90], [.7, 2.12], [.8, 2.36],
[.9, 2.62], [1.0, 2.90]
The correct answer y(2)=3.00 was approximated as 2.90.
Where did [.2,1.22] come from?
y(.2) = y(.1)+int(F(x),x=0.1 .. 0.2) [exactly]
= y(.1)+(0.2-0.1)F(0.1) [approximately, RECT RULE]
= y(.1)+0.1(2x+1) where x=0.1
= 1.1 + 0.1(1.2)  [approx, from data [.1,1.1]]
= 1.22
Rect, Trap, Simp rules from calculus
RECT
Replace int(F(x),x=a..b) by rectangle area (b-a)F(a)
TRAP
Replace int(F(x),x=a..b) by trapezoid area (b-a)(F(a)+F(b))/2
SIMP
(b-a)(F(a)+4F(a/2+b/2)+F(b))/6

The Euler, Heun, RK4 rules from this course: how they relate to
calculus rules RECT, TRAP, SIMP
Numerical Integration   Numerical Solutions of DE
RECT                    Euler
TRAP                    Heun [modified Euler]
SIMP                    Runge-Kutta 4 [RK4]

Example: y'=3x^2-1, y(0)=2 with solution y=x^3-x+2.
Example: y'=2x+1, y(0)=1 with solution y=x^2+x+1.
Dot tables,  connect the dots graphic.
How to draw a graphic without knowing the solution equation for y.

What to do when int(F(x),x) has no formula?
Key example y'=x exp(x^3), y(0)=2.
Challenge: Can you integrate F(x) = x exp(x^3)?
Making the dot table by approximation of the integral of F(x).
Accuracy: Rect, Trap, Simp rules have 1,2,4 digits resp.
Maple code for the RECT rule
Applied to the quadrature problem y'=2x+1, y(0)=1.
# Group 1, initialize.
F:=x->2*x+1:
x0:=0:y0:=1:h:=0.1:Dots:=[x0,y0]:n:=10:

# Group 2, repeat n times. RECT rule.
for i from 1 to n do
Y:=y0+h*F(x0);
x0:=x0+h:y0:=Y:Dots:=Dots,[x0,y0];
od:

# Group 3, display dots and plot.
Dots;
plot([Dots]);
Problem:  y'=x+1, y(0)=1
It has a dot table with x=0, 0.25, 0.5, 0.75, 1 and
y= 1, 1.25, 1.5625, 1.9375, 2.375.
The exact solution y = 0.5(1+(x+1)^2) has values
y=1, 1.28125, 1.625, 2.03125, 2.5000.
Determine how the dot table was constructed and identify
which rule, either Rect, Trap, or Simp, was applied.
Problem:  y'=x exp(x^3), y(0)=2
Find the value of y(2)=2+int(x*exp(x^3),x=0..1) to 4 digits.
Elementary integration won't find the integral, it has to be done
numerically. Choose a method and obtain 2.781197xxxx.
F:=x->x*exp(x^3);
int(F(x),x=0..1);  # Re-prints the problem. No answer.
evalf(%);          # ANS=0.7811970311 by numerical integration.
```

### Wed-Fri: Sections 2.5, 2.5, 2.6. Algorithms for y'=f(x,y)

``` Second lecture on numerical methods
Study problems like y'=-2xy, which have the form y'=f(x,y).
New algorithms are needed. Rect, Trap and Simp won't work,
because of the variable y on the right.
Euler, Heun, RK4 algorithms
Computer implementation in maple
Geometric and algebraic ideas in the derivations.
Numerical Integration   Numerical Solutions of y'=f(x,y)
RECT                    Euler
TRAP                    Heun [modified Euler]
SIMP                    Runge-Kutta 4 [RK4]
Reference for the ideas is thisSlides: Numerical methods (136.2 K, pdf, 16 Mar 2018)
Numerical Solution of y'=f(x,y)
Two problems will be studied.
First problem
y' = -2xy, y(0)=2
Symbolic solution y = 2 exp(-x^2)
Second problem
y' = (1/2)(y-1)^2, y(0)=2
Symbolic solution y = (x-4)/(x-2)
MAPLE TUTOR for NUMERICAL METHODS
# y'=-2xy, y(0)=2, by Euler, Heun, RK4
with(Student[NumericalAnalysis]):
InitialValueProblemTutor(diff(y(x),x)=-2*x*y(x),y(0)=2,x=0.5);
# The tutor compares exact and numerical solutions.
Examples
Web references contain two kinds of examples.
The first three are quadrature problems dy/dx=F(x).
y'=3x^2-1, y(0)=2, solution y=x^3-x+2
y'=exp(x^2), y(0)=2, solution y=2+int(exp(t^2),t=0..x).
y'=2x+1, y(0)=3 with solution y=x^2+x+3.
The fourth is of the form dy/dx=f(x,y), which requires a
non-quadrature algorithm like Euler, Heun, RK4.
y'=1-x-y, y(0)=3, solution y=2-x+exp(-x).

==> Left off here on Friday, will continue on Monday

WORKED EXAMPLE
y'=1-x-y, y(0)=3, solution y=2-x+exp(-x).
We will make a dot table by hand and also by machine.
The handwritten work for the Euler Method and the Improved Euler
Method [Heun's Method] are available:Jpeg: Handwritten example y'=1-x-y, y(0)=3, Euler and Heun (427.8 K, jpg, 15 Dec 2012)
The basic reference:Slides: Numerical methods (136.2 K, pdf, 16 Mar 2018)
EULER METHOD
Let f(x,y)=1-x-y, the right side of the differential equation.
Use step size h=0.2 from x=0 to x=0.4. The dot table has 3 rows.
Table row 1: x0=0, y0=3
Taken from initial condition y(0)=3
Table row 2: x1=0.2, y1=2.6
Compute from x1=x0+h, y1=y0+hf(x0,y0)=3+0.2(1-0-3)
Table row 3: x2=0.4, y2=2.24
Compute from x2=x1+h, y2=y1+hf(x1,y1)=2.6+0.2(1-0.2-2.6)
MAPLE EULER: [0, 3], [.2, 2.6], [.4, 2.24]

HEUN METHOD
Let f(x,y)=1-x-y, the right side of the differential equation.
Use step size h=0.2 from x=0 to x=0.4. The dot table has 3 rows.
Table row 1: x0=0, y0=3
Taken from initial condition y(0)=3
Table row 2: x1=0.2, y1=2.62
Compute from x1=x0+h, tmp=y0+hf(x0,y0)=2.6,
y1=y0+h(f(x0,y0)+f(x1,tmp))/2=2.62
Table row 3: x2=0.4, y2=2.2724
Compute from x2=x1+h, tmp=y1+hf(x1,y1)=2.62+0.2*(1-0.2-2.62)
y2=y1+h(f(x1,y1)+f(x2,tmp))/2=2.2724
MAPLE HEUN: [0, 3], [.2, 2.62], [.4, 2.2724]

RK4 METHOD
Let f(x,y)=1-x-y, the right side of the differential equation.
Use step size h=0.2 from x=0 to x=0.4. The dot table has 3 rows.
The only Honorable way to solve RK4 problems is with a calculator or
computer. A handwritten solution is not available (and won't be).
Table row 1: x0=0, y0=3
Taken from initial condition y(0)=3
Table row 2: x1=0.2, y1=2.618733333
Compute from x1=x0+h, 5 lines of RK4 code
Table row 3: x2=0.4, y2=2.270324271
Compute from x2=x1+h, 5 lines of RK4 code
MAPLE RK4: [0, 3], [.2, 2.618733333], [.4, 2.270324271]

EXACT SOLUTION
We solve the linear differential equation by the integrating factor
method to obtain y=2-x+exp(-x).
# MAPLE evaluation of y=2-x+exp(-x)
F:=x->2-x+exp(-x);[[j*0.2,F(j*0.2)] \$j=0..2];
# Answer [[0., 3.], [0.2, 2.618730753], [0.4, 2.270320046]]

COMPARISON GRAPHIC
The three results for Euler, Heun, RK4 are compared to the exact
solution y=2-x+exp(-x) in theGRAPHIC: y'=1-x-y Compare Euler-Heun-RK4 (17.8 K, jpg, 09 Dec 2012)
The comparison graphic was created with thisMAPLE TEXT: y'=1-x-y by Euler-Heun-RK4 (1.1 K, txt, 09 Dec 2012)    ```

### Friday: Ch 3

``` EULER SOLUTION ATOMS and INDEPENDENCE.

Def. atom=x^n(base atom)
base atom = 1, exp(ax), cos(bx), sin(bx), exp(ax) cos(bx),
exp(ax) sin(bx) for nonzero real a and positive real b
THEOREM. Euler solution atoms are independent.
EXAMPLE. Show 1, x^2, x^9 are independent by 3 methods.
EXAMPLE. Independence of 1, x^2, x^(3/2) by the Wronskian test.
Equation y''+10y'=0 has general solution y=c1 + c2 exp(-10x)
The Euler solution atoms for this example are 1 and exp(-10x).
Differential equations like this one have general solution a
linear combination of atoms.
THEOREM. An nth order scalar homogeneous linear differential equation
has general solution a linear combination of Euler solution atoms.

TOOLKIT for SOLVING LINEAR CONSTANT DIFFERENTIAL EQUATIONS
Picard: Order n of a DE = dimension of the solution space.
General solution = linear combination n independent atoms.
Euler's theorem(s), an algorithm for finding solution atoms.

Summary for Higher Order Differential Equations

Slides: Atoms, Euler's theorem, 7 examples (130.5 K, pdf, 25 Feb 2013)Slides: Base atom, atom, basis for linear DE (106.8 K, pdf, 07 Feb 2018)
EXAMPLE. The equation y'' +10y'=0.
How to solve y'' + 10y' = 0, chapter 1 methods.
Idea: Let v=x'(t) to get a first order DE in v and a quadrature
equation x'(t)=v(t). Solve the first order DE by the linear
integrating factor method. Then insert the answer into
x'(t)=v(t) and continue to solve for x(t) by quadrature.
Vector space of functions: solution space of a differential
equation.
A basis for the solution space of y'' + 10y'=0 is {1,exp(-10x)}

PICARDS THEOREM
The theorem of Picard and Lindelof for y'=f(x,y) has an extension
for systems of equations, which applies to scalar higher order
linear differential equations.

THEOREM [Picard]
A homogeneous nth order linear differential equation with
continuous coefficients has a general solution written as a linear
combination of n independent solutions. This means that the
solution space of the differential equation has dimension n.

```