Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 6: Explore different ways to solve a linear system of equations by typin

ID: 3595870 • Letter: P

Question

Problem 6: Explore different ways to solve a linear system of equations by typing help inv and helpncommand window, and then perform the following exercises a) Create a 3 x 3 matrix A with the following values and set p6a=A. 1 5 6 A=18 3 4 7 2 9 b) Create a 3-element column vector b with values of 7, 2 and 5. Set p6b1. c) Using operator, solve the system of equations Ax=b for x. Set p6x. d) Using function inv, solve the system of equations Ax=b forx. Set p6d=x. e) Is the answer in part (c) and part (d) the same? Put the answer in p6e. Hint: Check by setting them equal. f Compute the difference between part (c) and (d) and put the answer in p6f.

Explanation / Answer

*******************************************************************************
Kindly find the code below.
The outputs have also been provided.
The printf statements explain how the code works. We are using:
/ , inv(), isequal()
for this assignment. If you have any queries, kindly comment below.
*******************************************************************************


*******************************************************************************
Code:


printf('A is 3X3 matrix ');
A = [ 1 5 6; 8 3 4; 7 2 9]
printf('b is 3 element column vector ');
b = [7;2;5]
p6b=b;
printf('Solving Ax = b for x ');
printf('Using \ operator: ');
x=A
p6c=x;
printf('Using inv function: ');
x=inv(A)*b
p6d=x;
p6c
p6d
printf('isequal(p6c, p6d) 0 not equal, 1 equal ');
p6e = isequal(p6c,p6d)
printf('Difference: ');
p6f=p6c-p6d


*******************************************************************************


*******************************************************************************
Sample Input/Output:

A is 3X3 matrix
A =

   1   5   6
   8   3   4
   7   2   9

b is 3 element column vector
b =

   7
   2
   5

Solving Ax = b for x
Using operator:
x =

-0.33333
   0.66667
   0.66667

Using inv function:
x =

-0.33333
   0.66667
   0.66667

p6c =

-0.33333
   0.66667
   0.66667

p6d =

-0.33333
   0.66667
   0.66667

isequal(p6c, p6d) 0 not equal, 1 equal
p6e = 0
Difference:
p6f =

   0.0000e+00
-2.2204e-16
   0.0000e+00

*******************************************************************************


*******************************************************************************
I hope this helps you.
If you find my answer helpful,
Kindly rate the answer.
All the best :)
*******************************************************************************