Writing a script for finding the largest and second largest eigenvectors of a symmetric matrix.
up vote
0
down vote
favorite
For a final project in my linear algebra intro, I have been tasked with writing a script that finds the largest and the second largest eigenvectors of a symmetric matrix in Matlab. For the best possible grade, it must include a function as well. So far, I have been able to get my script to verify that a matrix is symmetric, and am feeling a little bit stuck. I need some guidance for finishing this assignment, as my Matlab experience is extremely limited.
Here is what I have so far:
prompt = 'Please input a symmetric matrix A.'
A = input(prompt);
if (A == A'),
eig(A)
else
disp('A is not a symmetric matrix. Please input a symmetric matrix.')
end
Note that the script hopefully verifies that A is symmetric, and I have the eigenvalues for A, but I am not sure where to go from here to $1$. find the eigenvectors, $2$. get the two largest eigenvectors, and $3$. write a useful function to fit into the script. I would be very grateful for any help given. Thanks!
matlab
|
show 1 more comment
up vote
0
down vote
favorite
For a final project in my linear algebra intro, I have been tasked with writing a script that finds the largest and the second largest eigenvectors of a symmetric matrix in Matlab. For the best possible grade, it must include a function as well. So far, I have been able to get my script to verify that a matrix is symmetric, and am feeling a little bit stuck. I need some guidance for finishing this assignment, as my Matlab experience is extremely limited.
Here is what I have so far:
prompt = 'Please input a symmetric matrix A.'
A = input(prompt);
if (A == A'),
eig(A)
else
disp('A is not a symmetric matrix. Please input a symmetric matrix.')
end
Note that the script hopefully verifies that A is symmetric, and I have the eigenvalues for A, but I am not sure where to go from here to $1$. find the eigenvectors, $2$. get the two largest eigenvectors, and $3$. write a useful function to fit into the script. I would be very grateful for any help given. Thanks!
matlab
3
This may be better suited for stackoverflow.com/questions/tagged/matlab
– Henry Swanson
Dec 2 '13 at 22:14
I'll x-post it there. I appreciate it.
– Heath Huffman
Dec 2 '13 at 22:17
Yeah, they'll probably know the specific syntax. If there's not a syntax for getting eigenvectors, you can look at the nullspace of $A - lambda I$, where $lambda$ is an eigenvalue. That'll give you the eigenvectors. The other two steps are just MATLAB syntax somehow.
– Henry Swanson
Dec 2 '13 at 22:21
1
To reinforce(?) @HenrySwanson 's Comment, if the Question is about an approach (Matlab: full eigensolution followed by picking out the two largest eigenvalues) already decided upon, it would certainly be ripe for SO. A mathematical (but computational) question would be how to best approximate the two top eigenvalues without getting all of them (such questions are also handled at SciComp.SE).
– hardmath
Dec 2 '13 at 22:27
1
It's the $largett Power Method$ algorithm or $largett Von Mises$ one which yields the eigenvalue of largest magnitude. Once you get this, you can "remove" that eigenvalue and repeat the algorithm for the next one. See ---> en.wikipedia.org/wiki/Power_iteration
– Felix Marin
Dec 2 '13 at 23:04
|
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
For a final project in my linear algebra intro, I have been tasked with writing a script that finds the largest and the second largest eigenvectors of a symmetric matrix in Matlab. For the best possible grade, it must include a function as well. So far, I have been able to get my script to verify that a matrix is symmetric, and am feeling a little bit stuck. I need some guidance for finishing this assignment, as my Matlab experience is extremely limited.
Here is what I have so far:
prompt = 'Please input a symmetric matrix A.'
A = input(prompt);
if (A == A'),
eig(A)
else
disp('A is not a symmetric matrix. Please input a symmetric matrix.')
end
Note that the script hopefully verifies that A is symmetric, and I have the eigenvalues for A, but I am not sure where to go from here to $1$. find the eigenvectors, $2$. get the two largest eigenvectors, and $3$. write a useful function to fit into the script. I would be very grateful for any help given. Thanks!
matlab
For a final project in my linear algebra intro, I have been tasked with writing a script that finds the largest and the second largest eigenvectors of a symmetric matrix in Matlab. For the best possible grade, it must include a function as well. So far, I have been able to get my script to verify that a matrix is symmetric, and am feeling a little bit stuck. I need some guidance for finishing this assignment, as my Matlab experience is extremely limited.
Here is what I have so far:
prompt = 'Please input a symmetric matrix A.'
A = input(prompt);
if (A == A'),
eig(A)
else
disp('A is not a symmetric matrix. Please input a symmetric matrix.')
end
Note that the script hopefully verifies that A is symmetric, and I have the eigenvalues for A, but I am not sure where to go from here to $1$. find the eigenvectors, $2$. get the two largest eigenvectors, and $3$. write a useful function to fit into the script. I would be very grateful for any help given. Thanks!
matlab
matlab
edited Nov 24 at 5:03
Rócherz
2,7262721
2,7262721
asked Dec 2 '13 at 22:13
Heath Huffman
164517
164517
3
This may be better suited for stackoverflow.com/questions/tagged/matlab
– Henry Swanson
Dec 2 '13 at 22:14
I'll x-post it there. I appreciate it.
– Heath Huffman
Dec 2 '13 at 22:17
Yeah, they'll probably know the specific syntax. If there's not a syntax for getting eigenvectors, you can look at the nullspace of $A - lambda I$, where $lambda$ is an eigenvalue. That'll give you the eigenvectors. The other two steps are just MATLAB syntax somehow.
– Henry Swanson
Dec 2 '13 at 22:21
1
To reinforce(?) @HenrySwanson 's Comment, if the Question is about an approach (Matlab: full eigensolution followed by picking out the two largest eigenvalues) already decided upon, it would certainly be ripe for SO. A mathematical (but computational) question would be how to best approximate the two top eigenvalues without getting all of them (such questions are also handled at SciComp.SE).
– hardmath
Dec 2 '13 at 22:27
1
It's the $largett Power Method$ algorithm or $largett Von Mises$ one which yields the eigenvalue of largest magnitude. Once you get this, you can "remove" that eigenvalue and repeat the algorithm for the next one. See ---> en.wikipedia.org/wiki/Power_iteration
– Felix Marin
Dec 2 '13 at 23:04
|
show 1 more comment
3
This may be better suited for stackoverflow.com/questions/tagged/matlab
– Henry Swanson
Dec 2 '13 at 22:14
I'll x-post it there. I appreciate it.
– Heath Huffman
Dec 2 '13 at 22:17
Yeah, they'll probably know the specific syntax. If there's not a syntax for getting eigenvectors, you can look at the nullspace of $A - lambda I$, where $lambda$ is an eigenvalue. That'll give you the eigenvectors. The other two steps are just MATLAB syntax somehow.
– Henry Swanson
Dec 2 '13 at 22:21
1
To reinforce(?) @HenrySwanson 's Comment, if the Question is about an approach (Matlab: full eigensolution followed by picking out the two largest eigenvalues) already decided upon, it would certainly be ripe for SO. A mathematical (but computational) question would be how to best approximate the two top eigenvalues without getting all of them (such questions are also handled at SciComp.SE).
– hardmath
Dec 2 '13 at 22:27
1
It's the $largett Power Method$ algorithm or $largett Von Mises$ one which yields the eigenvalue of largest magnitude. Once you get this, you can "remove" that eigenvalue and repeat the algorithm for the next one. See ---> en.wikipedia.org/wiki/Power_iteration
– Felix Marin
Dec 2 '13 at 23:04
3
3
This may be better suited for stackoverflow.com/questions/tagged/matlab
– Henry Swanson
Dec 2 '13 at 22:14
This may be better suited for stackoverflow.com/questions/tagged/matlab
– Henry Swanson
Dec 2 '13 at 22:14
I'll x-post it there. I appreciate it.
– Heath Huffman
Dec 2 '13 at 22:17
I'll x-post it there. I appreciate it.
– Heath Huffman
Dec 2 '13 at 22:17
Yeah, they'll probably know the specific syntax. If there's not a syntax for getting eigenvectors, you can look at the nullspace of $A - lambda I$, where $lambda$ is an eigenvalue. That'll give you the eigenvectors. The other two steps are just MATLAB syntax somehow.
– Henry Swanson
Dec 2 '13 at 22:21
Yeah, they'll probably know the specific syntax. If there's not a syntax for getting eigenvectors, you can look at the nullspace of $A - lambda I$, where $lambda$ is an eigenvalue. That'll give you the eigenvectors. The other two steps are just MATLAB syntax somehow.
– Henry Swanson
Dec 2 '13 at 22:21
1
1
To reinforce(?) @HenrySwanson 's Comment, if the Question is about an approach (Matlab: full eigensolution followed by picking out the two largest eigenvalues) already decided upon, it would certainly be ripe for SO. A mathematical (but computational) question would be how to best approximate the two top eigenvalues without getting all of them (such questions are also handled at SciComp.SE).
– hardmath
Dec 2 '13 at 22:27
To reinforce(?) @HenrySwanson 's Comment, if the Question is about an approach (Matlab: full eigensolution followed by picking out the two largest eigenvalues) already decided upon, it would certainly be ripe for SO. A mathematical (but computational) question would be how to best approximate the two top eigenvalues without getting all of them (such questions are also handled at SciComp.SE).
– hardmath
Dec 2 '13 at 22:27
1
1
It's the $largett Power Method$ algorithm or $largett Von Mises$ one which yields the eigenvalue of largest magnitude. Once you get this, you can "remove" that eigenvalue and repeat the algorithm for the next one. See ---> en.wikipedia.org/wiki/Power_iteration
– Felix Marin
Dec 2 '13 at 23:04
It's the $largett Power Method$ algorithm or $largett Von Mises$ one which yields the eigenvalue of largest magnitude. Once you get this, you can "remove" that eigenvalue and repeat the algorithm for the next one. See ---> en.wikipedia.org/wiki/Power_iteration
– Felix Marin
Dec 2 '13 at 23:04
|
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
$newcommand{+}{^{dagger}}%
newcommand{angles}[1]{leftlangle #1 rightrangle}%
newcommand{braces}[1]{leftlbrace #1 rightrbrace}%
newcommand{bracks}[1]{leftlbrack #1 rightrbrack}%
newcommand{ceil}[1]{,leftlceil #1 rightrceil,}%
newcommand{dd}{{rm d}}%
newcommand{ds}[1]{displaystyle{#1}}%
newcommand{equalby}[1]{{#1 atop {= atop vphantom{huge A}}}}%
newcommand{expo}[1]{,{rm e}^{#1},}%
newcommand{fermi}{,{rm f}}%
newcommand{floor}[1]{,leftlfloor #1 rightrfloor,}%
newcommand{half}{{1 over 2}}%
newcommand{ic}{{rm i}}%
newcommand{iff}{Longleftrightarrow}
newcommand{imp}{Longrightarrow}%
newcommand{isdiv}{,left.rightvert,}%
newcommand{ket}[1]{leftvert #1rightrangle}%
newcommand{ol}[1]{overline{#1}}%
newcommand{pars}[1]{left( #1 right)}%
newcommand{partiald}[3]{frac{partial^{#1} #2}{partial #3^{#1}}}
newcommand{pp}{{cal P}}%
newcommand{root}[2]{,sqrt[#1]{,#2,},}%
newcommand{sech}{,{rm sech}}%
newcommand{sgn}{,{rm sgn}}%
newcommand{totald}[3]{frac{{rm d}^{#1} #2}{{rm d} #3^{#1}}}
newcommand{ul}[1]{underline{#1}}%
newcommand{verts}[1]{leftvert, #1 ,rightvert}$
Given the $n$-iterated vector $Psi_{n}$, we get the net one $Psi_{n + 1}$ with
$$
Psi_{n + 1} = {varphi_{n} over lambda_{n}},,quad
mbox{where}quad varphi_{n} equiv APsi_{n}
$$
$lambda_{n}$ is the component of $varphi_{n}$ with the largest magnitude. After $N$ ( "many" ) iterations, we get the eigenvalue as $lambda_{N}$. This is the eigenvalue with the largest magnitude. Next, we normalize the eigenvector:
$ds{varphi_{N} to {varphi_{N} over varphi_{N}^{sf T},varphi_{N}}}$. "Reduce" the matrix as
$$
tilde{A} equiv A - lambda_{N} varphi_{N}varphi_{N}^{sf T}
$$
Repeat the procedure with $tilde{A}$ and so on.
See this link.
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%2f590143%2fwriting-a-script-for-finding-the-largest-and-second-largest-eigenvectors-of-a-sy%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
up vote
2
down vote
accepted
$newcommand{+}{^{dagger}}%
newcommand{angles}[1]{leftlangle #1 rightrangle}%
newcommand{braces}[1]{leftlbrace #1 rightrbrace}%
newcommand{bracks}[1]{leftlbrack #1 rightrbrack}%
newcommand{ceil}[1]{,leftlceil #1 rightrceil,}%
newcommand{dd}{{rm d}}%
newcommand{ds}[1]{displaystyle{#1}}%
newcommand{equalby}[1]{{#1 atop {= atop vphantom{huge A}}}}%
newcommand{expo}[1]{,{rm e}^{#1},}%
newcommand{fermi}{,{rm f}}%
newcommand{floor}[1]{,leftlfloor #1 rightrfloor,}%
newcommand{half}{{1 over 2}}%
newcommand{ic}{{rm i}}%
newcommand{iff}{Longleftrightarrow}
newcommand{imp}{Longrightarrow}%
newcommand{isdiv}{,left.rightvert,}%
newcommand{ket}[1]{leftvert #1rightrangle}%
newcommand{ol}[1]{overline{#1}}%
newcommand{pars}[1]{left( #1 right)}%
newcommand{partiald}[3]{frac{partial^{#1} #2}{partial #3^{#1}}}
newcommand{pp}{{cal P}}%
newcommand{root}[2]{,sqrt[#1]{,#2,},}%
newcommand{sech}{,{rm sech}}%
newcommand{sgn}{,{rm sgn}}%
newcommand{totald}[3]{frac{{rm d}^{#1} #2}{{rm d} #3^{#1}}}
newcommand{ul}[1]{underline{#1}}%
newcommand{verts}[1]{leftvert, #1 ,rightvert}$
Given the $n$-iterated vector $Psi_{n}$, we get the net one $Psi_{n + 1}$ with
$$
Psi_{n + 1} = {varphi_{n} over lambda_{n}},,quad
mbox{where}quad varphi_{n} equiv APsi_{n}
$$
$lambda_{n}$ is the component of $varphi_{n}$ with the largest magnitude. After $N$ ( "many" ) iterations, we get the eigenvalue as $lambda_{N}$. This is the eigenvalue with the largest magnitude. Next, we normalize the eigenvector:
$ds{varphi_{N} to {varphi_{N} over varphi_{N}^{sf T},varphi_{N}}}$. "Reduce" the matrix as
$$
tilde{A} equiv A - lambda_{N} varphi_{N}varphi_{N}^{sf T}
$$
Repeat the procedure with $tilde{A}$ and so on.
See this link.
add a comment |
up vote
2
down vote
accepted
$newcommand{+}{^{dagger}}%
newcommand{angles}[1]{leftlangle #1 rightrangle}%
newcommand{braces}[1]{leftlbrace #1 rightrbrace}%
newcommand{bracks}[1]{leftlbrack #1 rightrbrack}%
newcommand{ceil}[1]{,leftlceil #1 rightrceil,}%
newcommand{dd}{{rm d}}%
newcommand{ds}[1]{displaystyle{#1}}%
newcommand{equalby}[1]{{#1 atop {= atop vphantom{huge A}}}}%
newcommand{expo}[1]{,{rm e}^{#1},}%
newcommand{fermi}{,{rm f}}%
newcommand{floor}[1]{,leftlfloor #1 rightrfloor,}%
newcommand{half}{{1 over 2}}%
newcommand{ic}{{rm i}}%
newcommand{iff}{Longleftrightarrow}
newcommand{imp}{Longrightarrow}%
newcommand{isdiv}{,left.rightvert,}%
newcommand{ket}[1]{leftvert #1rightrangle}%
newcommand{ol}[1]{overline{#1}}%
newcommand{pars}[1]{left( #1 right)}%
newcommand{partiald}[3]{frac{partial^{#1} #2}{partial #3^{#1}}}
newcommand{pp}{{cal P}}%
newcommand{root}[2]{,sqrt[#1]{,#2,},}%
newcommand{sech}{,{rm sech}}%
newcommand{sgn}{,{rm sgn}}%
newcommand{totald}[3]{frac{{rm d}^{#1} #2}{{rm d} #3^{#1}}}
newcommand{ul}[1]{underline{#1}}%
newcommand{verts}[1]{leftvert, #1 ,rightvert}$
Given the $n$-iterated vector $Psi_{n}$, we get the net one $Psi_{n + 1}$ with
$$
Psi_{n + 1} = {varphi_{n} over lambda_{n}},,quad
mbox{where}quad varphi_{n} equiv APsi_{n}
$$
$lambda_{n}$ is the component of $varphi_{n}$ with the largest magnitude. After $N$ ( "many" ) iterations, we get the eigenvalue as $lambda_{N}$. This is the eigenvalue with the largest magnitude. Next, we normalize the eigenvector:
$ds{varphi_{N} to {varphi_{N} over varphi_{N}^{sf T},varphi_{N}}}$. "Reduce" the matrix as
$$
tilde{A} equiv A - lambda_{N} varphi_{N}varphi_{N}^{sf T}
$$
Repeat the procedure with $tilde{A}$ and so on.
See this link.
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
$newcommand{+}{^{dagger}}%
newcommand{angles}[1]{leftlangle #1 rightrangle}%
newcommand{braces}[1]{leftlbrace #1 rightrbrace}%
newcommand{bracks}[1]{leftlbrack #1 rightrbrack}%
newcommand{ceil}[1]{,leftlceil #1 rightrceil,}%
newcommand{dd}{{rm d}}%
newcommand{ds}[1]{displaystyle{#1}}%
newcommand{equalby}[1]{{#1 atop {= atop vphantom{huge A}}}}%
newcommand{expo}[1]{,{rm e}^{#1},}%
newcommand{fermi}{,{rm f}}%
newcommand{floor}[1]{,leftlfloor #1 rightrfloor,}%
newcommand{half}{{1 over 2}}%
newcommand{ic}{{rm i}}%
newcommand{iff}{Longleftrightarrow}
newcommand{imp}{Longrightarrow}%
newcommand{isdiv}{,left.rightvert,}%
newcommand{ket}[1]{leftvert #1rightrangle}%
newcommand{ol}[1]{overline{#1}}%
newcommand{pars}[1]{left( #1 right)}%
newcommand{partiald}[3]{frac{partial^{#1} #2}{partial #3^{#1}}}
newcommand{pp}{{cal P}}%
newcommand{root}[2]{,sqrt[#1]{,#2,},}%
newcommand{sech}{,{rm sech}}%
newcommand{sgn}{,{rm sgn}}%
newcommand{totald}[3]{frac{{rm d}^{#1} #2}{{rm d} #3^{#1}}}
newcommand{ul}[1]{underline{#1}}%
newcommand{verts}[1]{leftvert, #1 ,rightvert}$
Given the $n$-iterated vector $Psi_{n}$, we get the net one $Psi_{n + 1}$ with
$$
Psi_{n + 1} = {varphi_{n} over lambda_{n}},,quad
mbox{where}quad varphi_{n} equiv APsi_{n}
$$
$lambda_{n}$ is the component of $varphi_{n}$ with the largest magnitude. After $N$ ( "many" ) iterations, we get the eigenvalue as $lambda_{N}$. This is the eigenvalue with the largest magnitude. Next, we normalize the eigenvector:
$ds{varphi_{N} to {varphi_{N} over varphi_{N}^{sf T},varphi_{N}}}$. "Reduce" the matrix as
$$
tilde{A} equiv A - lambda_{N} varphi_{N}varphi_{N}^{sf T}
$$
Repeat the procedure with $tilde{A}$ and so on.
See this link.
$newcommand{+}{^{dagger}}%
newcommand{angles}[1]{leftlangle #1 rightrangle}%
newcommand{braces}[1]{leftlbrace #1 rightrbrace}%
newcommand{bracks}[1]{leftlbrack #1 rightrbrack}%
newcommand{ceil}[1]{,leftlceil #1 rightrceil,}%
newcommand{dd}{{rm d}}%
newcommand{ds}[1]{displaystyle{#1}}%
newcommand{equalby}[1]{{#1 atop {= atop vphantom{huge A}}}}%
newcommand{expo}[1]{,{rm e}^{#1},}%
newcommand{fermi}{,{rm f}}%
newcommand{floor}[1]{,leftlfloor #1 rightrfloor,}%
newcommand{half}{{1 over 2}}%
newcommand{ic}{{rm i}}%
newcommand{iff}{Longleftrightarrow}
newcommand{imp}{Longrightarrow}%
newcommand{isdiv}{,left.rightvert,}%
newcommand{ket}[1]{leftvert #1rightrangle}%
newcommand{ol}[1]{overline{#1}}%
newcommand{pars}[1]{left( #1 right)}%
newcommand{partiald}[3]{frac{partial^{#1} #2}{partial #3^{#1}}}
newcommand{pp}{{cal P}}%
newcommand{root}[2]{,sqrt[#1]{,#2,},}%
newcommand{sech}{,{rm sech}}%
newcommand{sgn}{,{rm sgn}}%
newcommand{totald}[3]{frac{{rm d}^{#1} #2}{{rm d} #3^{#1}}}
newcommand{ul}[1]{underline{#1}}%
newcommand{verts}[1]{leftvert, #1 ,rightvert}$
Given the $n$-iterated vector $Psi_{n}$, we get the net one $Psi_{n + 1}$ with
$$
Psi_{n + 1} = {varphi_{n} over lambda_{n}},,quad
mbox{where}quad varphi_{n} equiv APsi_{n}
$$
$lambda_{n}$ is the component of $varphi_{n}$ with the largest magnitude. After $N$ ( "many" ) iterations, we get the eigenvalue as $lambda_{N}$. This is the eigenvalue with the largest magnitude. Next, we normalize the eigenvector:
$ds{varphi_{N} to {varphi_{N} over varphi_{N}^{sf T},varphi_{N}}}$. "Reduce" the matrix as
$$
tilde{A} equiv A - lambda_{N} varphi_{N}varphi_{N}^{sf T}
$$
Repeat the procedure with $tilde{A}$ and so on.
See this link.
edited Dec 2 '13 at 23:17
answered Dec 2 '13 at 23:06
Felix Marin
66.9k7107139
66.9k7107139
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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.
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%2f590143%2fwriting-a-script-for-finding-the-largest-and-second-largest-eigenvectors-of-a-sy%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
3
This may be better suited for stackoverflow.com/questions/tagged/matlab
– Henry Swanson
Dec 2 '13 at 22:14
I'll x-post it there. I appreciate it.
– Heath Huffman
Dec 2 '13 at 22:17
Yeah, they'll probably know the specific syntax. If there's not a syntax for getting eigenvectors, you can look at the nullspace of $A - lambda I$, where $lambda$ is an eigenvalue. That'll give you the eigenvectors. The other two steps are just MATLAB syntax somehow.
– Henry Swanson
Dec 2 '13 at 22:21
1
To reinforce(?) @HenrySwanson 's Comment, if the Question is about an approach (Matlab: full eigensolution followed by picking out the two largest eigenvalues) already decided upon, it would certainly be ripe for SO. A mathematical (but computational) question would be how to best approximate the two top eigenvalues without getting all of them (such questions are also handled at SciComp.SE).
– hardmath
Dec 2 '13 at 22:27
1
It's the $largett Power Method$ algorithm or $largett Von Mises$ one which yields the eigenvalue of largest magnitude. Once you get this, you can "remove" that eigenvalue and repeat the algorithm for the next one. See ---> en.wikipedia.org/wiki/Power_iteration
– Felix Marin
Dec 2 '13 at 23:04