Docsity

4 Problems with Solution of Numerical Computing - Assignment 3 | MATH 4800, Assignments of Mathematics

Toggle sidebar
bg1
Rensselaer Polytechnic Institute
Homework # 3
MATH 48000 Numerical Computing
Luigi Vanfretti
February 12, 2007
(1) Exercises 3.3 and 3.11.
(a) Exercise 3.3.: Set up the linear least squares system Ax ∼
=bfor fitting the model function
f(t, x)=x1t+x2etto the three data points (1,2), (2,3), (3,5).
Solution:
The system Ax ∼
=bfor the desired model function is given by:
⎡
⎢
⎣
t1et1
t2et2
t3et3
⎤
⎥
⎦x1
x2=⎡
⎢
⎣
y1
y2
y3
⎤
⎥
⎦
Substituting the values of the three data points yields:
⎡
⎢
⎣
1e1
2e2
3e3⎤
⎥
⎦x1
x2=⎡
⎢
⎣
2
3
5⎤
⎥
⎦
Next, the matrices ATAand ATbare obtained:
ATA=123
e1e2e3⎡
⎢
⎣
1e1
2e2
3e3⎤
⎥
⎦=1+4+9 e1+2e2+3e3
e1+2e2+3e3e2+e4+e6
ATA=14 77.753
77.753 465.416
ATb=123
e1e2e3⎡
⎢
⎣
2
3
5⎤
⎥
⎦=2+6+15
2e1+3e2+5e3=23
128.031
1
pf3
pf4
pf5
pf8

Partial preview of the text

Download 4 Problems with Solution of Numerical Computing - Assignment 3 | MATH 4800 and more Assignments Mathematics in PDF only on Docsity!

Rensselaer Polytechnic Institute

Homework # 3

MATH 48000 Numerical Computing

Luigi Vanfretti

February 12, 2007

(1) Exercises 3.3 and 3.11.

(a) Exercise 3.3.: Set up the linear least squares system Ax ∼= b for fitting the model function f (t, x) = x 1 t + x 2 et^ to the three data points (1,2), (2,3), (3,5). Solution: The system Ax ∼= b for the desired model function is given by: ⎡ ⎢⎣

t 1 et^1 t 2 et^2 t 3 et^3

⎤ ⎥⎦

[ x 1 x 2

]

⎡ ⎢⎣

y 1 y 2 y 3

⎤ ⎥⎦

Substituting the values of the three data points yields: ⎡ ⎢ ⎣

1 e^1 2 e^2 3 e^3

⎤ ⎥ ⎦

[ x 1 x 2

]

⎡ ⎢ ⎣

⎤ ⎥ ⎦

Next, the matrices ATA and ATb are obtained:

ATA =

[ 1 2 3 e^1 e^2 e^3

] ⎡ ⎢⎣

1 e^1 2 e^2 3 e^3

⎤ ⎥⎦ =

[ 1 + 4 + 9 e^1 + 2e^2 + 3e^3 e^1 + 2e^2 + 3e^3 e^2 + e^4 + e^6

]

ATA =

[ 14 77. 753

  1. 753 465. 416

]

ATb =

[ 1 2 3 e^1 e^2 e^3

] ⎡ ⎢⎣

⎤ ⎥⎦ =

[ 2 + 6 + 15 2 e^1 + 3e^2 + 5e^3

]

[ 23

  1. 031

]

From where the system ATAx = ATb can be formed: [ 14 77. 753

  1. 753 465. 416

] [ x 1 x 2

]

[ 23

  1. 031

] (1)

Solving (1) yields: x =

[

  1. 59149 0. 008762

]T

f (t, x) = 1. 59149 t + 0. 008762 et

(b) Exercise 3.11.: Suppose that the partitioned matrix Q =

[ A B 0 C

] is orthogonal, where the sub-matrices A and C are square. Prove that A and C must be orthogonal and B = 0 Solution: An orthogonal matrix is such that it satisfies

QTQ = I (2)

Applying the condition (2) to our problem yields:

QTQ =

[ AT^0 BT^ CT

] [ A B 0 C

]

[ ATA ATB BTA BTB + CTC

]

QTQ =

[ ATA ATB BTA^ BTB^ +^ CTC

]

[ I 0 0 I

] (3)

From equation (3) we observe that the conditions for Q to be an orthogonal matrix are:

ATB = 0 BTA = 0

} ⇒ A = 0 ⇒ B = 0 (4)

ATA = I CTC = I (5)

From (5) we observe that A and C must be such that

ATA = I CTC = I (6)

which is the condition for an orthogonal matrix. Hence, from (4) we have shown that B = 0 , and from (6) we have proved that A and C are orthogonal for an orthogonal matrix Q.

The column vector Qx is given by

Qx =

[ x 1 cosφ + x 2 sinφ −x 1 sinφ + x 2 cosφ

]

and its 2-norm is

||Qx|| 2 =

√ (x 1 cosφ + x 2 sinφ)^2 + (−x 1 sinφ + x 2 cosφ)^2

√ x^21 cos^2 φ + 2x 1 x 2 sinφcosφ + x^22 sin^2 φ + x^21 sin^2 φ − 2 x 1 x 2 sinφcosφ + x^22 cos^2 φ

√ (cos^2 φ + sin^2 φ) x^21 + (cos^2 φ + sin^2 φ) x^22

√ x^21 + x^22

Therefore ||Qx|| 2 = ||x||.

(b) Under what conditions is matrix Q positive definite? Solution: The condition that a matrix Q must satisfy in order to by positive definite is xTQx > 0 unless x = 0. For our Q matrix the product xTQx > 0 is:

xTQx =

[ x 1 x 2

] [ cosφ sinφ −sinφ cosφ

] [ x 1 x 2

]

[ x 1 x 2

] [ x 1 cosφ + x 2 sinφ −x 1 sinφ + x 2 cosφ

]

xTQx = x^21 cosφ + x 1 x 2 sinφ + x^22 cosφ − x 1 x 2 sinφ = x^21 cosφ + x^22 cosφ

xTQx =

( x^21 + x^22

) cosφ (7)

The terms x^21 and x^22 in (7) will always yield a positive value, so does their sum (with the exception of x = 0). Therefore, the only term that can be equal to zero is cosφ, then the conditions for Q to be positive definite is:

− π 2 < φ < π 2 and φ = 0

Generalizing for any positive integer n the conditions are: π 2 (4n^ −^ 1)^ < φ <^

π 2 (4n^ + 1)^ n^ = 0,^1 ,^2 ,^3 , ...^ and^ φ^ = 2πn^ n^ = 0,^1 ,^2 ,^3 , ...

(4) MATLAB problem. Solution:

(a) Preliminary work:

The problem statement asks for a least squares curve fit of the function

V T a^ = b (8)

where a and b are parameters to be determined. We need to rewrite the model in order to be able to apply the linear least squares method. The following steps are taken to rewrite the model V T a^ = b 1 V =^

1 b T^

a log

( 1 V

) = a log (T ) + log

( 1 b

)

Define the new variables:

u = log

( 1 V

) k = a l = log

( 1 b

) t = log (T )

The fitting function can be expressed by the following equation:

f (t, x) = u = kt + l

The A matrix, and column vectors x and b of Ax ∼= b are:

A =

⎡ ⎢⎢ ⎢⎢ ⎢⎣

t 1 1 t 2 1 t 3 1 t 4 1 t 5 1

⎤ ⎥⎥ ⎥⎥ ⎥⎦^ x^ =

[ k l

] b =

⎡ ⎢⎢ ⎢⎢ ⎢⎣

u 1 u 2 u 3 u 4 u 5

⎤ ⎥⎥ ⎥⎥ ⎥⎦

Once the solution vector x =

[ k l

] is found, the constants for the original model function

(8) can be determined by: a = k b =

el^

(b) MATLAB program listing:

0001 %% Problem (4) - HW # 5 - Math 4800 0002 % Luigi Vanfretti, Feb. 04, 2007 0003 clear all; clc; 0004 %% Original problem data 0005 V = [160 180 200 220 240]; 0006 T = [7.0 5.5 5.0 3.5 2.0];

0060 set(gcf,’color’,’white’) 0061 loglog(V,T,’bo’,v,tlife,’r-’,’LineWidth’,1.5,’MarkerFaceColor’,’b’,... 0062 ’MarkerSize’,9) 0063 axis([155 250 1.75 8]) 0064 xlabel(’log(V)’) 0065 ylabel(’log(T)’) 0066 title(’LogLog Plot - log(T) vs log(V)’) 0067 legend(’Data’,’LS Fit’,’Location’,’SouthWest’) 0068 %%% eof

(c) Plots and conditioning numbers:

(c.1.) Conditioning numbers The conditioning numbers computed by the MATLAB program are the following: cond(A^TA) cond(P)

54.285 35.

As expected, the conditioning number of ATA is larger than the conditioning number of P, this is one benefit of transforming the original system by embedding it in a larger augmented one, the scaling factor used to compute matrix P is α = 1. 9459.

However the conditioning number of P is susceptible to the choice of the scaling factor α. The condition numbers shown below where obtained using α = 0. 0019459 cond(A^TA) cond(P)

54.285 2058.

From here we can observe that the adequate scaling of the matrix P is important for the conditioning of the matrix, if α is not correctly selected, the benefits of augmenting the system will be lost.

(c.2.) Plots Figure 1 shows the data and least squares fit for the function

V T a^ = b

where the constants a and b obtained are:

a = 0. 31104 b = 309. 95

Figure 2 presents a LogLog plot of the data and the least squares fit, as expected the least squares fit is a straight line going through the data.

Figure 1: T vs V Data and LS fit - Linear Scale

150 200 250

2

3

4

5

6

7

V − cutting speed (m/min)

T − tool life (min)

T vs V − Linear Plot

Data LS Fit

Figure 2: T vs V Data and LS fit - LogLog Scale

10 2.2^10 2.

10 0.

10 0.

10 0.

10 0.

10 0.

10 0.

10 0.

log(V)

log(T)

LogLog Plot − log(T) vs log(V)

Data LS Fit