Docsity

CS1371 Assignment 6: Linear Algebra and Nested Iteration, Assignments of Computer Science

Toggle sidebar
bg1
CS1371: Assignment 6 - Version 1
You will need to know linear algebra operations and nested iteration to com-
plete this assignment. Woody Allen tells us, “Life is divided into the horrible
and the miserable.” The estimated time to completion for this assignment is
five hours. Budget your time accordingly.
Corrections and revisions to this assignment should be sent to Titus Barik
([email protected]). For general assistance, contact the Teaching Assis-
tant for your section.
1 Warmup
1.1 System of Equations
Write a script, sys.m, which solves the following system of equations:
6x1+ 3x2+ 1x3+ 2x4+ 4x5= 70 (1)
1x1+ 9x2+ 1x3+ 2x4+ 1x5= 56 (2)
1x1+ 1x2+ 1x3+ 6x5= 63 (3)
1x2+ 2x3+ 3x4+ 5x5= 69 (4)
4x1+ 3x2= 13 (5)
1.2 Singularity
Given a square 2 ×2 matrix, determine the number of singular matrices
containing only combinations of the values 1 and 0. A singular matrix is a
square matrix that does not have an inverse. Compute this result using a
MATLAB script and name your script sing.m.
2 Exercises
2.1 Multivariable Functions
Write a script, multigraph.m, which, when run, will simultaneously display
three windows with graphs representing the following equations from the
1
pf3
pf4

Partial preview of the text

Download CS1371 Assignment 6: Linear Algebra and Nested Iteration and more Assignments Computer Science in PDF only on Docsity!

CS1371: Assignment 6 - Version 1

You will need to know linear algebra operations and nested iteration to com- plete this assignment. Woody Allen tells us, “Life is divided into the horrible and the miserable.” The estimated time to completion for this assignment is five hours. Budget your time accordingly.

Corrections and revisions to this assignment should be sent to Titus Barik ([email protected]). For general assistance, contact the Teaching Assis- tant for your section.

1 Warmup

1.1 System of Equations

Write a script, sys.m, which solves the following system of equations:

6 x 1 + 3x 2 + 1x 3 + 2x 4 + 4x 5 = 70 (1) 1 x 1 + 9x 2 + 1x 3 + 2x 4 + 1x 5 = 56 (2) 1 x 1 + 1x 2 + 1x 3 + 6x 5 = 63 (3) 1 x 2 + 2x 3 + 3x 4 + 5x 5 = 69 (4) 4 x 1 + 3x 2 = 13 (5)

1.2 Singularity

Given a square 2 × 2 matrix, determine the number of singular matrices containing only combinations of the values 1 and 0. A singular matrix is a square matrix that does not have an inverse. Compute this result using a MATLAB script and name your script sing.m.

2 Exercises

2.1 Multivariable Functions

Write a script, multigraph.m, which, when run, will simultaneously display three windows with graphs representing the following equations from the

−

0

5

−

0

50

10

20

30

40

50

(a) z = x^2 + y^2

−

0

5

−

0

−0.8 5

−0.

−0.

−0.

0

1

(^) (b) z = (cos x)(cos y)e √ x^2 +y^2 / 8

Figure 1: Example of mesh output.

range [-5:0.2:5] to [-5:0.2:5]:

z = x^2 + y^2 (6) z = (cos x)(cos y)e

x^2 +y^2 / (^8) (7)

z =

xy(x^2 − y^2 ) x^2 + y^2

You will need the functions mesh, meshgrid, and figure. Examples of mesh graphs are shown in Figure 1.

2.2 Gravity

Consider the following m × n matrix, A, consisting of the values V = { 0 , 1 , − 1 }, where 0 represents an open space, 1 represents a vertically falling object, and −1 represents a fixed block.

A =

    

    

2.4 MATLAB Extras

Re-implement the MATLAB function reshape(x, m, n), as specified in help reshape. That is, return the m × n matrix whose elements are taken column-wise from x. You may assume that the input is valid. Call your function myreshape(x, m, n).

3 Turn In

You will need to turn in the following files: sys.m, sing.m, multigraph.m, gravity.m, life.m, myreshape.m. Be sure to include test scripts that test the functionality of the above problems. Finally, properly document all func- tions. For this assignment, functions with syntax errors will receive no credit.