## 2250 8:05am Lectures Week 4 S2015

Last Modified: February 08, 2015, 11:59 MST.    Today: September 24, 2018, 11:26 MDT.
```Topics
The textbook definitions and theoremsEdwards-Penney 3.1, 3.2, 3.3 (3.0 K, txt, 18 Dec 2013)Edwards-Penney 3.4, 3.5, 3.6 (4.0 K, txt, 18 Dec 2013)```

### Monday: Sections 2.4, 2.5, 2.6. Maple examples.

```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.

==> Left off here last Friday, will complete the lecture on Monday

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).
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, 16 Dec 2012)
The basic reference isSlides: Numerical methods (149.7 K, pdf, 26 Jan 2014)
Numerical maple and matlab resources for Euler, Heun, RK4 are located in the Directory Here (0.0 K, 09 Feb 2015)
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 proceeds like this
Table row 1: x0=0, y0=3
Taken from initial condition y(0)=3
FIRST DOT = [0,3]
Table row 2: x1=0.2, y1=2.618733333
Compute from x1=x0+h, 5 lines of RK4 code:
k1=h*f(x0,y0)=0.2*f(0,3)=0.2*(1-0-3)=-0.4
k2=h*f(x0+h/2,y0+k1/2)=0.2*f(0.1,3-0.4)=-0.3800000000
k3=h*f(x0+h/2,y0+k2/2)=0.2*f(0.1,3-0.38)=-0.3820000000
k4=h*f(x0+h,y0+k3)=0.2*f(0.2,3-0.382)=-0.3636000000
y1=y0+(1/6)*(k1+2*k2+2*k3+k4)=2.618733333
0.2
2.618733333
MAPLE RK4: [0, 3], [.2, 2.618733333]

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 y'=1-x-y by the integrating
factor method to obtain y=2-x+exp(-x).
# MAPLE evaluation of y=2-x+exp(-x), the exact solution.
F:=x->2-x+exp(-x);[0.0,F(0.0)],[0.2,F(0.2)],[0.4,F(0.4)];
# 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, 10 Dec 2012)
The comparison graphic was created with thisMAPLE TEXT: y'=1-x-y by Euler-Heun-RK4 (1.1 K, txt, 10 Dec 2012)    ```
```Third lecture on numerical methods. RK4 details.
Theory for RK4
How Simpson's Rule provides RK4, using Predictors and Correctors.
Why we don't read the proof of RK4.
Numerical project example y'=-2xy, y(0)=2.
Handwritten example for y'=1-x-y, y(0)=3
References for numerical methods:Slides: Numerical methods (149.7 K, pdf, 26 Jan 2014)Manuscript: Numerical methods y'=F(x) and y'=f(x,y) (659.1 K, pdf, 29 Nov 2014)Manuscript: Numerical methods RECT, TRAP, SIMP for y'=F(x) (305.2 K, pdf, 23 Jan 2014)Manuscript: Numerical methods to compute Pi, ln2 and e (205.9 K, pdf, 26 Jan 2014)Manuscript: Jules Verne problem, skydiving, lunar lander (278.2 K, pdf, 01 Jan 2015)Slides: Jules Verne problem and escape velocity (124.2 K, pdf, 01 Jan 2015)Matlab: Numerical DE in matlab m-file from Professor W. Nesse (3.1 K, m, 28 Jan 2014)Maple: Ejected baggage nonlinear drag example, numerical DE from Professor Gustafson (0.8 K, mpl, 28 Jan 2014)How to use maple at home (7.3 K, txt, 05 Dec 2012)Jpeg: Handwritten example y'=1-x-y, y(0)=3, for Euler and Heun methods (427.8 K, jpg, 16 Dec 2012)```

### Monday-Wednesday: Linear Algebraic Equations. No matrices.

```Linear Algebraic Equations sections 3.1, 3.2
Frame sequence defined.
Theater 35mm movies project at 30 frames per second.A 35mm filmstrip (7.0 K, jpg, 11 Dec 2012)
Streaming video provider NetFlix uses frames to make a filmstrip,
each frame an image thumbnail of a DVD cover.A NetFlix Wii filmstrip (19.5 K, jpg, 11 Dec 2012)
Solutions to linear algebra problems can use a similar filmstrip
scheme, with the NetFlix DVD cover replaced by an image of a
completed solution step, called a frame.A filmstrip of 3 solution steps, called a frame sequence (68.3 K, pdf, 12 Dec 2012)
A frame sequence records the steps needed to solve a system of
equations. The steps are determined by a basic set of operations on
equations (the Toolkit).
Toolkit: combination, swap, multiply
Briefly: combo, swap, mult
Plane and space geometry: the meaning of simultaneous equations
The three possibilities
Unique solution
No solution
Infinitely many solutions
Method of elimination
Example: unique solution x=-1, y=1
x + 2y =  1
x -  y = -2
Example: no solution
x + 2y = 1
x + 2y = 2
Example: infinitely many solutions, parametric form of a line x=1-2t, y=t
x + 2y = 1
0 = 0
References:Slides: Intro Linear Equations, Toolkit, 3 Possibilities, Matrices (237.3 K, pdf, 14 Dec 2012)Slides: Unique solution case (110.1 K, pdf, 13 Dec 2012)Slides: No solution case (79.7 K, pdf, 03 Mar 2012)Slides: Infinitely many solutions case (131.1 K, pdf, 03 Mar 2012)Manuscript: Linear algebraic equations, no matrices (429.7 K, pdf, 30 Jan 2014)
Parameters in the general solution
Calculus: Parametric equation of a line or a plane.
Differential equations example, problem 3.1-26
y'' -121y = 0, y(0)=44, y'(0)=22
General solution given: y=A exp(11 x) + B exp(-11 x)
Substitute y into y(0)=44, y'(0)=22 to obtain a 2x2
system for unknowns A,B that has the unique solution
A=23, B=21.
Prepare 3.1 problems for next collection.
See problem notes section 3.1:html: Problem notes S2015 (2.8 K, html, 01 Jan 2015)
More ReferencesTransparencies:  Ch3 Page 149+, Exercises 3.1 to 3.6 (869.6 K, pdf, 25 Sep 2003)Transparency: 3x3 Frame sequence and general solution (315.9 K, jpg, 12 Dec 2012)```

### Mon-Wed: Three Possibilities. No matrices.

```Lecture: 3.1, 3.2, 3.3
Topics
Frame sequence
Toolkit: combo, swap, multiply [EP 3.2]
Plane and space geometry
The three possibilities [EP 3.1]
Unique solution
No solution
Infinitely many solutions
Definitions
Free variable
Signal equation
Echelon form [EP 3.2]
The last frame test [EP 3.3]
The last frame algorithm [EP 3.2]
A detailed account of the three possibilities
Unique solution == zero free variables
No solution == signal equation
Infinitely many solutions == one+ free variables
How to solve a linear system
Toolkit: swap, combo, mult
Toolkit operations neither create nor destroy solutions!
Frame sequence examples
Computer algebra systems and error-free frame sequences.
How to use maple to make a frame sequence without errors.Help: Utah Maple Tutorial (2.1 K, html, 30 Jan 2016)
Solved Problems
Example 4 in 3.2
A:=Matrix([
[1,-2,3,2, 1],
[0, 0,1,0, 2],
[0, 0,0,1,-4]]);
b:=<10,-3,7>;
linalg[linsolve](A,b);
x1 - 2x2 + 3x3 + 2x4 +  x5 = 10,
x3       + 2x5 = -3,
x4 - 4x5 =  7
==> A is upper triangular; system is upper triangular
==> Solve by 3.2 Algorithm Back Substitution.
Back-substitution.
Warning:
The naming convention in the textbook [EP 3.2] differs from a
substantial number of references.Remarks on back-substitution (1.4 K, txt, 13 Dec 2012)
Back-Substitution, be it the textbook algorithm or another, should
be presented as combo operations in frames. Please avoid isolated,
incomplete algebraic gibberish.A gibberish example (1.2 K, txt, 12 Dec 2012)
DEFINITION
The leading variable in a equation is the first variable,
in variable list order, with a nonzero coefficient.
DEFINITION
A frame is echelon provided
(1) Each nonzero equation has a leading variable different from
all other equations.
(2) All variables preceding a leading variable, in variable list
order, are absent from all following equations.
DEFINITION
In an Echelon System the pivots are the coefficients of
the leading variables, in turn called pivot variables.
MATLAB EXPERTS Back-Substitution Example
Assume U is an nxm echelon (upper triangular) matrix with nonzero
diagonal entries U(i,i). Can you decode the following back
substitution algorithm for Ux=b, written in Matlab syntax?
n = length(b);
x = zeros(n,1);
for i=n:-1:1
x(i) = (b(i)-U(i,:)*x)/U(i,i);
end
NON-EXPERTS. The answer is expressed in terms of dot-products,
a COMBO operation.
Problem 3.2-24
The book's answer is wrong, it should involve k-4.
See references on 3 possibilities with symbol k.Beamer slides: 3 possibilities with symbol k (60.0 K, pdf, 31 Jan 2010)Slides: 3 possibilities with symbol k (98.8 K, pdf, 03 Mar 2012)Manuscript: Examples 11, 12 in Linear algebraic equations no matrices (429.7 K, pdf, 30 Jan 2014)Answer checks should use the online FAQ.html: Problem notes S2015 (2.8 K, html, 01 Jan 2015)?>

the solution, as in lecture examples. Expected is a sequence of
augmented matrices. Maple may be used to make the frames. A maple last
frame answer check is linalg[rref](A). Browse the Linear Algebra help
in the on-line tutorial:Help: Utah Maple Tutorial (2.1 K, html, 30 Jan 2016)
References for this lecture.Slides: Intro Linear Equations, Toolkit, 3 Possibilities, Matrices (237.3 K, pdf, 14 Dec 2012)Slides: Unique solution case (110.1 K, pdf, 13 Dec 2012)Slides: No solution case (79.7 K, pdf, 03 Mar 2012)Slides: Infinitely many solutions case (131.1 K, pdf, 03 Mar 2012)Manuscript: Linear algebraic equations, no matrices (429.7 K, pdf, 30 Jan 2014)```

### Wed-Fri: Augmented Matrix for System Ax=b. RREF. Last Frame Algorithm. Sections 3.3, 3.4.

```Topics
The textbook definitions and theoremsEdwards-Penney 3.1, 3.2, 3.3 (3.0 K, txt, 18 Dec 2013)Edwards-Penney 3.4, 3.5, 3.6 (4.0 K, txt, 18 Dec 2013)
Project: Switch from equations to matrices, which is the interface
for a computer algebra system [Maple, Mathematica, MuPad, Maxima] or a
numerical workbench [Matlab, Scilab, Octave].

Translation of equation models [EP 3.4]
Equality of vectors
Scalar equations to augmented matrix
Augmented matrix to scalar equations
Matrix toolkit: Combo, swap and multiply
Frame sequences for matrix models.
Last frame test for a matrix. The RREF of a matrix.
Last frame algorithm for a matrix.
Scalar form of the solution.
Vector form of the solution.
THEOREMS in 3.3
Theorem 1. RREF is unique
Theorem 2. Three possibilities
Theorem 3. More variables than equations ==> infinitely many
Theorem 4. Ax=0 has unique solution x=0 <==> rref(A)=I
Vector add and scalar multiply: componentwise
Matrix multiplication on paper.
Stopped here on Friday==>
Digital photographs.
Maxwell's RGB separation.
Photoshop operations and matrix algebra.
How to use maple to make frame sequences. No solution example 3.1-16.PDF: Maple frame sequence, no solution example (42.2 K, pdf, 07 Feb 2012)Maple Text: Maple code, frame sequence with no solution (0.6 K, mpl, 05 Feb 2016)Maple Text: Frame Sequence in maple, Exercise 3.2-14 (3.0 K, txt, 10 Feb 2012)
Answer checks should use the online FAQ.html: Problem notes S2015 (2.8 K, html, 01 Jan 2015)
References:Manuscript: Linear algebraic equations, no matrices (429.7 K, pdf, 30 Jan 2014)Slides: Intro Linear Equations, Toolkit, 3 Possibilities, Matrices (237.3 K, pdf, 14 Dec 2012)Manuscript: Matrix Equations (292.1 K, pdf, 07 Feb 2012)Slides: Matrix add, scalar multiply and matrix multiply (156.7 K, pdf, 03 Mar 2012)Slides: Digital photos, Maxwell's RGB separations, visualization of matrix add (170.2 K, pdf, 03 Mar 2012)Slides: More on digital photos, checkerboard analogy (141.9 K, pdf, 03 Mar 2012)```

### Thursday: Ziwen Zhu

```Lab 4, Numerical methods.
Sample Exam: Exam 1 key from S2013. See also S2012, exam 1.Exams and exam keys for the last 5 years (22.2 K, html, 23 Feb 2015)```

### Friday: Frame Sequence to RREF. Last Frame Algorithm. Sections 3.2, 3.3, 3.4.

```Topics
The textbook definitions and theoremsEdwards-Penney 3.1, 3.2, 3.3 (3.0 K, txt, 18 Dec 2013)Edwards-Penney 3.4, 3.5, 3.6 (4.0 K, txt, 18 Dec 2013)
The three possibilities
The Toolkit: combo, swap, mult
Frame sequence
Last frame test for equations. Reduced echelon system.
coefficient one.
2. Zero equations are last
3. Lead variables are maintained in variable list order
Last frame test for matrices. Row reduced echelon form (RREF).
1. Each nonzero row has a leading one.
2. Zero rows are last
3. Leading ones are in columns of the identity matrix, called pivot
columns. These columns match the order of initial columns of the
identity matrix, but final columns may be missing.
Last frame algorithm
1. Apply the last frame test.
Proceed only if the system passes the test.
If in matrix form, then convert to a scalar system.
to the free variables.
4. Back-substitute the free variables into step 2.
5. Present the general solution as a list of variable
names in variable list order, with only invented
symbols on the right.
Example 1. The unique solution case
C:=Matrix([[1,2,1,1],[1,3,1,2],[1,1,2,3]]);
x + 2y + z = 1
x + 3y + z = 2
x + y + 2z = 3
Scalar form of the unique solution.
Why only lead variables in the last frame?
Why no free variables?
Example 2. The no solution case
C:=Matrix([[1,2,1,1],[1,3,1,2],[2,5,2,4]]);
x + 2y +  z = 1
x + 3y +  z = 2
2x + 5y + 2z = 4
We will find a signal equation
Example 3. The infinitely many solution case
C:=Matrix([[1,2,1,1],[1,3,1,2],[2,5,2,3]]);
x + 2y +  z = 1
x + 3y +  z = 2
2x + 5y + 2z = 3
Find the last frame
How many free variables? Count is called the RANK.
Apply the last frame algorithm
Example 4. The infinitely many solution case
C:=Matrix([[1,2,1,1],[3,6,3,3],[0,0,0,0]]);
x + 2y +  z = 1
3x + 6y + 3z = 3
0 = 0
Find the last frame
How many free variables?
Apply the last frame algorithm
Example 5. The infinitely many solution case
C:=Matrix([[0,0,0,0],[0,0,0,0],[0,0,0,0]]);
0 = 0
0 = 0
0 = 0
Find the last frame
How many free variables?
Apply the last frame algorithm

The three possibilities with symbol k.
x + ky = 2,
(2-k)x +  y = 3.
Examples with symbols.Slides: Three possibilities, theorems on infinitely many solutions, equations with symbols (129.0 K, pdf, 03 Mar 2012)Slides: 3 possibilities with symbol k (98.8 K, pdf, 03 Mar 2012)Beamer slides: 3 possibilities with symbol k (60.0 K, pdf, 31 Jan 2010)
See also Examples 11, 12 in The next reference.Manuscript: Linear algebraic equations, no matrices (429.7 K, pdf, 30 Jan 2014)Slides: Intro Linear Equations, Toolkit, 3 Possibilities, Matrices (237.3 K, pdf, 14 Dec 2012)Slides: Unique solution case (110.1 K, pdf, 13 Dec 2012)Slides: No solution case (79.7 K, pdf, 03 Mar 2012)Slides: Infinitely many solutions case (131.1 K, pdf, 03 Mar 2012)Manuscript: Matrix Equations (292.1 K, pdf, 07 Feb 2012)Slides: Matrix add, scalar multiply and matrix multiply (156.7 K, pdf, 03 Mar 2012)Slides: Digital photos, Maxwell's RGB separations, visualization of matrix add (170.2 K, pdf, 03 Mar 2012)Slides: More on digital photos, checkerboard analogy (141.9 K, pdf, 03 Mar 2012)Slides: Inverse matrix, frame sequence method (97.0 K, pdf, 11 Feb 2015) ```

### More References Linear Algebra, Chapters 3, 4

`Chapters 3 and 4Slides: Last frame algorithm, Elimination, Rank, Nullity (156.3 K, pdf, 20 Dec 2012)Slides: Elementary matrix theorems (154.2 K, pdf, 11 Feb 2015)Slides: Three possibilities, theorems on infinitely many solutions, equations with symbols (129.0 K, pdf, 03 Mar 2012)html: Problem notes S2015 (2.8 K, html, 01 Jan 2015)Transparencies:  Ch3 Page 149+, Exercises 3.1 to 3.6 (869.6 K, pdf, 25 Sep 2003)Transparency: 3x3 Frame sequence and general solution (315.9 K, jpg, 12 Dec 2012)Maple: Extra Credit Lab 5, Linear algebra (160.8 K, pdf, 29 Nov 2014)Manuscript: Vectors and Matrices (426.4 K, pdf, 07 Feb 2012)Slides: vector models and vector spaces (144.1 K, pdf, 03 Mar 2012)Slides: Base atom, atom, basis for linear DE (117.6 K, pdf, 03 Mar 2012)Slides: Orthogonality (124.8 K, pdf, 04 Dec 2014)Slides: Partial fraction theory (148.6 K, pdf, 14 Dec 2014)Slides: The pivot theorem and applications (189.2 K, pdf, 03 Mar 2012)Text: Lawrence Page's pagerank algorithm (0.7 K, txt, 06 Oct 2008)Text: History of telecom companies (1.9 K, txt, 03 Apr 2013)html: Problem notes S2015 (2.8 K, html, 01 Jan 2015)`