Homework 3

L. Vandenberghe
EE133A Fall 2014
Homework 3
Due: Wednesday 10/29/2014.
Reading assignment: Sections 3.1, 3.2, and 3.3 in chapter 3.
1. Polynomial interpolation. In this problem we construct polynomials
p(t) = x1 + x2 t + · · · + xn−1 tn−2 + xn tn−1
of degree 5, 10, and 15 (i.e., for n = 6, 11, 16), that interpolate points on the graph
of the function f (t) = 1/(1 + 25t2 ) in the interval [−1, 1]. For each value of n, we
compute the interpolating polynomial as follows. We first generate n pairs (ti , yi ),
using the MATLAB commands
t = linspace(-1, 1, n)’;
y = 1 ./ (1 + 25*t.^2);
This produces two vectors: a vector t with n elements ti , equally spaced in the interval
[−1, 1], and a vector y with elements yi = f (ti ). (See ‘help rdivide’ and ‘help power’
for the meaning of the operations ./ and .^.) We then solve a set of linear equations









1
1
..
.
t1
t2
..
.
1 tn−1
1 tn
· · · t1n−2 t1n−1
· · · t2n−2 t2n−1
..
..
.
.
n−2
n−1
· · · tn−1 tn−1
· · · tnn−2 tnn−1

















xn−1 









x1
x2
..
.
xn
=
y1
y2
..
.







yn−1 

(1)
yn
to find the coefficients xi .
Calculate the three polynomials (for n = 6, n = 11, n = 16). Plot the three polynomials
and the function f on the interval [−1, 1], and attach a printout of the plots to your
solutions. What do you conclude about the effect of increasing the degree of the
interpolating polynomial?
MATLAB hints.
• Use x = A \ b to solve a set of n linear equations in n variables Ax = b.
• To construct the coefficient matrix in (1), you can write a double for-loop, or use
the built-in MATLAB function vander, which constructs a matrix of the form
 n−1
t1
 n−1
 t2
 .
 .
 .
tnn−1
t1n−2 · · · t21 t1
t2n−2 · · · t22 t2
..
.. ..
.
. .
tnn−2 · · · t2n tn
1
1
..
.



.


1
Type ‘help vander’ for details. This is almost what we need, but you have to
‘flip’ this matrix from left to right. This operation is also built in in MATLAB
(type help fliplr).
• We are interested in the behavior of the interpolating polynomials between the
points ti that you used in the construction. Therefore, when you plot the three
polynomials, you should use a much denser grid of points (e.g., a few hundred
points equally spaced in interval [−1, 1]) than the n points that you used to
generate the polynomials.
2. Formulate the following problem as a set of linear equations. Compute two cubic
polynomials
p(t) = c0 + c1 t + c2 t2 + c3 t3 ,
q(t) = d0 + d1 t + d2 t2 + d3 t3
that satisfy the following conditions:
(a) p(t1 ) = y1 , p(t2 ) = y2 , p(t3 ) = y3
(b) q(t5 ) = y5 , q(t6 ) = y6 , q(t7 ) = y7
(c) p(t4 ) = q(t4 ), p0 (t4 ) = q 0 (t4 ).
The variables in the problem are the 8 coefficients ci , di . The numbers ti , yi are given,
with t1 < t2 < t3 < t4 < t5 < t6 < t7 .
Condition (a) specifies the value of p(t) at t = t1 , t2 , t3 . Condition (b) specifies the
value of q(t) at t = t5 , t6 , t7 . Condition (c) specifies that at t = t4 the polynomials p
and q should have the same value and the same derivative.
Test the method in MATLAB on the following problem. We take the 7 points ti equally
spaced in the interval [−0.75, 0.25] (using t = linspace(-0.75, 0.25, 7)’, and
y1 = 0,
y2 = −0.1,
y3 = 0.5,
y5 = 1,
y6 = 0.8,
y7 = 0.5.
Calculate the two polynomials p(t) and q(t), and plot them on the interval [−0.75, 0.25].
Attach a printout of the plots to your solutions.
3. Do the following matrices have linearly independent columns? To prove that A has
linearly independent columns, show that Ax = 0 only holds when x = 0. To show that
the columns are linearly dependent, show there exists a nonzero x with Ax = 0.


−1
2


(a) A =  3 −6 
2 −1
"
(b) A =
"
−1
3
2
2 −6 −1
#
(this is the transpose of the matrix in part (a))
#
D
(c) A =
, where B is m × n and D is a diagonal n × n-matrix with nonzero
B
diagonal elements.
(d) A = abT where a and b are n-vectors and n > 1.
(e) A = I − abT where a and b are n-vectors with kakkbk < 1.
4. Let a = (a1 , a2 , a3 ), b = (b1 , b2 , b3 ), c = (c1 , c2 , c3 ), d = (d1 , d2 , d3 ) be four given points
in R3 . The points do not lie in one plane. Algebraically, this can be expressed by
saying that the vectors b − a, c − a, d − a are linearly independent, i.e., the equality
y1 (b − a) + y2 (c − a) + y3 (d − a) = 0
holds only if y1 = y2 = y3 = 0.
Suppose we are given the distances of a point x = (x1 , x2 , x3 ) to the four points:
kx − ak = ra ,
kx − bk = rb ,
kx − ck = rc ,
kx − dk = rd .
Write a set of linear equations Ax = f , with A nonsingular, from which the coordinates
x1 , x2 , x3 can be computed. Explain why the matrix A is nonsingular.
5. Suppose A is a nonsingular n × n matrix, u and v are n-vectors, and v T A−1 u 6= −1.
Show that A + uv T is nonsingular with inverse
(A + uv T )−1 = A−1 −
1
1+
v T A−1 u
A−1 uv T A−1 .