function x = lsq_qr(epsilon)
% set A and b, initialize x
A = [1 1 1;epsilon 0 0;0 epsilon 0;0 0 epsilon];
b = [1;0;0;0];
x = zeros(3,1);
[m,n] = size(A);
% QR fatorization using function house()
[W, R] = house(A);
% compute Q\
Q = eye(4);
temp = zeros(4);
Lecture 19: Steepest Descent Method
Motivation: quasiNewtons methods, e.g., Broydens method, can achieve superlinear convergence
but depends on the initial guess. We will consider a method which is less sensitive for the initial guess.
Given F : Rn ! Rn
Lecture 18: QuasiNewton Methods  Broydens Method
Drawback of Newtons method is that n2 partial derivatives of F (x) are required to compute and
evaluate, which is inconvenient in practice. To approximate the Jacobian matrix, one option is to
apply the f
Lecture 23: Householders Method
1
Householder Transformations
Definition 1. Let w
~ 2 Rn with kwk
~ 2 = 1. The matrix
2w
~w
~T
P = In
is called a Householder matrix. The linear transformation ~x 7! P ~x is Householder transformation.
Remark: If ~0 6= w
~
Lecture 21: Eigenvalues, Orthogonal Matrices and Similarity Transformations
Definition 1. Let A 2 Rnn ,
is called eigenvalue of A if there exists 0 6= x 2 Rn such that
Ax = x.
Here x is called the eigenvector of A corresponding to the eigenvalue . Define
Lecture 25: Least Squares Approximation I
1
Data Fitting
Given a data set cfw_(xi , yi )m
i=1 , the data fitting problem is to find a polynomial of degree < m
Pn (x) = an xn + . . . + a1 x + a0 =
n
X
1
aj xj
j=0
such that the least squares error
E(a0 , a1
Lecture 14: Boundary Value Problem II
1
Nonlinear BVP  Shooting Method
To solve a nonlinear secondorder BVP, we consider a sequence of IVPs
y 00 = f (x, y, y 0 ),
8 x 2 [a, b],
y(a) = , y 0 (a) = tk
(1)
such that the solution y(x, tk ) to the above IVP
Lecture 22: Power Method
1
Power Method
Definition 1. Let
eigenvalue of A if
1,
2, . . . ,
n
be the eigenvalues of a matrix A 2 Rnn .

The eigenvectors corresponding to
1
1
>  i ,
1
is called the dominant
i = 2, . . . , n.
are called dominant eigenvec
Lecture 24: QR Algorithm
1
QR Factorization Based on GramSchmidt Process
Based on the GramSchmidt orthogonalization process, we can factorize
2
r11 r12
6
6 0 r22
A = a 1 a 2 a n = q1 q2 qn 6 .
.
4 .
.
rnn
0
where rij = qi aj = qiT aj . Here we set
v
Lecture 16: FiniteDierence Methods for Nonlinear BVP
1
FiniteDierence Method for nonlinear BVP
Given a nonlinear BVP
(
y 00 = f (x, y, y 0 ),
y(a) = ,
y(b) =
a x b,
we consider finitedierence method to solve it. To ensure the existence and uniqueness o
MATH 151B Applied Numerical Methods, Winter 2017, Homework 3
Due Friday, February 10, 11:00am
Question 1: (10 marks) Consider the following IVP:
d2 y
dy
= 0.
4y(t) = 6 exp(t), y(0) = 0,
dt2
dt t=0
(a) Obtain the coefficients a and b in the onestep impl
function [W, R] = house(A)
% setting up and initialize
[m,n] = size(A);
W = zeros(m,n);
% compute QR factoriztion using householder reflector
for k = 1 : n
x = A(k:m, k);
W(k:m,k) = sign(x(1) * norm(x) * eye(mk+1,1)  x;
W(k:m,k) = W(k:m,k) / norm( W(k:
function x = lsq_normaleq(epsilon)
% set A and b, initialize x
A = [1 1 1;epsilon 0 0;0 epsilon 0;0 0 epsilon];
b = [1;0;0;0];
x = zeros(3,1);
% compute Cholesky A'*A = L*L'
L = chol(A'*A,'lower');
% solve L*delta = A'*y using backward substitution
delta
Lecture 20: Homotopy and Continuation Methods
1
Homotopy
Assume that x(0) is an initial estimate of the solution of F (x ) = 0. Define G : [0, 1] Rn ! Rn by
G( , x) = F (x) + (1
)[F (x)
F (x(0)] = F (x) + (
If
= 0, then G(0, x) = F (x)
If
= 1, then G(1,