Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12156 > unrolled thread
| Started by | jure lapajne <lapajne.jure@gmail.com> |
|---|---|
| First post | 2012-10-24 07:30 +0000 |
| Last post | 2012-10-26 03:35 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Eigenvalues works very slow jure lapajne <lapajne.jure@gmail.com> - 2012-10-24 07:30 +0000
Re: Eigenvalues works very slow David Bailey <dave@removedbailey.co.uk> - 2012-10-25 05:40 +0000
Re: Eigenvalues works very slow Michael Weyrauch <michael.weyrauch@gmx.de> - 2012-10-26 03:35 +0000
| From | jure lapajne <lapajne.jure@gmail.com> |
|---|---|
| Date | 2012-10-24 07:30 +0000 |
| Subject | Eigenvalues works very slow |
| Message-ID | <k685fc$m70$1@smc.vnet.net> |
Hello,
I'm trying to calculate eigenvalues of different sized matrices (from 10x10 to 1000x1000) using mathematica's built-in function - Eigenvalues. For smaller matrices it works ok, but for larger matrices it's just too slow. I tried writing the code in another system and it finds eigenvalues very quickly (in a second or two at most) even for big matrices. I'm not sure whether am I doing something wrong or is the speed difference really this big.
My code (you only need to change d to change the size of matrix):
d = 25;
q = Table[Table[1/2*Sqrt[i + j + 1]*KroneckerDelta[Abs[i - j], 1], {j, 0, d-1}],{i, 0, d - 1}];
h0 = Table[Table[(i + 1/2)*KroneckerDelta[i, j], {j, 0, d - 1}], {i, 0,d-1}];
lambda = 1/2;
q4 = lambda*q.q.q.q;
N[Eigenvalues[q4 + h0]]
Thanks for help.
[toc] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2012-10-25 05:40 +0000 |
| Message-ID | <k6ajci$r27$1@smc.vnet.net> |
| In reply to | #12156 |
On 24/10/2012 08:30, jure lapajne wrote:
> Hello,
> I'm trying to calculate eigenvalues of different sized matrices (from 10x10 to 1000x1000) using mathematica's built-in function - Eigenvalues. For smaller matrices it works ok, but for larger matrices it's just too slow. I tried writing the code in another system and it finds eigenvalues very quickly (in a second or two at most) even for big matrices. I'm not sure whether am I doing something wrong or is the speed difference really this big.
> My code (you only need to change d to change the size of matrix):
> d = 25;
> q = Table[Table[1/2*Sqrt[i + j + 1]*KroneckerDelta[Abs[i - j], 1], {j, 0, d-1}],{i, 0, d - 1}];
> h0 = Table[Table[(i + 1/2)*KroneckerDelta[i, j], {j, 0, d - 1}], {i, 0,d-1}];
> lambda = 1/2;
> q4 = lambda*q.q.q.q;
> N[Eigenvalues[q4 + h0]]
>
> Thanks for help.
>
You are calculating eigenvalues of an integer matrix - so you will get a
result in terms of complicated fractions, that you then reduce to
floating point numbers using N !
Change the last line to
Eigenvalues[N[q4 + h0]]
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | Michael Weyrauch <michael.weyrauch@gmx.de> |
|---|---|
| Date | 2012-10-26 03:35 +0000 |
| Message-ID | <k6d0eb$26s$1@smc.vnet.net> |
| In reply to | #12156 |
Hello,
there is a very simple solution to this:
Eigenvalues[N[q4 + h0]]
Reason: If you want to use numerical algorithms as most likely
the other system does automatically (because it doesen't know better),
then you need to give numerical input to the function Eigenvalues.
Unlike most other systems, Mathematica is smart enough to
chose different algorithms depending on the input it receives.
Michael
Am 24.10.2012 09:30, schrieb jure lapajne:
> Hello,
> I'm trying to calculate eigenvalues of different sized matrices (from 10x10 to 1000x1000) using mathematica's built-in function - Eigenvalues. For smaller matrices it works ok, but for larger matrices it's just too slow. I tried writing the code in another system and it finds eigenvalues very quickly (in a second or two at most) even for big matrices. I'm not sure whether am I doing something wrong or is the speed difference really this big.
> My code (you only need to change d to change the size of matrix):
> d = 25;
> q = Table[Table[1/2*Sqrt[i + j + 1]*KroneckerDelta[Abs[i - j], 1], {j, 0, d-1}],{i, 0, d - 1}];
> h0 = Table[Table[(i + 1/2)*KroneckerDelta[i, j], {j, 0, d - 1}], {i, 0,d-1}];
> lambda = 1/2;
> q4 = lambda*q.q.q.q;
> N[Eigenvalues[q4 + h0]]
>
> Thanks for help.
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web