Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mathlab code TASKS 1. Create a new cell and type in the following commands to generate the matrix A and the column-vector b: %% Matlab

Mathlab code image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
TASKS 1. Create a new cell and type in the following commands to generate the matrix A and the column-vector b: %% Matlab backslash 80lver clear: A-magic (5) b- [10: 26: 42: 59: 38] 2. If nothing is known about the structure of the matrix of the system, the best approach to solution is to use the Matlab backslash solver In most cases, this method will produce the numerical solution of the system Ax-b with the highest accuracy and in the shortest computational time 3. Whenever we are talking about the accuracy of the solution, ideally we want to find the difference between the approximate numerical solution rnu" and the exact solution ., of the system. However. this is not feasible in most situations since the exact solution zez 1s generally not known (otherwise, there is no point in using numerical methods at all). The next best thing is to find the residual r-Ax-b. If the residual is small then we can assume with certain limitations that our approximate solution is close enough to the exact solution (this is not always true, howr). Let us check how accurate is the solution which we found on the previous step. Type in the following line in your Matlab script The resulting vector r should be very close to zero. The Matlab backslash operator is based on LU-or PLU decomposition of the matrix A. The main idea here is that any square non-singular matrix A (meaning that the inverse matrix A exists) can be written as A = PLU (actually, in Matlab it is PTLU), where P is a pormutation matrix (or matrix obtained by matrix (all the elements above the main diagonal are equal to zero), and U is the upper riangular matrix (all the elements below the main diagonal are equal zero). Matlab has a special lu function to generate a pr LU decomposition of the matrix A. Type in the following lines in your Matlab script: g the rows of the identity matrix of the same size as A): L is a lower-triangular LU-factorization This will create a new code cell and compute the matrices P, L, and U. Now let us use these matrices to solve the linear system Ax b: err1=x-x1 Observe that the difference between the solutions errjsz-xl is exactly the aero-vector. This is due to the fact that we found the solution using exactly the same steps as Matab. Observe also that at no point did we use the Matlab inverse matrix function inv. In general, there is almost never a good

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

43 Executive compensation methods. SPHR ONLY

Answered: 1 week ago