For demonstrative purposes, I am trying to find an online solver where alumni can input data of two matrices A and B, then the system outputs the first eigenvalues and eigenvectors in the generalized eigenvalue problem. Do you know any?


Go to compileonline.com's Matlab/octave page, enter the following, and click on "Execute Script":

A = rand(3);
B = rand(3);
[V,D] = eig(A,B)

Unfortunately their Python page doesn't seem to support numpy, but they also support R if you like that. Another option for octave specifically is Octave online, but it only supports line-by-line interpretation of input. Both support plotting.


I'd suggest an online interpreter for Python, like: https://www.pythonanywhere.com/try-ipython/

Python (with the packages NumPy and SciPy) is a popular open-source alternative to Matlab. So, using an online interpreter like the one above can give your students a realistic impression on how to solve eigenvalue problems in practice.


First import the Python packages that include matrices and eigensolvers:

In [1]: import numpy as np
In [2]: import scipy.linalg

Create two random 3x3 matrices:

In [3]: A = np.random.randn(3, 3)
In [4]: B = np.random.randn(3, 3)

Solve the generalized eigenvalue problem:

In [5]: E, U = scipy.linalg.eig(A, B)

Print eigenvalues:

In [6]: E
Out[6]: array([-28.36682105+0.j, 0.10868568+0.j, -0.85885290+0.j])

Print eigenvectors:

In [7]: U
array([[ 1.,          1. ,        -1. ],
       [ 0.104041 ,  -0.10251811, -0.35878059],
       [-0.73142778, -0.08405626,  0.44436849]]) 


There are several different eigensolvers, optimized for different conditions (e.g. symmetric or sparse matrices). See the documentation of NumPy and Scipy for details.

If you already are familiar with Matlab, this comparison may be useful to you:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.