[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-11 Thread pedda
Sure, you can download it from here: https://gist.github.com/ee7157b4446dfe5a20fb Chris, the book was recommended us during class but as far as I know they "only" treat analytically solvable cases. People love this model which is why the book is still hundreds of pages thick without talking about

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-11 Thread pedda
Hello everyone, thank you very much for your participation! I have attached the code. It is probably not the cleanest you can find, but it works for now.. You can control the size of the matrix by setting the variables sites, n_up, and n_down which I have moved to the top of the script. The goal w

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-10 Thread pedda
I have tried to do it non-symbolically, but I think it is rather inelegant. I am also trying to promote the use of python/sage over the use of Mathematica with my fellow students and it is somewhat important to show that they can do the same thing for free with other advantages. Since Mathematica i

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-10 Thread pedda
The matrices are the representations of Hamiltonians that come up in the one dimensional Hubbard model that is used in condensed matter physics. The size is determined by the number of lattice sites and electrons that are present in the system. x is the interaction energy for the electrons. Using

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-10 Thread pedda
Sorry for posting again, but I just made some progress on solving this problem: I used sagenb.com and sympy to find the eigenvalues for the matrix above and they were calculated in a very short time. Using my local sage, I get the same result in the same time as well. Only when using straight pytho

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-10 Thread pedda
I noticed there is an error in the matrix, which I thought might have prevented sympy from calculating the right values, but Mathematica calculates this and even bigger matrices instantly. What I find interesting though is that Maxima has the same problems with the matrix. I have attached a new mat

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-08 Thread pedda
So, actually the matrix I was talking about is even bigger, it is 400x400. As you can see, this the smaller one which my computer can also not handle. I also tried using Maxima which didn't work either. Am I doing something wrong in the setup of the program? I have x declared as a Symbol, the coeff

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-08 Thread pedda
The chop option worked well! Now one last problem: One of the tasks was to calculate the eigenvalues for an even bigger matrix (20 by 20) which sympy was not able to do in 24 hours and counting, while Mathematica solves this problem in about one minute (according to my tutor). Am I doing something

[sympy] Re: Getting rid of tiny imaginary parts in eigenvalues

2011-12-05 Thread pedda
Thank you very much for your answer. nsimplifying has sped up the process of finding the eigenvalues, but it is still not possible to plot them as they are still complex and so I get an error: TypeError: cannot create mpf from ... and then the function. I have tried varies approaches but just add

[sympy] Getting rid of tiny imaginary parts in eigenvalues

2011-12-02 Thread pedda
Hello everyone, I have a problem with sympy that has been driving me nuts for the last two nights. I am working on a simulation of a physical system that at some point gives me this matrix: [ 0,-1, 0, 0, 0, 0,-1, 0, 0] [-1, 1.0*x,-1, 0, 0, 0, 0, -1, 0