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

Homework problems for chapter 6

6.1 Basic systems of Linear Equations.

(a). consider the system of equations

,( 1  + 42  + a①3 = 6

2① 1 - ①2 + 2a①3  = 3

(a① 1 + 32  + 3 = 5

show the following:

. when a = O, it has a unique solution;

. when a = -1, there is no solution;

. when a = 1, it has ininitely many solutions.

Also, investigate the corresponding situation when the right-hand side is replaced by O,s.

(b). For what values of β does naive Gaussian elimination produce erroneous answers for this system?

6.2 Gaussian elimination

(a). consider the following 3 3 system.

3.333O 1     +    1592O 2     -   1O.333 3     =     7973.6

2.222O ① 1      +    16.71O ①2       +    9.612O ①3      =    O.965OO

-1.5611 ① 1      +   5.1792 ①2      -   1.6855 ①3     =     2.714O

verify that the solution is ① 1  = 1)①2  = O.5)①3 = -1.

solve the following the system with naive Gaussian elimination, by using a calculator (not Matlab). All calculations should use 5 signiicant digits.  show details of your work. what do you get?

Now, solve the system in Matlab, by the command x=A\b.  what do you get? Are the answers diferent? Any explanations and comments?

(b). consider the 2 2 system of linear equations

1.13① + 1.54g    =   4.21

1.14① + 1.57g    =   4.28


.  verify that ① = 1)g = 2 is the solution.

.  solve it by naive Gaussian elimination, using 3 signiicant digits.  No credit will be given if using any other methods.  Don,t panic if you get some strange result.

.  could you explain your result in the previous part?

Hint: You may use the fact that the two eigenvalues for the matrix are given as

A =  [  1(1).(.)14(13)   1(1).(.)57(54) ] λ 1 (A) = O.OO687) λ2 (A) = 2.69.

6.3    Gaussian Elimination in Matlab

In this problem we test the performance of the the naive Gaussian elimination procedure and compare it with the linear system solver implemented in Matlab (which uses scaled partial pivoting). As a test problem, we solve the system

Ax = b

where A is the  ⅤandeTmonde-matrix:

'c(c) c(c)-(-)1(1)     . . .(. . .)    c1(c0)     1(1))'

A = '                                    '

'   .(.)       .(.)               .(.)     .(.)  '

(c cn(n)1     . . .   cn(.)   1(.))

where c =  [c0c1. . . )cn]  is  a  given  vector.   since  the  main  point  of this  problem is to compare the two algorithms, we choose a vector b which gives a known solution x. b = A . ones(n).

solve the above system with two diferent algorithms:

.  The naive Gaussian elimination without pivoting, using the function naiv-gau网网(A,b), which you can download from canvas;

.  Gaussian elimination with pivoting in Matlab, i.e., using the command   x = A\b;

You should test it for the following 3 cases:

i) c = [O.2)O.4)O.6)O.8)1]T

ii) c = [O.1)O.2)O.3). . . O.9)1]T

iii) c = [O.O5)O.1O)O.15). . . O.9O)O.95)1]T

compare the two solutions.  what do you observe? what do you think is happening? comment on your results.

Hint! construct your A and b in Matlab in the following way:

c =  [0.2:0.2:1];

A  =  vander(c);        X  make  van  der  Monde-matrix .

x网ol  =  one网(c,);       X  make  the  column  vector  x网ol=[1,1,1,1,1], . b  =  A*x网ol;                   X  make  the  load  vector  b

what to hand in: your script ile, your results for all 3 cases, and your comments.

6.4    solving Lower Triangular systems in Matlab.

Given a system of linear equations L从 = b where L is lower triangular, i.e.  L = {lij} where lij   = 0 for all indices i < j. write a Matlab function that solves this system, taking advantage of the lower triangular structure of L. your function should start as

function  网=MYLT网olver(L,b)

X  网=function  MYLT网olver(L,b)

X  input网: L  --  a  lower triangular matrix

X                b  -- the  load vector

X  output:  网  -- olution for L网=b

Test your code with a randomly generated system, whose solution is [1; 1; . . . ; 1]t. you may use the following script:

n=10;  X  the ize  of the Y网tem

A=rand(n);  X  a  random  nxn matrix,  with  entrie网  in  (0,1),  which  i网  a  full  matrix L=tril(A)+eYe(n); X take the  lower  triangular part  of  A  and put  in  L,

Xand  to make  网ure  that  the  diagonal  element网  are  bigger  than  1 . b=网um(L,2);    X  we  then  have  b=Lx  where  x=[1;1;   . . .  1]

xe=one网(n,1);  X  the  exact  网olution

x=MYLT网olver(L,b);

errorx=max(ab网(x-xe)) X  check  the  error  in  the  computation  of x

errorR=max(ab网(b-L*x)) X  check  the  re网idual  error

what  to  hand  in: your  ile  for the function“MYLT网olver”, your script ile, your results, and any comments you would like to share.

F1                          F2                        F3                           F4

Figure 1: construction

6.5    Application of system of Linear Equations.

Figure 1 shows a mechanical structure which consists of 17 rigid sticks:

The  sticks  form  3  squares,  and  all  the  triangles  in  the  structure  are  isosceles  right triangles. Therefore all the angles in the graph are 45 or 9O.  Each point of junction is labelled with a circled number, and there are 1O such junctions. Note that the junction point no. 1 isixed on the ground, while the junction point no. 1O is supported on wheels on a horizontal ground, so that it can move freely in the horizontal direction.

The forces F1, F2 , F3 , F4  are applied to the points no. 3, 5, 7, 9, respectively.

we assume that the structure is in equilibrium.  This means, at each junction, the total force is zero, i.e., the total force components in ①- and g-directions are both zero.

we wish to compute the force on each stick, for diferent values of the source loads F1, F2 , F3 , F4 .

To simplify notation, we also write a = sin(45) = cos(45) =^2/2, since this appears in many equations.

we denote by fi  the force in the stick number i.  At each junction, the two equations, representing the equilibrium of forces in the ① and g direction, are listed below.

a = sin(45) = cos(45) =^2/2

Junction point 2:      {- a(a)f(f)1(1)

+ f4 + af5 = O

+ f3 + af5 = O

Junction point 3:      {- f(f)3(2)

+ f6 = O

+ F1 = O

Junction point 4:       {f7(-)fO(+) f8  = O

Junction point 5:

Junction point 6:

Junction point 7:

Junction point 8:

Junction point 9:

Junction point 1O:      {-af16  - f17 = O

Be careful now!  There are mistakes in some of these equations, left there on purpose to spice up the problem. Therefore, every student, with his or her mechanical talent, is challenged to double check each equation, and correct them in case of mistakes.

once you are sure that you have a correct system, you need to ind the forces in each stick when the whole construction is put under the following source forces:

a)  F1  = 1O, F2  = 15, F3  = O, F4 = 1O.

b)  F1  = 15, F2  = O, F3  = O, F4  = 1O.

c)  F1  = 1O, F2  = O, F3 = 2O, F4 = O.

d)  F1  = O, F2 = 1O, F3 = 1O, F4  = O.

You will end up in solving a system of linear equations, with can be written in matrix- vector form as A从 = b. Here the matrix A is sparse, i.e., most of its elements are O.  You are therefore encouraged to use the sparse matrix structure in Matlab.  check this out by ,help  sparse, and ,help  full,.

For example,“sparse(m,n)” generates a sparse matrix or vector of size m n,  and “full(v)”makes a full matrix or vector out of a sparse one.

Eventhough our system is relatively small, and there is no urgent need to use the sparse matrix, nevertheless it is an important feature to learn.

what to hand on: your script ile, your results for a,b,c,d, and any comment that you would like to make.

6.6    x system of Linear Equations

consider the system of equations (n = 9)

l d1

'

'

'

'

'

'

'

'

'

'

'

'

[ a1

d2

d3

d4

d5

a4

a3

a2


a8 a7

a6

d6

d7

d8


a9

'

'

'

'

'

'

'

'

'

'

'

'

d9  l

①(①)2(1) b2(b1)

' 3 ' ' b3 '

' 4 '          ' b4 '

' 5 ' = ' b5 '

' 6 ' ' b6 '

' 7 ' ' b7 '

①(①)9 l(8 ') b(b)9(8)  l(')

The general system can be written for n odd.

write a Matlab function, as simple as possible, that solves this system, for general n, using naive Gaussian Elimination.  The algorithm must utilize the X structure of the coe伍cient matrix.

The function should start with:

function x=Gaussianxn,d,a,b)

X function x=Gaussianxn,d,a,b)

X  input:  n=system  si处e,  must  be  an  odd  number,  (d,a,b):  vectors  of  length  n X  output: x=solution

(Hint: write out the pseudocode for the forward elimination. what system do you get now? Then write the pseudocode for the backward substitution.  Then code in Matlab.)

Test your code with the case where all entries in d is 4 and all entries in a is 1.  construct the b vector such that the exact solution has all entries 1.  Test your code with various choices of n.  (For example, n = 7, 9, 11.)

what to hand in: your explanation which leads to the pseudo code, your Matlab function, script ile, and result.