Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Es 204 PS

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

ES 204 Numerical Methods in Engineering

De Vera, Kester Ray L.

2006-12518

I hereby declare that I have created this work completely on my own, used no unauthorized
assistance has been received or given in the completion of this work, and I have marked any citations
accordingly.

Kester Ray L. De Vera


April 20, 2020

Written Exercise

1. Solve the following linear systems, if possible, by Gaussian elimination, and determine
whether row interchanges are necessary

x1 −x2 +3 x 3=2 2 x 1−1.5 x 2+ 3 x 3=1


a.
{
3 x 1−3 x 2 + x 3=−1
x 1+ x 2=3
c.
{ −x 1+ 2 x 3=3
4 x1 −4.5 x 2+5 x 3=1

2 x 1=3 x1 + x 2 + x 4=2
b.
{ x 1 +1.5 x 2=4.5
−3 x 2+ 0.5 x 3 =−6.6
2 x 1−2 x2 + x 3 + x 4=0.8
{
d . 2 x 1+ x2−x 3 + x 4 =1
−x 1+ 2 x 2 +3 x3 −x 4=4
3 x 1−x 2−x 3+ 2 x 4 =−3

ANSWERS:

x 1−x 2 +3 x 3=2

{
a . 3 x 1−3 x 2+ x3 =−1
x1 + x 2=3

Converting the system of equations to an augmented matrix:

1 −1 3 2

[ 3 −3 1 −1
1 1 0 3 |]
Row operation: R2=3R1-R2
R3=R1-R3

1 −1 3 2

[ 0 0 8 7
0 −2 3 −1 |]
Page 1 of 14
ES 204 Numerical Methods in Engineering

Row operation: R2 ↔ R 3

1 −1 3 2

[ 0 −2 3 −1
0 0 8 7 |]
Upper triangular matrix

Converting back to system of equation:

x 1−x 2+ 3 x 3=2 ( 1 )

{−2 x 2 +3 x 3=−1 ( 2 )
8 x 3 =7 (3 )

From (3):
8 x 3=7
7
x 3= =0.875
8

Substituting to (2) the obtained value of x3:


−2 x2 +3 x 3=−1
−2 x2 +3 ( 0.875 ) =−1

3 ( 0.875 )+ 1
x 2=
2

x 2=1.8125

Substituting to (1) the obtained values of x3 and x2:


x 1−x 2+ 3 x 3=2

x 1−1.81425+3 ( .0875 )=2

x 1=1.81425−3 ( .0875 ) +2

x 1=1.1875

Check with the original equations:

1.1875−1.8125+3 ( 0.875 )=2


3 ( 1.1875 )−3 ( 1.8125 ) +0.875=−1
1.1875+ 1.8125=3

Page 2 of 14
ES 204 Numerical Methods in Engineering

2 x 1=3
b.
{ x 1 +1.5 x 2=4.5
−3 x 2+ 0.5 x 3 =−6.6
2 x 1−2 x2 + x 3 + x 4=0.8

Row operations not required. System of equations can be solved by substitution.


2 x 1=3 ( 1 )

{ x 1+1.5 x 2=4.5 ( 2 )
−3 x2 +0.5 x 3=−6.6 ( 3 )
2 x 1−2 x 2+ x 3 + x 4 =0.8 ( 4 )

From (1):
2 x1 =3
3
x 1= =1.5
2

Substituting to (2) the obtained value of x1:


x 1+ 1.5 x 2=4.5

1.5+1.5 x 2=4.5

4.5−1.5
x 2=
1.5

3
x 2= =2
1.5

Substituting to (3) the obtained value and x 2:

−3 x 2+ 0.5 x 3=−6.6

−3 ( 2 ) +0.5 x 3=−6.6

−6.6+6
x 3=
0.5

−0.6
x 3= =−1.2
0.5

Substituting to (4) the obtained values of x2, x3 and x4:

2 x1 −2 x 2 + x 3+ x 4 =0.8

2 ( 1.5 )−2 ( 2 )−1.2+ x 4 =0.8

Page 3 of 14
ES 204 Numerical Methods in Engineering

x 4 =3

2 x 1−1.5 x 2+ 3 x 3=1
c.
{ −x 1+ 2 x 3=3
4 x1 −4.5 x 2+5 x 3=1

Converting the system of equations to an augmented matrix:

2 −1.5 3 1

[ −1 0 23
4 −4.5 5 1 |]
Row operation: R2=R1+2R2
R3=R1-0.5R3

2 −1.5 3 1

[ 0 −1.5 7 7
0 7.5 0.5 0.5 |]
Row operation: R3=R2-0.2R3
2 −1.5 3 1

[ 0 −1.5 7 7
0 0 7.1 7.1 |]
Converting back to system of equation:

2 x 1−1.5 x 2+ 3 x 3=1 ( 1 )

{
− 1.5 x2 +7 x 3=7 ( 2 )
7.1 x 3=7.1 (3 )

From (3):
7.1 x3 =7.1
x 3=1

Substituting to (2) the obtained value of x3:


−1.5 x 2+7 x 3=7
−1.5 x 2+7 ( 1 ) =7

x 2=0

Substituting to (1) the obtained values of x3 and x2:


2 x1 −1.5 x 2 +3 x3 =1

Page 4 of 14
ES 204 Numerical Methods in Engineering

2 x1 −1.5 ( 0 )+ 3 (1 ) =1

2 x1 +3=1

x 1=−1

Check with the original equations:

2 (−1 )−1.5 ( 0 ) +3 ( 1 )=2


−(−1 ) +2 ( 1 )=3
4 (−1 )−4.5 ( 0 )+ 5 ( 1 ) =1

x1 + x 2 + x 4=2

{
d . 2 x 1+ x2−x 3 + x 4 =1
−x 1+ 2 x 2 +3 x3 −x 4=4
3 x 1−x 2−x 3+ 2 x 4 =−3

Converting the system of equations to an augmented matrix:

1 1 0 1 2

[ 2
−1 2
1 −1 1 1
3 −1 4
3 −1 −1 2 −3
|]
Row operation: R2=2R1-R2
R3=R1+R3
R4=3R1-R3

1 1 0 1 2

[ 0
0
0
1 1
3 3
4 −1
|]
1
0
1
3
6
9

Row operation: R3=3R2-R3


R4=4R2-R4

1 1 0 12

[ |]0
0
0
1
0
0
1
6
5
13
33
33

Page 5 of 14
ES 204 Numerical Methods in Engineering

Row operation: R4=R3-(6/5) R4

1 1 0 1 2

[ 0
0
0
1
0
0
1
6
1
3
3
3 | ]
0 −3 /5 −3 / 5

Converting back to system of equation:

x 1 + x2 + x 4 =2 (1 )

{

x 2+ x3 + x 4 =3 ( 2 )
6 x 3 +3 x 4=3 ( 3 )
3
()
5 4
x =− ()3
5
(4 )

From (4):
−( 35 ) x =−( 35 )
4

x 4 =1

Substituting to (3) the obtained value of x4:


6 x 3+ 3 x 4=3

6 x 3+ 3 (1 )=3

x 3=0

Substituting to (2) the obtained values of x3 and x4:


x 2+ x3 + x 4 =3

x 2+ 0+1=3

x 2=2

Substituting to (1) the obtained values of x2, x3 and x4:


x 1+ x2 + x 4 =2

x 1+ 2+ 1=2

x 1=−1

Check with the original equations:

Page 6 of 14
ES 204 Numerical Methods in Engineering

−1+2+1=2
2 (−1 ) +2−0+1=1
−(−1 ) +2 ( 2 )+ 3 ( 0 )−1=4
3 (−1 )−2−0+2 ( 1 )=−3

2. For all the systems above, calculate the condition number of the coefficient matrix for this
system, and show whether the system is ill-conditioned or not.

Matrix Inverse Matrix Condition Number

1 −1 3 −1/16 3 /16 1/2 |3|+|-3|+|1|·|1/16|+|3/16|+|1/2|

[ 3 −3 1
1 1 0 ] [ 1/16 −3 /16 1/2
3/8 −1/8 0 ] =7·0.75

=5.25
|1|+|3|+|1| ·|0.5|+|0.5|+|0|
=5·1

=5
√ 12+−12+3 2+ 32+−32 +12+12 +12 +02 ·
√ 0.6252 +−0.6252 +0.3752 +0 .18752 +−0.12 +−0.1
=4 √ 2 ·0.85695

=4.8476
2 0 0 0 0.5 0 0 0 |1.5|+|-3|+|-2|+|0|·|0|+|0.6666|+|4|+|-2.666|

[ 1 1.5 0 0
0 −3 0.5 0
2 −2 1 1
] [ −0.333 0.6666 0
−2 4 2
0.333 −2.666 −2
0
0
1
] =6.5·7.3326

=47.6619
|2|+|-2|+|1|+|1|·|-2|+|4|+|2|+|0|
=6·8

=48
√ 22+ 12+22 +1.52 +−3 2+−22+ 0.52+12 +12 ·
√ 0.52 +−0.3332 +−22 +0 .3332 +0.66662 + 42 +−2.6
=5.1478·6.0847

=31.322

2 −1.5 3 0.75 −0.5 −0.25 |3|+|2|+|5|·|1.0833|+|0.75|+|0.375|

[ −1 0 2
4 −4.5 5 ] [ 1.0833 −0.166 −0.583
0.375 0.25 −0.125 ] =10·2.2083

=22.083
|4|+|-4.5|+|5| ·|1.0833|+|-.166|+|-0.583|
=13.5·1.8323

=24.7361
√ 22+−12+ 4 2+−1.52+−4.52 +32 +22 +52 +02 ·
√ 0.752 +1.08332 +0.3752±0 .52 +−0.166 2+ 0.252+−
=9.0277·1.623

Page 7 of 14
ES 204 Numerical Methods in Engineering

=14.65
1 1 0 1 −1 0.666 0.333 0.333 |1|+|2|+|-1|+|3|·|-1|+|0.333|+|0|+|1.666|

[ 2
−1 2
1 −1 1
3 −1
3 −1 −1 2
][ 0.333 0.333
0
1.666
0
−0.333 0.333
−1 −0.333
−0.333
]
=7·2.999

0.333 =20.993
0 |3|+|-1|+|-1|+|2|·|-1|+|-0.333|+|0|+|1.666|
=7·2.999

=20.993
√ 10(1¿¿ 2)+3 (22)+2(3 2) ¿ ·
√ 9(0.333¿ ¿2)+12 +−12+ 0.6662 +1.6662 ¿
=6.3245·2.4934

=15.7696

Page 8 of 14
ES 204 Numerical Methods in Engineering

3. Suppose that A, B ϵ Mn(R) are strictly diagonally dominant. Which of the following must be
strictly diagonally dominant?
(a) -A
(b) AT
(c) A + B
(d) A2
(e) A-B

ANSWER:

-A will still be strictly diagonally dominant since the absolute value of the of the elements are
being considered.

a b c

[ ]
Say A= d e f
g h i
−a
, where |a|> |b|+|c| and |e|> |d|+|f| and |i|> |g|+|h| which is an SDD.

−b −c

[
Taking -A= −d
−g ]
−e −f , it will still hold true that |a|> |b|+|c| and |e|> |d|+|f| and |i|> |g|+|h|, which
−h −i
satisfies the requirements for an SDD matrix

To show that the other cases may yield a non-strictly diagonally matrix, specific examples are as
follows.

For AT:

8 2 3 8 5 4
Say A = 5
[ ] [ ]
10 2 , which is an SDD. AT= 2 10 4 , is not an SDD because of the first row
4 4 12 3 2 12

For A+B and A-B, adding the additive inverse (or subtracting) by the value of the (even just one)
elements in the main diagonal will yield a zero main diagonal, which is also a non-SDD case

8 2 3 −8 2 3

[
Say A = 5 10 2 ∧B= 5 −10
4 4 12 4 ] [ ]
2 , which are both SDD matrices.
4 −12

0 4 6

[ ]
The resulting A+B= 10 0 4 is not an SDD
8 8 0

8 2 3
A2 which is equal to AxA, may also yield a non-SDD matrix. Say A= 5
[ ]
10 2 , an SDD.
4 4 12

Page 9 of 14
ES 204 Numerical Methods in Engineering

86 48 64
AxA= 98
[ ]
118 59 is not an SDD matrix.
100 96 164

The examples, while do not provide a generalized proof that the given cases does not yield an SDD
with the given conditions above.

4. Is A= [−12 −1 ¿
⋱ ¿ ]
¿ ⋱ ¿ ⋱ ¿−1 ¿−1 ¿ 2 ¿ ϵ Mn(R) a positive definite matrix?

ANSWER:

Yes, A is a positive definite matrix. First A is a symmetric matrix. Using the definition, x TAx >0 for the
n n
2
matrix A to be positive. x Ax can be further defined as the ∑ aii x + ∑ aij x i x j, which should also
T
i
i=1 i>j
be greater than zero.

Say x=[ p q r s]

From the definition


xTAx = [2p2 -2pq + 2q2 ]+[2r2-2sr +2s2]-2qr>0

Using the determinant check:


det|2|=2>0

det[−12 −12 ] =4-1=3>0

2 −1 0

[
det −1 2 −1 =3>0
0 −1 2 ]
det[−12 −1 ¿
⋱ ¿
¿ ⋱ ¿ ⋱ ¿−1 ¿−1 ¿ 2 ¿ =5>0]
Therefore, matrix A is positive definite

x 1 0

[ ]
5. Suppose A = y 2 1 , Find all values of x and y for which
0 1 2

(a) A is strictly diagonally dominant.


(b) A is positive definite.

ANSWER:

Page 10 of 14
ES 204 Numerical Methods in Engineering

(a) By definition, a nxn matrix is said to be strictly diagonally dominant (SDD) if |a ij|≥
n

∑ ¿ aij∨¿ ¿. For matrix A to be an SDD, |x|>|1|+|0| or X>1 or X<-1 AND |2|>|y|+|1| or -1<y<1
i=1
i≠ j

(b) To become a positive definite matrix, A should be symmetric, that is A=A T. A is symmetric if

x 1 0 x y 0

[ ][ ]
y 2 1 = 1 2 1 . This is true when x is any real positive number and y =1.
0 1 2 0 1 2

x1 x 1 0
Furthermore for A to become positive definite, x 2

Using the determinant test:


x3 [ ][ ] 1 2 1 [ x 1 x 2 x 3 ] >0.
0 1 2

| x | >0 and

det [ 1x 12]
> 0, 2x-1> 0 or x> ½ and

x 1 0
det 1
[ ] 2 1 > 0, 3x=2>0 or x>-2/3
0 1 2

Simplifying. x>1/2 for matrix A to be positive definite

6. Find the first two iterations of the SOR method with ω = 1.1 for the following linear
system

4 x 1 + x 2−x 3=5

{−x 1+3 x 2 + x3 =−4


2 x 1 +2 x 2 +5 x 3=1

ANSWER:

4 x 1 + x 2−x 3=5

{−x 1+3 x 2 + x3 =−4


2 x 1 +2 x 2 +5 x 3=1
The given matrix is strictly diagonally dominant, so we can expect convergence regardless of any
initial guess

i−1 n
(k)
x =(1−ω)x
i
(k−1)
i +
ω
aii[bi−∑ aij x (kj )− ∑ aij x (k−1
j=1 j =1 +1
j
)
]
i −1 n
(1)
x =(1−1.1)x +
1
1.1
4
(0)
5−∑ aij x (1)
1
j=1
[ (0)
j − ∑ aij x j
j=1+1
]
Page 11 of 14
ES 204 Numerical Methods in Engineering

i−1
x(1) (0)
1 =(1−1 .1) x 1 +
1.1
4 [
5−∑ a ij x(1)
j=1
j −0 ]
x =0= [ 0 0 0 ] T; ω=1.1
(0)

1. 1
x 1=(1−1.1)(0)+

{
(5−0−0)=1.375
4
1.1
x 2=(1−1.1)(0)+ (−4 +1.375−0)=0.9625
−3
1.1
x3 =(1−1.1)(0)+ (1−2(1.375)−2(0.9625))=−0.8085
5

x(1)=0= [ 1.375 0 0.9625 −0.8085 ] T; ω=1.1


1.1
x 1=(1−1.1)(1.375)+

{
(5−0.9625−0.8085)=0.75045
4
1.1
x 2=(1−1.1)(0 .9625)+ (−4+ 0.75045−−0.8085)=0.79880
−3
1.1
x3 =(1−1.1)(−0.8085)+ (1−2(0.75045)−2(0.79880))=−0.38082
5

7. Find the first two iterations of the Jacobi method for the following linear system

4 x 1 + x 2−x 3+ x 4=−2

{
x1 + 4 x 2−x 3−x 4=−1
−x 1−x 2 +5 x 3 + x 4 =0
x 1−x 2 + x 3+3 x 4 =1

ANSWER:

x =0= [ 0 0 0 0 ] T
(0)

1
x 1= (0+0−0−2)=−0.5

{
4
1
x2 = (0+0+ 0−1)=−0.25
4
1
x 3 = (0+ 0−0)=0
5
1
x 4 = ( 0+0−0+1)=1/3
3

x =0= [ −0.5 −0,25 0 1/3 ] T


(1)

Page 12 of 14
ES 204 Numerical Methods in Engineering

1 1
x 1= (0.25+0− −2)=−0. 52083

{
4 3
1 1
x2 = (0.5+0+ −1)=−7 /24=−0. 41667
4 3
1 1 −13
x3 = (−0.5±0.25− )= =−0.21667
5 3 60
1 5
x 4= (0.5±0.25−0+1)= =0.41667
3 12

Answer should be [ −0.5753 −0,9589 −0.17808 0.21917 ]T

Since the given matrix is not strictly diagonally dominant because of the fourth row, we may
expect the values not to converge to the solution because the given is not strictly diagonally
dominant matrix

8. What is the motivation behind the notion of numerical stability?

ANSWER:

Numerical stability is a criterion imposed to categorize the accuracy of a method/algorithm of


approximation. It ensures that any small changes in the domain (or input) will only cause a small
change in the range(output). While various methods/ algorithms are available to solve problems,
even with large number of variables, the concept ensures that the method itself will not allow
yielding of a result outside the set boundaries (e.g. allowable error)

Page 13 of 14
ES 204 Numerical Methods in Engineering

References

J. Douglas Faires, Richard L. Burden, Numerical Analysis 4e, 2004.


J. Kiusalaas. Numerical Methods in Engineering with Python 2, 2010.

Page 14 of 14

You might also like