Find inverse of matrix using Cayley Hamilton Theorem using MATLAB? - matlab

I have understood how to prove CHT using MATLAB but unable to find how to find inverse using it i.e post-multiplying by A^-1 in characteristic equation and then finding the value of the inverse.
This is how far i have gotten so far:
A=[1,2,3;4,5,6;7,8,9];
p=char(A);
poly2str(p,'x')
polyvalm(p,A)

Related

Numerical diagonalization of Hamiltonian using MATLAB

I am trying to diagonalize the Bogoliubov-de Gennes Hamiltonian. The problem is that the Hamiltonian contains a Laplacian. This could be solved by using a discretized Laplacian
If I use a simple Hamiltonian (just the Laplacian) and use eig(l1dd(...,...)) with l1dd the discretized Laplacian (2 and -1's) as in https://people.sc.fsu.edu/~jburkardt/m_src/laplacian/laplacian.html, Then I get:
I expect a linear or quadratic dispersion ($\omega \propto k or k^2$), but I get neither. What could be the problem? It seems that eig does a good job, so probably l1dd is the problem?

Solve system of linear equations in Spark

I have a system of linear equations in the form of Ax = b to solve in Spark.
A is n by n
b is n by 1
I representA in the form of IndexedRowMatrix or RowMatrix and b in the form of DenseMatrix or DenseVector.
How can I solve this system to calculate the x vector?
If the suggested solution is Cholesky Decomposition, would you please guide me through doing it as it is not part of the public API ? For example if the original matrix A is:
1,2,3,4
2,1,5,6
3,5,1,7
4,6,7,1
and b is:
5,6,7,8
What is passed as argument to the solve method ?
Any other solution other than inversing A would be very helpful.
I don't know if the question is still relevant to you or not, but another solution to the question is to invert the coefficient matrix and then multiply the inverted matrix to the vector b. There are many matrix inversion algorithm. One such algorithm can be found in the following paper
SPIN: A Fast and Scalable Matrix Inversion Method in Apache Spark
You can find the complete code on GitHub link also.
Cheers!!

Finding Eigenvalue and Eigenvector of a symmetric n*n matrix in Matlab

I need to find the eigen value decomposition of the symmetric matrix in Matlab. But I do not want to use the matlab inbuilt function eig Can anyone tell me efficient algortihm. I have already implemented the power Iteration Algorithm but it is not suitable for my project because it gives the best value in eigenvalue and eigen vector. Looking forward for suggestions.
PS: I am using eigenvalue decomposition several time in my algorithm...

MATLAB: How to solve linear system modulo m

Does anyone know what functions are available for solving linear systems when the equations are actually congruences mod m? The desire is to solve a linear system (Ax = b) for values x in which "Ax is congruent to b"
A discussion of how to perform gaussian elimination in this situation can be found here, but I was hoping to use MATLAB rather than attempting to do it by hand.
Have a look at the lincon() method found here:
http://www.mathworks.com/matlabcentral/fileexchange/32856-system-of-linear-congruences/content/lincon.m

Finding eigenvalues in MATLAB without using eig function

I'm trying to find eigenvalues of a matrix without using eig function (my homework says so). In Matlab, I define the matrix and identity matrix. But I cannot set up this equation:
A - x*I
x here is lambda, A is the matrix that I should find eigenvalues of and I is the identity matrix. If you know how to find eigenvalues, you supposed to understand this. How can I go through?
you can get some inspiration here: http://en.wikipedia.org/wiki/Eigenvalue_algorithm
if the matrix is fixed size, you can easily do the det(A-lambda*eye)=0 solving by yourself and use that.
With power iteration you can already find the dominant eigenvalue, and I knew there was an extension to this algorithm to also find the other eigenvalues, but cannot recall how that works :(