Question

Alt Print out this page and write answers on the sheet where indicated. Algebra 1. Consider the matrisx 0 -1 2 4 2 -3 6 -9 -1

Just MATLAB code please

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Matlab code LU decomposition and solution clear all close all %&Answering question 1. Matrix B B-l 2 3 4 1:0-1 2 4 2;0 040 0-eigenAsolve (polyA); fprintf( Solution is\n) disp(eigenA) %finding P and D matrix [vec, val]-eig(A) fprintf( Matrix P isin2 Columns 4 through 5 -12 2.33333333333333 P matrix- Solution Vector is 8. 00000000000001 Matrix A- Characteristic polynomialAnd D matrix is 6.91797521473434e-16 -2.96596306538106e-16 -3. 72248211441642e-16 5.11760939987911e-16 1.65138893315861e-16 5

%%Matlab code LU decomposition and solution
clear all
close all

%%Answering question 1.

% Matrix B
B=[1 2 3 4 1;0 -1 2 4 2;0 0 4 0 0;-3 -6 -9 -12 4; 0 0 1 1 1];

%displaying the matrix
fprintf('Matrix B=\n')
disp(B)
%Determinant of B
det_B=det(B);
fprintf('Determinant of B is %f.\n',det_B)

%LU decomposition of B
[L,U,P] = lu(B);
%Displaying all matrix
fprintf('L matrix=\n')
disp(L)

fprintf('U matrix=\n')
disp(U)

fprintf('P matrix=\n')
disp(P)

%solution vector
b=[2;3;4;1;1];

%solving the equation
y = L\(P*b);
x = U\y;

fprintf('Solution Vector is \n')
disp(x)

%%Answering question 2.

A=[1 3 3;-3 -5 -3;3 3 1];

%displaying the matrix
fprintf('Matrix A=\n')
disp(A)

syms x
AA = sym(A);
polyA = charpoly(AA,x);
fprintf('Characteristic polynomial is\n')
disp(polyA)
%solving the polynomial
eigenA = solve(polyA);
fprintf('Solution is\n')
disp(eigenA)

%finding P and D matrix

[vec,val]=eig(A);
fprintf('Matrix P is\n')
disp(vec)

D=inv(vec)*A*vec;
fprintf('And D matrix is\n')
disp(D)

%Finding A^9
A9=vec*(D.^9)*inv(vec);
fprintf('Finding A^9=\n')
disp(A9)

%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%

Add a comment
Know the answer?
Add Answer to:
Just MATLAB code please Alt Print out this page and write answers on the sheet where indicated. Algebra 1. Consider...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Matlab exercise: 1. (20 points total) Let -6 28 211 A=14-15-12 L-8 32 25 Write a script that (a) ...

    Linear Algebra Matlab exercise: 1. (20 points total) Let -6 28 211 A=14-15-12 L-8 32 25 Write a script that (a) (5 points) Computes and prints on the screen the eigenvalues of A (b) (10 points) Without using eig command, computes and prints on the screen bases for the eigenspaces corresponding to each of the distinct eigenvalues of A (c) (5 points) Plots p(t) (e) (5 points) Plots det(A tI), the characteristic polynomial of A, as a function of t...

  • just 1,2,4 Problem 1 Consider the linear system of equations Ax = b, where x €...

    just 1,2,4 Problem 1 Consider the linear system of equations Ax = b, where x € R4X1, and A= 120 b = and h= 0.1. [2+d -1 0 0 1 1 -1 2+d -1 0 h2 0 -1 2 + 1 Lo 0 -1 2+d] 1. Is the above matrix diagonally dominant? Why 2. Use hand calculations to solve the linear system Ax = b with d=1 with the following methods: (a) Gaussian elimination. (b) LU decomposition. Use MATLAB (L,...

  • Need Help on Matlab matrix system. Have your code return the solution x and show this...

    Need Help on Matlab matrix system. Have your code return the solution x and show this solution in a command prompt printout. Note that you can, of course, check your answer easily with the Matlab backslash command, A\b. Naive LU Decomposition Now, starting with your functioning Gauss Elimination code, modify it to keep the factors in the same matrix that it is passed. You of course will not modify the b-vector. Have this code return the L and U matrices...

  • # 2 and # 3 2 -6 4 -4 0 -4 6 1. Define A =...

    # 2 and # 3 2 -6 4 -4 0 -4 6 1. Define A = 8 01 . Determine, by hand, the LU factorization, of A. You may of course check your answer using appropriate technology tools. Then use your result to solve the system of equations Ax b, where b--4 2 0 5 2 2. Suppose A-6 -3 133Even though A is not square, it has an LU factorization A LU, 4 9 16 17 where L and...

  • (911 (1) (a) Recall that a square matrix A has an LU decomposition if we can...

    (911 (1) (a) Recall that a square matrix A has an LU decomposition if we can write it as the product A = LU of a lower triangular matrix and an upper triangular matrix. Show that the matrix 0 1 21 A= 3 4 5 (6 7 9] does not have an LU decomposition 0 0 Uji U12 U13 O 1 2 Il 21 l22 0 0 U22 U23 = 3 4 5 (131 132 133 0 0 U33 6...

  • 5. Consider the matrix A-1-6-7-3 Hint: The characteristic polynomial of A is p(λ ) =-(-2)0+ 1)2....

    5. Consider the matrix A-1-6-7-3 Hint: The characteristic polynomial of A is p(λ ) =-(-2)0+ 1)2. (a) Find the eigenvalues of A and bases for the corresponding eigenspaces. (b) Determine the geometric and algebraic multiplicities of each eigenvalue and whether A is diagonalizable or not. If it is, give a diagonal matrix D and an invertible matrix S such that A-SDS-1. If it's not, say why not.

  • Please use matlab, post the code, and dont just write the code by hand. Thank you!...

    Please use matlab, post the code, and dont just write the code by hand. Thank you! 4 [3 points] Use the function f(x on the interval [5, 5] and the 11 points below to find a N-10 Lagrange polynomial, using MATLAB. You will need to write code for and plot the polynomial as a function of x, but you do not have to write the polynomials down by hand 5 0 2 3 4 5 f(x) | 0.0399 | 00623...

  • Differention Equations - Can someone answer the checked numbers please? Determinants 659 is the characteristic equation of A with λ replaced by /L we can multiply by A-1 to get o get Now solve fo...

    Differention Equations - Can someone answer the checked numbers please? Determinants 659 is the characteristic equation of A with λ replaced by /L we can multiply by A-1 to get o get Now solve for A1, noting that ao- det A0 The matrix A-0 22 has characteristic equation 0 0 2 2-A)P-8-12A +62- 0, so 8A1-12+6A -A, r 8A1-12 Hence we need only divide by 8 after computing 6A+. 23 1 4 12 10 4 -64 EXERCISES 1. Find AB,...

  • This assignment assesses the material covered in Modules 6-10. Write full and complete so- lutions, using...

    This assignment assesses the material covered in Modules 6-10. Write full and complete so- lutions, using full sentences where appropriate. Explain all row operations when computing an RREF. Answer the questions asked. Questions 1-5 are worth 20 points each. The bonus question is worth 10 points (but points on this assignment are capped at 100). Recommended Deadline: April 24th Final Deadline: May 1st. 1. Compute the inverse of the matrix A = 1 3 1 4 -1 1 2 0...

  • 4. Consider the following matrix [1 0 -27 A=000 L-2 0 4] (a) (3 points) Find...

    4. Consider the following matrix [1 0 -27 A=000 L-2 0 4] (a) (3 points) Find the characteristic polynomial of A. (b) (4 points) Find the eigenvalues of A. Give the algebraic multiplicity of each eigenvalue (c) (8 points) Find the eigenvectors corresponding to the eigenvalues found in part (b). (d) (4 points) Give a diagonal matrix D and an invertible matrix P such that A = PDP-1 (e) (6 points) Compute P-and verify that A= PDP- (show your steps).

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT