Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 6 pts . ) Write the system of equations as a matrix - vector system . Generate the solution to the system of equations

(6 pts.) Write the system of equations
as a matrix-vector system
. Generate the solution to the system of equations by computing the
factorization of the matrix
by hand and using this factorization to solve for
. Do not using pivoting to find your factorization. Validate the solution you obtain without solving the system again. That is, do not use MATLAB to solve the system, do not refactor, do not resolve the system using the factors, and do not find an inverse.
(8 pts.) For this problem, you will need to write two MATLAB functions. Write one function that takes as input a matrix
and a vector
and outputs the solution
to the linear system
using the MATLAB \ operator. This function is referred to as matlabSolve in the script given below.
For the second function, the input should allow for the
and
factors of
as well as a right-hand side vector
. The output should be the vector
that is the solution to
. This function is referred to as luSolve in the script below. You can use the MATLAB \ operator to solve each of the triangular systems associated with the
and
factors.
Write a script to solve a matrix system defined using a matrix of size
and a matrix of size
with random entries. Populate the right-hand side vector
with random entries as well. The MATLAB function rand can be used to generate both the matrix and the vector. Note the size of
will need to correspond to the size of
. Obtain an overall timing to assess the difference between the functions. You can obtain timings using the MATLAB tic and toc commands. When using the MATLAB \ command to solve the matrix system, the
factors are generated each time, at a cost of
operations. The upper and lower triangular solves are performed next, each with an operation count of
.
Your script file might look like the following.
% enter the size of the matrix
n =250;
% define the matrix A with random entries
A = rand(n,n);
% generate the right-hand side vector with random entries
b = rand(n,1);
% determine how many times to run the experiment
m =??;
% start timing for the first function call
tstartBackslash = tic;
% solve the system n times and record the results
for i =1:m
% solve the system
xSolns1= matlabSolve(A,b);
% generate the right-hand side vector b by multiplying
% the old right-hand side by different random numbers
b = rand(length(b),1).* b;
end
% end the timings
telapsedBackslash = toc(tstartBackslash)
% now repeat with the second function
% You now have to compute the LU factors of A
% before making the function call
% start the clock
tstartLU = tic;
% find the LU factors of A
[L,U]= lu(A)
% solve the system n times and record the results
for i =1:m
% solve the system
xSolns2= luSolve(L,U,b);
% generate the right-hand side vector b by multiplying
% the old right-hand side by different random numbers
b = rand(length(b),1).* b;
end
% end the timings
telapsedLU = toc(tstartLU)
Report your timings and your final results. Discuss why one method takes less time than the other. What happens to the timings as you increase the number of times you execute the loops?
(6 pts.) Problem 2.3 in the linear algebra notes Download linear algebra notes in the text Numerical Computing with MATLAB by Cleve Moler contains a system of linear equations associated with a truss system. The matrix for this system of equations can be generated using the script generateTrussMatrix Download generateTrussMatrix.
The value of
describes the angle between components of the truss system. In this exercise, you will change the value of
and see how it changes the condition number of the matrix. You will also determine how the change in condition number affects the computed solution.
In order to understand the effect on the solution, generate the right-hand side vector
so you know what the true solution is. Generate a vector of all ones that has the same number of rows as the matrix
. This can be done using
xtrue = ones(length(A),1);
Generate the vector
by multiplying
by this vector of all ones. Then, when you solve
, the solution should be a vector of all ones. This procedure has been added to the file which generates the truss matrix.
Start with
, compute the solution, and compare the computed solution to the known true solution (i.e., the vector of all ones). Find the condition number of
and note the number of correct significant digits in the computed solution. Reduce the value of
by a factor of
until you have
around
. Make a table with the value of
in one column, the condition number of
in a second column, and the number of correct digits in the computed solution in the third column. Do these data support the connection between loss of significant digits and the condition number discussed in

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_2

Step: 3

blur-text-image_3

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 And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions