You are on page 1of 3

Homework Set No.

1. Simplest problem using least squares method

Use the method of least squares, find the constant function that best fits the data
x -1 2 3
y 5/4 4/3 5/12

2. The method of least squares with polynomial regression

(a) What straight line best fits the following data in the least-squares sense?
x 1 2 3 4
y 0 1 1 2
(b) Find the equation of a parabola of form y = ax2 + b that best represent the data in
least squares
x -1 0 1
y 3.1 0.9 2.9

3. The method of least squares with linear non-polynomial

(a) We are given a data set (xk , yk ), k = 0 . . . m. For these data we shall fit in the
function
g(x) = α sin x + β cos x.
Set up the normal equations that will solve the problem with the method of least squares.
Now, given the data set

x 1.0 1.5 2.0 2.5


y 1.902 0.5447 −0.9453 −2.204

find α and β in g(x).


(b) Let f (x) be a given function. What constant c makes the expression
m
X
[f (xk ) − cexk ]2
k=0

as small as possible?

4. Application: A pessimistic population model

A model for the population on earth is given by


dB
= KF B 2
dT

1
where
B = world population
T = the time
KF = the fertility constant.
The solution of the equation is givenby
1 1
B(T ) = ·
KF T0 − T
Throughout the years we have got the following observation data:
T 1650 1700 1750 1800 1850 1900 1920 1940 1960
10−6 · B 545 623 728 906 1171 1608 1834 2295 3003
where T is the year and 10−6 · B equals to numbers of millions of people.

a). Let y = 1012 /B, and x = T − 1830, and rewrite the equation into the form
y(x) = a0 + a1 x.
b). Use the method of least squares to decide a0 and a1 .
c). Then, find KF and T0 . Now you can write out the function B(T ) that describes
the population B as a function of time T .
d). What is your T0 ? What does it tell you?
e). Use the model to predict the population for T = 1980, T = 2000 and T = 2010.
Are you happy with the result? Comparing to the actual population in 2011,
which is about 7.1 billions, what would you say about this model?

5. Quasi-linear method of least squares

For the table


xk 0.0 0.2 0.4 0.6 0.8 1.0
yk 1.996 1.244 0.810 0.541 0.375 0.259
we are looking for a least square approximation of the form
ea1 x
y(x) = a0 · ,
(1 + x)a2
where a0 , a1 and a2 are three unknown coefficients.

a). Decide the normal equations for your approximation.


The students are expected to reformulate the problem in such a way, that they
would get a linear system at the end.
b). Use Matlab to compute the solution of the normal equations. Make a plot which
shows the data points and the least square approximation ȳ(x). Compute the
quadratic sum X
(yk − y(xk ))2
k

2
6. The method of least squares in Matlab

Given data set


xk 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
yk 0.7829 0.8052 0.5753 0.5201 0.3783 0.2923 0.1695 0.0842 0.0415 0.009 0

Use Matlab function polyfit to find respectively the first, second, fourth and eighth
order polynomials that best fit the data, in the method of least squares. You would
rather plot your polynomials.

What to hand in: The script file, the plots, and your comments.

7. Least squares to approximate functions

Let f (x) be a function defined on the interval [−1, 1], as



−1, −1 ≤ x ≤ 0
f (x) =
1, 0≤x≤1

If we want to approximate f (x) by

f (x) ≈ a cos(πx) + b sin(πx),

find the constants a and b by the method of least squares.

You might also like