Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

DATA203 Assignment 2022.

1.  Consider the overdetermined system of equations

   0(2)   一(一)2(6)   14(8)        一(一)3(4)2(6) 

Ax =  .(.)      8    12      16   .(.)  =  .(.)      22   .(.)  = b.

     4      4        2            26   

(a) Using the GivensRollup code, reduce A to a row echelon matrix R using Givens rotations. Apply the same rotations to the right hand side vector b to get a new right hand side vector c.

(b) Find the least squares solution x  to Ax = b using the row echelon matrix R and new right hand side c you found in part (a) of this question. Do this bit by hand; the numbers should all be multiples of 10 and the solution x should be integer.

(c) Without doing any further calculation, what is the length of the residual vector b 一 Ax  ??

2. A person wishes to t a sinusoidal model of the form

y = x ù + M cos /   φ                                                (1)

to average monthly rainfall data (in mm) for Nuku’alofa, Tonga, where this data is as given in Table 1. Here the unknown x ù  is an average level, and the unknowns M and φ are the amplitude and phase offset of the sinusoid respectively. Also t is time in months, and y is rainfall.

Table 1:  Nonthl夕 bwerbge rbinfbll dbtb for auku│blofb!  Nonths bre numcered )  to )垒J  yith )  ceing 〉bnubr夕J 垒 ceing 尹ecrubr夕 et←! yi  giwes the bwerbge rbinfbll for eb←h month in millimetres!

month ti average rainfall yi

10

128

(a) Use a double angle formula to show that the model (1) can be written in the form

y = x ù + xsin /  + xà cos /                                     (2)

where x ù , x , and xà  are the new unknowns. Give x  and xà  in terms of M and φ .              (b) Why is the form  (2) useable for least squares fitting of the data,  whereas the original

model (1) was not?

(c)  Set up the overdetermined system Ax = b and find the least squares solution to it using matlab.  This least squares can be computed very efficiently in matlab via the instruction A\b. This solves the system Ax = b if it has a solution, otherwise it finds the least squares solution to this system.

(d)  Calculate the mean of the average rainfalls over the 12 months.

(e)  Calculate the matrix AT A in matlab.  What unusual structure does this matrix have, and what does it tell you about the columns of A?

(f) Using your answer to part (e) of this question, show that x ù  must equal the mean value of the 12 monthly average rainfalls. A

3.  Consider the following overdetermined system of four equations:

x ù  = x + 1      x  = 1 一 x ù         2xù  = 3 一 x         and      4x≠  = 6 + 2xù                         (3)

(a) Using the  LeastSquaresPlotSoln  code,  generate  at  least  800 randomly weighted  least squares solutions to the system of four equations  (3).  Your answer should contain A, b and the plot produced by LeastSquaresPlotSoln.

(b) Briefly comment on the locations of the unweighted and evenly weighted solutions, along with the distribution of the randomly weighted solutions.

(c) Briefly state why is it not possible for the point (3, 0) to be a solution for any non-zero set of weights applied to the system of four equations (3).

●  [newA,G]  =  GivensRollup(A,i,k) applies a Givens rotation to rows i-1 and i to make the (i,k) element of newA zero via newA  =  G  *  A. You will need to multiply the right hand side vector by G yourself.

● LeastSquaresPlotSoln(A,b,N) plots N randomly weighted least squares solutions of the overde- termined system Ax = b, along with the unweighted and evenly weighted least squares solutions. The former simply uses A and b as provided, without any explicit weighting.  The latter scales each row of A to make it a unit vector, with the same scale factors applied to the corresponding elements of b. Parts of each line defined by a row of Ax = b are also plotted in the vicinity of the randomly weighted solutions.