Unformatted text preview:

Math 0280 Introduction to Matrices and Linear AlgebraExploration Assignment #1(Linear Systems)Acknowledgment The MATLAB assignments for Math 0280 were developed by JonathanRubin with the help of Matthew BadgerSCHEDULE: The first exploration assignment is due within two weeks. One submission pergroup (no more than three people) is sufficient. Every member of the group assumes fullresponsibility for the final product and should be prepared to answer any questions relatedto the work submitted.GOAL: In these exploration assignments, our goal is to introduce you to various applicationsof linear algebra to real world problems. We will make use of the software package MATLAB,a useful tool for numerical computation using matrices and graphical interpretation of data.The first assignment begins with a gentle introduction to MATLAB. You will learn howto enter and carry out basic computations with matrices. In particular, linear systems ofequations can be solved quickly and accurately using the rref command, which performsGauss-Jordan elimination on a matrix. We also examine two applications:(1) Given n points (x1, y1), . . . , (xn, yn) on the Euclidean plane, we can find a polynomialp(x) = a0+a1x+· · ·+an−1xn−1going through the points: p(xi) = yi, for all 1 ≤ i ≤ n.(2) Using linear systems to calculate unknown flows through the junctions of a network.(For example, think of the speed of water through pipes or vehicle traffic on roads.)SAVING YOUR WORK IN THE GSCC COMPUTER LAB: When you save your MAT-LAB files in a computer in the GSCC lab, make sure you save it in a folder called “AFS.”Otherwise, you will lose everything when you log off of the computer. You can access thisfolder by double-clicking the link on the Desktop of any GSCC computer. If you want to ac-cess this folder using any other computer, you can open a web browser and in the address bartype: ftp://username:[email protected]. Here username and userpasswwordare the same as your pitt username and password.INTRODUCTION TO MATLAB: “MATrix LABratory”, or more simply called MATLAB,is an interactive software system for doing calculations with matrices. For those interested,several thorough introductions to MATLAB are available online. Here we will focus on justenough to get you through the first assignment.I. The Command WindowOnce you open MATLAB, several windows will open. Our primary focus is on the windowcalled the “Command Window”. This is place where you enter commands and receive output.II. Inputing Matrices and Solving Linear Systems12First, suppose that we want to enter the following augmented matrix,A =1 2 3 45 6 7 89 10 11 12.Then, at the command window prompt, type the following:PROMPT>> A=[1, 2, 3, 4; 5, 6, 7, 8; 9, 10, 11, 12] <enter>MATLAB has assigned the variable A to the matrix and prints the following output to thecommand window:A =1 2 3 45 6 7 89 10 11 12To summarize, a matrix can be entered into MATLAB, by writing the matrix entries rowwise:put the entries between square brackets “[ . . . ]”, put commas “,” between the entries, andput semicolons “;” between the rows.Second, suppose we want to change the bottom left entry in the matrix A from 9 to −9.Do we have to retype the entire matrix into MATLAB? The answer is no. Instead, just typethe following into the command window prompt:PROMPT>> A(3,1) = -9 <enter>Then, MATLAB records the change:A =1 2 3 45 6 7 8-9 10 11 12More generally, to change the ij entry of a matrix M , type M(i,j)= . . .Third, suppose we want to solve the linear system represented by A,x + 2y + 3z = 45x + 6y + 7z = 8−9x + 10y + 11z = 12MATLAB implements Gauss-Jordan elimination, which reduces a matrix to its reduced rowechelon form. The following command assigns the RREF of A to the matrix B:PROMPT>> B=rref(A) <enter>This outputs:B =1 0 0 00 1 0 -10 0 1 2Fourth, suppose we want to extract the solution vector b from B. In the command window,the following command assigns the fourth column of B to b:PROMPT>> b=B(:,4) <enter>MATLAB responds:3b =0-12More generally, to extract the ith row or jth column of a matrix M , type M(i,:) or M(:,j),respectively.III. Evaluating Polynomials and Plotting GraphsSuppose that we want to plot the polynomial P (x) = −x2+ 3 on the interval [−1, 1].Apply the following procedure. First, we need to represent P (x) as a vector p:PROMPT>> p=[-1;0;3] <enter>More generally, to create a vector for the degree n polynomial P (x) = anxn+ · · · + a1x + a0,type p=[an;· · · ; a1; a0].Second, specify the domain u of the desired plot, as follows:PROMPT>> u=-1:0.2:1 <enter>The command above (-1:0.2:1) creates a vector u with entries between −1 (the left number)and 1 (the right number). The middle number 0.2, which is called the mesh or step size,specifies the detail of the plot. A smaller step size (or “finer mesh”) produces a more accurateplot than a larger step size.Third, use the following command to evaluate P (x) on the domain specified by u:PROMPT>> v=polyval(p,u) <enter>Lastly, plot the graph by specifying the domain u and the range v:PROMPT>> plot(u,v) <enter>After entering the command, MATLAB will open a new window with its plot of −x2+ 3.You will notice that the graph of −x2+ 3 is not smooth; rather, it is a linear approximationusing line segments, spaced 0.2 apart on the x-axis. Try repeating the procedure above,except replace “0.2” in step 3 with “0.1”. The new plot is a finer approximation of −x2+ 3.IV. Using M–Files to Save Your WorkRather than type commands into the prompt one by one, MATLAB provides a mechanismfor collecting your commands in one place. Let’s use the previous section as an example.From the MATLAB menubar click File -> New -> M-File. A new window “Editor –Untitled” will open. Retype the commands from the last section:% Any Line That Begins With A Percent Sign Is A Comment% These Commands Plot -x2+3 From -1 to +1p=[-1;0;3]u=-1:0.2:1v=polyval(p,u)plot(u,v)Save the M-file as “test1.m” and close the editor. At the command prompt, you can nowtype a single command to plot the graph of −x2+ 3:PROMPT>> test1 <enter>Completed assignments are to be submitted on paper, clearly indicating the names of allstudents in the group. A computer printout is preferred, but fully or partially handwrittensubmissions will be accepted.4ASSIGNMENT: (OUT OF 40 POINTS) Complete all three parts:I. Exercise on Linear Systems (14 POINTS)(a) Convert the following linear


View Full Document

Pitt MATH 0280 - Exploration Assignment

Documents in this Course
Load more
Download Exploration Assignment
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Exploration Assignment and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Exploration Assignment 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?