Replies: 26 comments
-
yeah, this would be awesome of course 😎 |
Beta Was this translation helpful? Give feedback.
-
Related: #672 |
Beta Was this translation helpful? Give feedback.
-
Hi, just letting you know I am currently working on eigenvalue/vector function. |
Beta Was this translation helpful? Give feedback.
-
awesome @honeybar ! |
Beta Was this translation helpful? Give feedback.
-
Any progress? |
Beta Was this translation helpful? Give feedback.
-
I haven't had any update about it. |
Beta Was this translation helpful? Give feedback.
-
Any progress now? We have just "found out" that numeric.js has a bug in calculating eig values. And I was not able to find any trustworthy javascript library. + can this be takend out of Math.js docs? Its recommending numeric.js for eig calculations Issues with numeric.js |
Beta Was this translation helpful? Give feedback.
-
@josdejong Hi, I am so sorry. It is been a while and I am busy with work. I dont think I am able to complete it. Feel free to pass it over to anyone. |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back @honeybar, no problem at all! Anyone interested in implementing eigenvalues and eigenvectors? |
Beta Was this translation helpful? Give feedback.
-
I am interested. I have already written a small diagonalization library : https://github.com/arkajitmandal/DiagonalizeJS |
Beta Was this translation helpful? Give feedback.
-
That is exactly what we're looking for Arkajit! Thanks for your offer. Would be great if you can implement this in mathjs. Note that right now mathjs supports numbers and BigNumbers. An implementation for both would be great but it makes sense to me to start simple with just support for numbers. What do you think is a good approach to integrated this functionality in mathjs? |
Beta Was this translation helpful? Give feedback.
-
I agree, I would start with simple. I will begin with the eigenvalue eigenvectors for real symmetric matrix. |
Beta Was this translation helpful? Give feedback.
-
I think |
Beta Was this translation helpful? Give feedback.
-
I have started coding. I will ask you if I get some problem. Thanks |
Beta Was this translation helpful? Give feedback.
-
Hi !
After running build-and-test my unit-tests pass, how ever I get this error: 35 passing (3s)
Could you tell me what am I missing thanks in advance. |
Beta Was this translation helpful? Give feedback.
-
Update: |
Beta Was this translation helpful? Give feedback.
-
That looks promising Arkajit 👍 The issue |
Beta Was this translation helpful? Give feedback.
-
@arkajitmandal This looks awesome, any updates? :) |
Beta Was this translation helpful? Give feedback.
-
The present version of MathJS now has a math.eigs function that can compute eigenvalue/eigenvector for real symmetrix matrix. |
Beta Was this translation helpful? Give feedback.
-
Cool! In my opinion the best way to implement a general-case function eigs_general(M: Matrix)
{
let E = math.identity( math.size(M) );
let l = math.symbols('l');
let charEqn = math.evaluate( 'det( M - l*E )', {M, E, l} );
let eigVals = math.solve( charEqn, l );
let eigVecs = [];
for (ev of eigVals) {
mat = math.evaluate('M - ev*E', {M, E});
eigVecs.push( ...math.kernel(mat) );
}
return [eigVals, eigVecs];
} I know it sounds daunting at first, but imho it would benefit math.js as a whole. If you don't have time for that, I should be able to do that some time later this month. But if you think another approach would be better, go ahead! |
Beta Was this translation helpful? Give feedback.
-
I think I would focus on other parts, .... JosDeJong would be able to let you know if this is something he would like to have for mathjs. :) |
Beta Was this translation helpful? Give feedback.
-
@m93a do you mean like first use symbolic computation to turn I think implementing a solver for polynomial equations will be great to have on it's own, but as far as I know you can't "just" solve every polynomial symbolically, or is it? And how will this scale if you have a large real world matrix with ugly values? Will it feasible computationally to write it out as a polynomial and evaluate it? I have the feeling that it will explode. Probably going the numerical way is probably more robust and performant (and there are proven algorithms and libraries we can use for inspiration). I don't know for sure though. What do you guys think? |
Beta Was this translation helpful? Give feedback.
-
@josdejong I think that the problem of finding eigenvalues of a matrix is equivalent to that of solving a polynomial. So yes, the polynomial would grow with O(n²), but so would the problem itself. But I haven't studied this problem for long enough, so it's possible I'm missing something important. However, there's a great article about eigenvalue algorithms on Wikipedia. It says, for example, that:
So it seems that we can take the naïve approach I suggested and move the hard numerical algorithms to the polynomial solver. I'll take more time to look at it after my QM exam next week 😅️ |
Beta Was this translation helpful? Give feedback.
-
That is an excellent Wikipedia page 👍 . What sounds like the easiest solution to me is pick one of the iterative, numeric methods listed on that page, one that works for generic matrices. It could be interesting to experiment with your idea of writing out the polynomial and solve that (numerically with a root-finding algorithm?). My gut feeling though is that that will be more complicated and very slow. But maybe you can prove me wrong 😄 . |
Beta Was this translation helpful? Give feedback.
-
I started reading Numerical recipes in Fortran 77 and there they say:
So you were right, there are much better ways to tackle the issue. According to the book, a good library will provide methods that return:
Computing eigenvectors takes a lot of time, even when you know the eigenvalues. They also say that the library should have algorithms for these specific cases:
I'll try to implement an algorithm that computes all eigenvalues and all eigenvectors for a complex, non-Hermitian matrix, I'm starting issue #1741 for that. But even after I'm done with the algorithm, there will still be a lot to improve. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your research and the update @m93a , sounds like a good start 👍 |
Beta Was this translation helpful? Give feedback.
-
Hi again =)
Throwing another idea of implementing some useful methods of linalg, mostly inspired by Numpy. Again, anyone who is doing Machine Learning in JS will benefit from Math.js if we can support APIs like:
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.linalg.svd.html#numpy.linalg.svd
https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.linalg.eig.html#numpy.linalg.eig
Beta Was this translation helpful? Give feedback.
All reactions