MatLab: Not Enough Eigenvectors for (Repeated) Eigenvalues
$begingroup$
I am trying to make a code that matches the eigenvalues to eigenvectors for one of my projects and I am new to MatLab. I get a 3x3 matrix output when it comes to eigenvalues and a 3x2 when it comes to eigenvectors. I know the issues lies within the fact that one of my eigenvalues is a repeat, but I cannot find any resources telling me how to fix this. My V should definitely be a 3x3 matrix unless I have completely done this wrong when I did it by hand.
When n=2, my answer is how I want and my code works.
% Case n=2.
clear
syms k1 c1 c2 lambda t
A=[-k1 0; k1 0];
[V,D]=eig(A) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0];
eqn11 = c1*V(1,1)+c2*V(1,2) == p0(1,1);
eqn12 = c1*V(2,1)+c2*V(2,2) == p0(1,2);
solcon = solve([eqn11,eqn12], [c1, c2]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)
However, when n=3, I get an error.
% Case n=3.
clear
syms k1 c1 c2 c3 lambda t
B=[-k1 0 0; k1 -k1 0; 0 k1 0]
[V,D]=eig(B) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0 0];
eqn21 = c1*V(1,1)+c2*V(1,2)+c3*V(1,3) == p0(1,1);
eqn22 = c1*V(2,1)+c2*V(2,2)+c3*V(2,3) == p0(1,2);
eqn23 = c1*V(3,1)+c2*V(3,2)+c3*V(3,3) == p0(1,3);
solcon = solve([eqn21, eqn22, eqn23], [c1, c2,c3]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
c3Sol=solcon.c3;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)+exp(D(3,3)*t)*c3Sol*V(:,3)
V should be a 3x3, right? Please help. Perhaps my code for n=2 is wrong as well and I just lucked out.
linear-algebra matrices matlab matrix-equations
$endgroup$
|
show 5 more comments
$begingroup$
I am trying to make a code that matches the eigenvalues to eigenvectors for one of my projects and I am new to MatLab. I get a 3x3 matrix output when it comes to eigenvalues and a 3x2 when it comes to eigenvectors. I know the issues lies within the fact that one of my eigenvalues is a repeat, but I cannot find any resources telling me how to fix this. My V should definitely be a 3x3 matrix unless I have completely done this wrong when I did it by hand.
When n=2, my answer is how I want and my code works.
% Case n=2.
clear
syms k1 c1 c2 lambda t
A=[-k1 0; k1 0];
[V,D]=eig(A) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0];
eqn11 = c1*V(1,1)+c2*V(1,2) == p0(1,1);
eqn12 = c1*V(2,1)+c2*V(2,2) == p0(1,2);
solcon = solve([eqn11,eqn12], [c1, c2]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)
However, when n=3, I get an error.
% Case n=3.
clear
syms k1 c1 c2 c3 lambda t
B=[-k1 0 0; k1 -k1 0; 0 k1 0]
[V,D]=eig(B) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0 0];
eqn21 = c1*V(1,1)+c2*V(1,2)+c3*V(1,3) == p0(1,1);
eqn22 = c1*V(2,1)+c2*V(2,2)+c3*V(2,3) == p0(1,2);
eqn23 = c1*V(3,1)+c2*V(3,2)+c3*V(3,3) == p0(1,3);
solcon = solve([eqn21, eqn22, eqn23], [c1, c2,c3]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
c3Sol=solcon.c3;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)+exp(D(3,3)*t)*c3Sol*V(:,3)
V should be a 3x3, right? Please help. Perhaps my code for n=2 is wrong as well and I just lucked out.
linear-algebra matrices matlab matrix-equations
$endgroup$
1
$begingroup$
A matrix can simply not have enough eigenvectors for a given eigenvalue. Then it isn't diagonalizable. Depending on your application, there are ways around it, but none of them will give you that second eigenvector, because it just doesn't exist.
$endgroup$
– Matt Samuel
Dec 27 '18 at 20:19
$begingroup$
It has been quite some time since I took linear algebra. Does this mean that there are only two eigenvalues that apply (as in, my by-hand method was incorrect), or does this mean that MatLab can simply not do what I want?
$endgroup$
– hgasu
Dec 27 '18 at 21:20
$begingroup$
Try your $n=2$ code with[0 k1;0 0]
instead. You won’t have enough eigenvectors there, either. As @MattSamuel points out, not every matrix is diagonalizable. You’ll need to do something else to compute exponentials for those matrices. See “Jordan normal form” for a general method.
$endgroup$
– amd
Dec 27 '18 at 21:20
$begingroup$
MATLAB can do what you need, but you’re going to have to use the Jordan decomposition of the matrix, or something similar. I’m sure that there’s a built-in function for computing the exponential of a matrix, for that matter.
$endgroup$
– amd
Dec 27 '18 at 21:21
$begingroup$
@hgasu It's true that matlab can't find two eigenvectors for that eigenvalue. But that's not matlab's fault. Only one exists. Nothing can change that. It's like asking for a positive real number $x$ such that $2x=0$.
$endgroup$
– Matt Samuel
Dec 27 '18 at 21:22
|
show 5 more comments
$begingroup$
I am trying to make a code that matches the eigenvalues to eigenvectors for one of my projects and I am new to MatLab. I get a 3x3 matrix output when it comes to eigenvalues and a 3x2 when it comes to eigenvectors. I know the issues lies within the fact that one of my eigenvalues is a repeat, but I cannot find any resources telling me how to fix this. My V should definitely be a 3x3 matrix unless I have completely done this wrong when I did it by hand.
When n=2, my answer is how I want and my code works.
% Case n=2.
clear
syms k1 c1 c2 lambda t
A=[-k1 0; k1 0];
[V,D]=eig(A) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0];
eqn11 = c1*V(1,1)+c2*V(1,2) == p0(1,1);
eqn12 = c1*V(2,1)+c2*V(2,2) == p0(1,2);
solcon = solve([eqn11,eqn12], [c1, c2]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)
However, when n=3, I get an error.
% Case n=3.
clear
syms k1 c1 c2 c3 lambda t
B=[-k1 0 0; k1 -k1 0; 0 k1 0]
[V,D]=eig(B) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0 0];
eqn21 = c1*V(1,1)+c2*V(1,2)+c3*V(1,3) == p0(1,1);
eqn22 = c1*V(2,1)+c2*V(2,2)+c3*V(2,3) == p0(1,2);
eqn23 = c1*V(3,1)+c2*V(3,2)+c3*V(3,3) == p0(1,3);
solcon = solve([eqn21, eqn22, eqn23], [c1, c2,c3]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
c3Sol=solcon.c3;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)+exp(D(3,3)*t)*c3Sol*V(:,3)
V should be a 3x3, right? Please help. Perhaps my code for n=2 is wrong as well and I just lucked out.
linear-algebra matrices matlab matrix-equations
$endgroup$
I am trying to make a code that matches the eigenvalues to eigenvectors for one of my projects and I am new to MatLab. I get a 3x3 matrix output when it comes to eigenvalues and a 3x2 when it comes to eigenvectors. I know the issues lies within the fact that one of my eigenvalues is a repeat, but I cannot find any resources telling me how to fix this. My V should definitely be a 3x3 matrix unless I have completely done this wrong when I did it by hand.
When n=2, my answer is how I want and my code works.
% Case n=2.
clear
syms k1 c1 c2 lambda t
A=[-k1 0; k1 0];
[V,D]=eig(A) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0];
eqn11 = c1*V(1,1)+c2*V(1,2) == p0(1,1);
eqn12 = c1*V(2,1)+c2*V(2,2) == p0(1,2);
solcon = solve([eqn11,eqn12], [c1, c2]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)
However, when n=3, I get an error.
% Case n=3.
clear
syms k1 c1 c2 c3 lambda t
B=[-k1 0 0; k1 -k1 0; 0 k1 0]
[V,D]=eig(B) %V is the eigenvectors, D is the eigenvalues.
p0=[1 0 0];
eqn21 = c1*V(1,1)+c2*V(1,2)+c3*V(1,3) == p0(1,1);
eqn22 = c1*V(2,1)+c2*V(2,2)+c3*V(2,3) == p0(1,2);
eqn23 = c1*V(3,1)+c2*V(3,2)+c3*V(3,3) == p0(1,3);
solcon = solve([eqn21, eqn22, eqn23], [c1, c2,c3]);
c1Sol=solcon.c1;
c2Sol=solcon.c2;
c3Sol=solcon.c3;
exp(D(1,1)*t)*c1Sol*V(:,1) + exp(D(2,2)*t)*c2Sol*V(:,2)+exp(D(3,3)*t)*c3Sol*V(:,3)
V should be a 3x3, right? Please help. Perhaps my code for n=2 is wrong as well and I just lucked out.
linear-algebra matrices matlab matrix-equations
linear-algebra matrices matlab matrix-equations
asked Dec 27 '18 at 19:59
hgasuhgasu
111
111
1
$begingroup$
A matrix can simply not have enough eigenvectors for a given eigenvalue. Then it isn't diagonalizable. Depending on your application, there are ways around it, but none of them will give you that second eigenvector, because it just doesn't exist.
$endgroup$
– Matt Samuel
Dec 27 '18 at 20:19
$begingroup$
It has been quite some time since I took linear algebra. Does this mean that there are only two eigenvalues that apply (as in, my by-hand method was incorrect), or does this mean that MatLab can simply not do what I want?
$endgroup$
– hgasu
Dec 27 '18 at 21:20
$begingroup$
Try your $n=2$ code with[0 k1;0 0]
instead. You won’t have enough eigenvectors there, either. As @MattSamuel points out, not every matrix is diagonalizable. You’ll need to do something else to compute exponentials for those matrices. See “Jordan normal form” for a general method.
$endgroup$
– amd
Dec 27 '18 at 21:20
$begingroup$
MATLAB can do what you need, but you’re going to have to use the Jordan decomposition of the matrix, or something similar. I’m sure that there’s a built-in function for computing the exponential of a matrix, for that matter.
$endgroup$
– amd
Dec 27 '18 at 21:21
$begingroup$
@hgasu It's true that matlab can't find two eigenvectors for that eigenvalue. But that's not matlab's fault. Only one exists. Nothing can change that. It's like asking for a positive real number $x$ such that $2x=0$.
$endgroup$
– Matt Samuel
Dec 27 '18 at 21:22
|
show 5 more comments
1
$begingroup$
A matrix can simply not have enough eigenvectors for a given eigenvalue. Then it isn't diagonalizable. Depending on your application, there are ways around it, but none of them will give you that second eigenvector, because it just doesn't exist.
$endgroup$
– Matt Samuel
Dec 27 '18 at 20:19
$begingroup$
It has been quite some time since I took linear algebra. Does this mean that there are only two eigenvalues that apply (as in, my by-hand method was incorrect), or does this mean that MatLab can simply not do what I want?
$endgroup$
– hgasu
Dec 27 '18 at 21:20
$begingroup$
Try your $n=2$ code with[0 k1;0 0]
instead. You won’t have enough eigenvectors there, either. As @MattSamuel points out, not every matrix is diagonalizable. You’ll need to do something else to compute exponentials for those matrices. See “Jordan normal form” for a general method.
$endgroup$
– amd
Dec 27 '18 at 21:20
$begingroup$
MATLAB can do what you need, but you’re going to have to use the Jordan decomposition of the matrix, or something similar. I’m sure that there’s a built-in function for computing the exponential of a matrix, for that matter.
$endgroup$
– amd
Dec 27 '18 at 21:21
$begingroup$
@hgasu It's true that matlab can't find two eigenvectors for that eigenvalue. But that's not matlab's fault. Only one exists. Nothing can change that. It's like asking for a positive real number $x$ such that $2x=0$.
$endgroup$
– Matt Samuel
Dec 27 '18 at 21:22
1
1
$begingroup$
A matrix can simply not have enough eigenvectors for a given eigenvalue. Then it isn't diagonalizable. Depending on your application, there are ways around it, but none of them will give you that second eigenvector, because it just doesn't exist.
$endgroup$
– Matt Samuel
Dec 27 '18 at 20:19
$begingroup$
A matrix can simply not have enough eigenvectors for a given eigenvalue. Then it isn't diagonalizable. Depending on your application, there are ways around it, but none of them will give you that second eigenvector, because it just doesn't exist.
$endgroup$
– Matt Samuel
Dec 27 '18 at 20:19
$begingroup$
It has been quite some time since I took linear algebra. Does this mean that there are only two eigenvalues that apply (as in, my by-hand method was incorrect), or does this mean that MatLab can simply not do what I want?
$endgroup$
– hgasu
Dec 27 '18 at 21:20
$begingroup$
It has been quite some time since I took linear algebra. Does this mean that there are only two eigenvalues that apply (as in, my by-hand method was incorrect), or does this mean that MatLab can simply not do what I want?
$endgroup$
– hgasu
Dec 27 '18 at 21:20
$begingroup$
Try your $n=2$ code with
[0 k1;0 0]
instead. You won’t have enough eigenvectors there, either. As @MattSamuel points out, not every matrix is diagonalizable. You’ll need to do something else to compute exponentials for those matrices. See “Jordan normal form” for a general method.$endgroup$
– amd
Dec 27 '18 at 21:20
$begingroup$
Try your $n=2$ code with
[0 k1;0 0]
instead. You won’t have enough eigenvectors there, either. As @MattSamuel points out, not every matrix is diagonalizable. You’ll need to do something else to compute exponentials for those matrices. See “Jordan normal form” for a general method.$endgroup$
– amd
Dec 27 '18 at 21:20
$begingroup$
MATLAB can do what you need, but you’re going to have to use the Jordan decomposition of the matrix, or something similar. I’m sure that there’s a built-in function for computing the exponential of a matrix, for that matter.
$endgroup$
– amd
Dec 27 '18 at 21:21
$begingroup$
MATLAB can do what you need, but you’re going to have to use the Jordan decomposition of the matrix, or something similar. I’m sure that there’s a built-in function for computing the exponential of a matrix, for that matter.
$endgroup$
– amd
Dec 27 '18 at 21:21
$begingroup$
@hgasu It's true that matlab can't find two eigenvectors for that eigenvalue. But that's not matlab's fault. Only one exists. Nothing can change that. It's like asking for a positive real number $x$ such that $2x=0$.
$endgroup$
– Matt Samuel
Dec 27 '18 at 21:22
$begingroup$
@hgasu It's true that matlab can't find two eigenvectors for that eigenvalue. But that's not matlab's fault. Only one exists. Nothing can change that. It's like asking for a positive real number $x$ such that $2x=0$.
$endgroup$
– Matt Samuel
Dec 27 '18 at 21:22
|
show 5 more comments
1 Answer
1
active
oldest
votes
$begingroup$
The "secret" is to use the kernel of $B-lambda_k I$ for the different eigenvalues $lambda_k$.
Let me explain it on a numerical example :
B=[2 1 1
1 2 1
1 1 2];
eig(B),% gives 1 (double eigenvalue) and 4 (which is simple)
I=eye(3);
null(B-1*I), % provides a basis of 2 vectors for the eigenspace associated with $lambda_1=1$
null(B-4*I), % provides a unique vector generating the eigenspace associated with $lambda_1=1$
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3054308%2fmatlab-not-enough-eigenvectors-for-repeated-eigenvalues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The "secret" is to use the kernel of $B-lambda_k I$ for the different eigenvalues $lambda_k$.
Let me explain it on a numerical example :
B=[2 1 1
1 2 1
1 1 2];
eig(B),% gives 1 (double eigenvalue) and 4 (which is simple)
I=eye(3);
null(B-1*I), % provides a basis of 2 vectors for the eigenspace associated with $lambda_1=1$
null(B-4*I), % provides a unique vector generating the eigenspace associated with $lambda_1=1$
$endgroup$
add a comment |
$begingroup$
The "secret" is to use the kernel of $B-lambda_k I$ for the different eigenvalues $lambda_k$.
Let me explain it on a numerical example :
B=[2 1 1
1 2 1
1 1 2];
eig(B),% gives 1 (double eigenvalue) and 4 (which is simple)
I=eye(3);
null(B-1*I), % provides a basis of 2 vectors for the eigenspace associated with $lambda_1=1$
null(B-4*I), % provides a unique vector generating the eigenspace associated with $lambda_1=1$
$endgroup$
add a comment |
$begingroup$
The "secret" is to use the kernel of $B-lambda_k I$ for the different eigenvalues $lambda_k$.
Let me explain it on a numerical example :
B=[2 1 1
1 2 1
1 1 2];
eig(B),% gives 1 (double eigenvalue) and 4 (which is simple)
I=eye(3);
null(B-1*I), % provides a basis of 2 vectors for the eigenspace associated with $lambda_1=1$
null(B-4*I), % provides a unique vector generating the eigenspace associated with $lambda_1=1$
$endgroup$
The "secret" is to use the kernel of $B-lambda_k I$ for the different eigenvalues $lambda_k$.
Let me explain it on a numerical example :
B=[2 1 1
1 2 1
1 1 2];
eig(B),% gives 1 (double eigenvalue) and 4 (which is simple)
I=eye(3);
null(B-1*I), % provides a basis of 2 vectors for the eigenspace associated with $lambda_1=1$
null(B-4*I), % provides a unique vector generating the eigenspace associated with $lambda_1=1$
edited Jan 11 at 20:41
answered Jan 11 at 19:11
Jean MarieJean Marie
30.7k42154
30.7k42154
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3054308%2fmatlab-not-enough-eigenvectors-for-repeated-eigenvalues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
A matrix can simply not have enough eigenvectors for a given eigenvalue. Then it isn't diagonalizable. Depending on your application, there are ways around it, but none of them will give you that second eigenvector, because it just doesn't exist.
$endgroup$
– Matt Samuel
Dec 27 '18 at 20:19
$begingroup$
It has been quite some time since I took linear algebra. Does this mean that there are only two eigenvalues that apply (as in, my by-hand method was incorrect), or does this mean that MatLab can simply not do what I want?
$endgroup$
– hgasu
Dec 27 '18 at 21:20
$begingroup$
Try your $n=2$ code with
[0 k1;0 0]
instead. You won’t have enough eigenvectors there, either. As @MattSamuel points out, not every matrix is diagonalizable. You’ll need to do something else to compute exponentials for those matrices. See “Jordan normal form” for a general method.$endgroup$
– amd
Dec 27 '18 at 21:20
$begingroup$
MATLAB can do what you need, but you’re going to have to use the Jordan decomposition of the matrix, or something similar. I’m sure that there’s a built-in function for computing the exponential of a matrix, for that matter.
$endgroup$
– amd
Dec 27 '18 at 21:21
$begingroup$
@hgasu It's true that matlab can't find two eigenvectors for that eigenvalue. But that's not matlab's fault. Only one exists. Nothing can change that. It's like asking for a positive real number $x$ such that $2x=0$.
$endgroup$
– Matt Samuel
Dec 27 '18 at 21:22