DOC PREVIEW
CR MATH 45 - Numerical Linear Algebra

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

NumericalLinearAlgebraMath 45 — Linear AlgebraDavid [email protected] this activity you will learn how to solve systems of linear equations using LU de-composition, with both forward and back substitution. In addition, you will also beintroduced to function files and a number of Matlab’s control structures. Prerequi-sites: Some knowledge of how to enter vectors and matrices in Matlab. Familiaritywith Gaussian elimination, elementary matrices, and LU decomposition.next pagecloseexitTable of ContentsIntroductionWorking with MatlabNumerical Linear AlgebraFunctions in MatlabBack SubstitutionForward SubstitutionLU DecompositionSummaryExercisesNumericalLinearAlgebratitle pagecontentsprevious pagenext pagebackprint doccloseexitIntroductionThis is an interactive document designed for online viewing. We’ve constructed this onscreen documentbecause we want to make a conscientious effort to cut down on the amount of paper wasted at the College.Consequently, printing of the onscreen document has been purposefully disabled. However, if you areextremely uncomfortable viewing documents onscreen, we have provided a print version. If you click onthe Print Doc button, you will be transferred to the print version of the document, which you can printfrom your browser or the Acrobat Reader. We respectfully request that you only use this feature whenyou are at home. Help us to cut down on paper use at the College.Much effort has been put into the design of the onscreen version so that you can comfortably navigatethrough the document. Most of the navigation tools are evident, but one particular feature warrants a bitof explanation. The section and subsection headings in the onscreen and print documents are interactive.If you click on any section or subsection header in the onscreen document, you will be transferred to anidentical location in the print version of the document. If you are in the print version, you can makea return journey to the onscreen document by clicking on any section or subsection header in the printdocument.Finally, the table of contents is also interactive. Clicking on an entry in the table of contents takes youdirectly to that section or subsection in the document.Working with MatlabThis document is a working document. It is expected that you are sitting in front of a computer terminalwhere the Matlab software is installed. You are not supposed to read this document as if it were a shortstory. Rather, each time your are presented with a Matlab command, it is expected that you will enterthe command, then hit the Enter key to execute the command and view the result. Furthermore, it isexpected that you will ponder the result. Make sure that you completely understand why you got theresult you did before you continue with the reading.Numerical Linear AlgebraNumerical linear algebra devotes its existence to the study of numerical computations using matrices.Here is a quote from the preface of Numerical Linear Algebra and Its Applications by Biswa Nath Dattaof Northern Illinois University.NumericalLinearAlgebratitle pagecontentsprevious pagenext pagebackprint doccloseexit“Numerical linear algebra, no longer a subtopic of numerical analysis, has grown into an independenttopic for research and teaching. Because it is crucial to scientific computing (a major component ofmodern applied and engineering research), numerical linear algebra is becoming integral to coursesin mathematics, computer science, and engineering.”In this activity we present a small taste of a fascinating subject. We begin with a presentation of functions.Functions in MatlabScript files are simply a convenient way to gather a list of Matlab commands you wish to execute insequence. For example, open Matlab’s editor and enter the following code.1format rat %rational formatA=[1,2,-3,4;...2,0,-1,4;...3,1,0,6;...-4,4,8,0]b=[1;1;1;-1]M=[A,b]R=rref(M)x=R(:,5)format %back to default formatSave the file as example.m. Now, at the Matlab prompt, enter>> exampleand each line in example.m will be executed in the order presented in the script file.Function M-files are similar to script files. You still enter code to be executed in sequence. However,function files afford the user the opportunity to enter input, and functions can also return output to thecalling function (in many cases Matlab’s command window).Suppose, for example, that you would like to code the function defined by f(x) = x2. Open the Matlabeditor and enter these two lines of code.The ellipses are Matlab’s line continuation character. Everything in a line following a % character is a comment. It is1ignored by the compiler.NumericalLinearAlgebratitle pagecontentsprevious pagenext pagebackprint doccloseexitfunction y=f(x)y=x^2;Save the file as f.m. Now, test your function at the Matlab prompt with the following command.>> t=8;>> z=f(t)z =64Note that when calling the function, you need not match the independent variable t with that in thefunction definition, namely x. Nor do the names of the dependent variables have to match. We could havejust as easily executed these commands.>> skunk=8skunk =8>> lots_of_skunks=f(skunk)lots_of_skunks =64Similarly, you are free to change the function name.function y=square(x)y=x^2;However, Matlab requires that you save the file with the same name. Thus, this file must be saved assquare.m. This function will behave in precisely the same way as our previous definition. Only the nameshave changed.>> skunk=8skunk =8>> lots_of_skunks=square(skunk)lots_of_skunks =64NumericalLinearAlgebratitle pagecontentsprevious pagenext pagebackprint doccloseexitFunctions can have more than one input and they can have more than one output. For example, considerthe function defined by g(x, y) = x2+ y2. Code this function as follows.function z=g(x,y)z=x^2+y^2;Save the file as g.m and execute the following at the command line.>> u=3; v=4;>> z=g(u,v)z =25We will soon encounter functions with more than one output.Back SubstitutionConsider the system of linear equations2x1+ x2− 2x3= 4−2x2+ x3= −34x3= 8.(1)In matrix form, this system is represented as follows.2 1 −20 −2 10 0 4x1x2x3=4−38Thus, we have writtensystem 1 in the formUx = c,whereU =2 1 −20 −2 10 0 4, x =x1x2x3, and c =4−38.NumericalLinearAlgebratitle pagecontentsprevious pagenext pagebackprint doccloseexitNote that matrix U is square (3 × 3) as the system has an


View Full Document

CR MATH 45 - Numerical Linear Algebra

Documents in this Course
Load more
Download Numerical Linear Algebra
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 Numerical Linear Algebra 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 Numerical Linear Algebra 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?