Question

Publish using a MatLab function for the following:

If a matrix A has dimension n×n and has n linearly independent eigenvectors, it is diagonalizable.This means there exists a matrix P such that P^(−1)AP=D, where D is a diagonal matrix whose diagonal entries are made up of the eigenvalues of A. P is constructed by taking the eigenvectors of A and using them as the columns of P. Your task is to write a program (function) that does the following

If a matrix A has dimension n x n and has n linearly independent eigenvectors, it is diagonalizable. This means there exists

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

MATLAB Script:

close all
clear
clc

fprintf('Example 1\n-----------------------------------\n')
A = [2 -1 -1; -1 2 -1; -1 -1 2];
[P,D] = diagonalize(A);

fprintf('\nExample 2\n-----------------------------------\n')
B = [0 -6 -4; 5 -11 -6; -6 9 4];
[P,D] = diagonalize(B);

function [P,D] = diagonalize(A)
disp('Input Matrix, A ='), disp(A)
[P,D] = eig(A);
if abs(real(det(P))) > eps
% Linearly independent eigenvectors => Diagonalizable
disp('P ='), disp(P)
disp('MatrixInverse(P) ='), disp(inv(P))
disp('D ='), disp(D)
disp('P*D*MatrixInverse(P) ='), disp(P*D/P)
else
error('Matrix is not diagonalizable.')
end
end

Output:

Example 1
-----------------------------------
Input Matrix, A =
2 -1 -1
-1 2 -1
-1 -1 2
P =
0.5774 0.7634 0.2895
0.5774 -0.6325 0.5164
0.5774 -0.1310 -0.8059
MatrixInverse(P) =
0.5774 0.5774 0.5774
0.7634 -0.6325 -0.1310
0.2895 0.5164 -0.8059
D =
0.0000 0 0
0 3.0000 0
0 0 3.0000
P*D*MatrixInverse(P) =
2.0000 -1.0000 -1.0000
-1.0000 2.0000 -1.0000
-1.0000 -1.0000 2.0000

Example 2
-----------------------------------
Input Matrix, A =
0 -6 -4
5 -11 -6
-6 9 4
Error using code_17>diagonalize (line 23)
Matrix is not diagonalizable.
Error in code_17 (line 11)
[P,D] = diagonalize(B);

Add a comment
Know the answer?
Add Answer to:
Publish using a MatLab function for the following: If a matrix A has dimension n×n and has n line...
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
  • Font Styles Paragraph Definition 1: Given La linear transformation from a vector space V into itself,...

    Font Styles Paragraph Definition 1: Given La linear transformation from a vector space V into itself, we say that is diagonalizable iff there exists a basis S relevant to which can be represented by a diagonal matrix D. Definition 2: If the matrix A represents the linear transformation L with respect to the basis S, then the eigenvalues of L are the eigenvalues of the matrix A. I Definition 3: If the matrix A represents the linear transformation L with...

  • Let T be a linear operator on a finite dimensional vector space with a matrix representation...

    Let T be a linear operator on a finite dimensional vector space with a matrix representation A = 1 1 0 0] 16 3 2 1-3 -1 0 a. (3 pts) Find the characteristic polynomial for A. b. (3 pts) Find the eigenvalues of A. C. (2 pts) Find the dimension of each eigenspace of A. d. (2 pts) Using part (c), explain why the operator T is diagonalizable. e. (3 pts) Find a matrix P and diagonal matrix D...

  • Commenting no idea is not helpful and doesn't mean my question needs to be edited. The...

    Commenting no idea is not helpful and doesn't mean my question needs to be edited. The answer is A and C are false, I'd like a good explanation. Review 4: question 2 Let A be an n x n matrix. Which of the below is/are not true? A Matrix A is diagonalizable if and only if the dimension of each eigenspace is less than the multiplicity of the corresponding eigenvalue. B Matrix A is diagonalizable if and only if it...

  • Consider the following hermitian matrix a) Calculate the trace and the determinant of this matrix. b)...

    Consider the following hermitian matrix a) Calculate the trace and the determinant of this matrix. b) Find the eigenvalues and compare their product and sum to the determinant and trace respectively. (It is a general result for any matrix that can be diagonalized, that the trace of a matrix is equal to the sum of its eigenvalues and that the determinant of a diagonalizable matrix is equal to the product of its eigenvalues. If these conditions are satisfied, you can...

  • Consider the following hermitian matrix: a) Calculate the trace and the determinant of this matrix. b)...

    Consider the following hermitian matrix: a) Calculate the trace and the determinant of this matrix. b) Find the eigenvalues and compare their product and sum to the determinant and trace respectively. (It is a general result for any matrix that can be diagonalized, that the trace of a matrix is equal to the sum of its eigenvalue:s and that the determinant of a diagonalizable matrix is equal to the product of its eigenvalues. If these conditions are satisfied, you can...

  • 3) (9 points) For each of the following matrices Find the eigenvalues and associated eigenvectors. If...

    3) (9 points) For each of the following matrices Find the eigenvalues and associated eigenvectors. If possible, state the matrices P and D, such that A = PDP-1. (Hint: P is a matrix containing eigenvectors of A on its columns, and D is a diagonal matrix.) If it is not possible to find P and D, just state so. 11-133b a. A = 1 2 2 1-2 -2 -2 2 0 -1 3] b. A = [1 -4 110 0...

  • Prove that if matrix A is diagonalizable with n real eigenvalues λι, λ2-..,An, then AI-λιλ2" λπ....

    Prove that if matrix A is diagonalizable with n real eigenvalues λι, λ2-..,An, then AI-λιλ2" λπ. Complete the proof by justifying each step. There exists an invertible matrix P and a diagonal matrix D, such that P1AP -D. -JIAT O Determinant of a Matrix Product O Definition of the Inverse of a Matrix O Properties of the Identity Matrix O Determinant of a Triangular Matrix O Determinant of an Inverse Matrix O Definition of a Diagonalizable Matrix O Eigenvalues of...

  • Consider the following matrices 2. .6 6 .9 A2 Ag (a) Diagonalize each matrix by writing...

    Consider the following matrices 2. .6 6 .9 A2 Ag (a) Diagonalize each matrix by writing A SAS-1 (b) For each of these three matrices, compute the limit Ak-SNS-1 as k-+ 00 if it exists. (c) Suppose A is an n x n matrix that is diagonalizable (so it has n linearly independent eigenvectors). What must be true for the limit Ak to exist as k → oo? What is needed for Ak-+ O? Justify your answer.

  • MATLAB HELP!!! Recall that if A is an m × n matrix and B is a p × q matrix, then the product C = AB is defined if and on...

    MATLAB HELP!!! Recall that if A is an m × n matrix and B is a p × q matrix, then the product C = AB is defined if and only if n = p, in which case C is an m × q matrix. 5. Recall that if A is an mx n matrix and B is a px q matrix, then the product C-AB is defined if and only if n = p, in which case C is...

  • In this exercise, you will work with a QR factorization of an mxn matrix. We will proceed in the ...

    In this exercise, you will work with a QR factorization of an mxn matrix. We will proceed in the way that is chosen by MATLAB, which is different from the textbook presentation. An mxn matrix A can be presented as a product of a unitary (or orthogonal) mxm matrix Q and an upper-triangular m × n matrix R, that is, A = Q * R . Theory: a square mxm matrix Q is called unitary (or orthogona) if -,or equivalently,...

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
ADVERTISEMENT