matrices help again (inverse) please
hi there would anyone be able to give me a link or guidence as how i would go about finding the inverse of A? I have a book that tells me add subtract and multiply.
the question is this: find the inverse of A
A =
(19 81)
(2 10)
sorry for the crude matrices. any help would be great :)
lakitu
Re: matrices help again (inverse) please
Quote:
Originally Posted by lakitu
hi there would anyone be able to give me a link or guidence as how i would go about finding the inverse of A? I have a book that tells me add subtract and multiply.
the question is this: find the inverse of A
A =
(19 81)
(2 10)
sorry for the crude matrices. any help would be great :)
lakitu
Hello.
Matrices can be inverted by various algorithms. It's not easy to explain in a few words so I suggest you Google around. Yot can search for "matrix inversion", "Gauss-Jordan", "LU decomposition", etc.
Or you can go to http://mathworld.wolfram.com/topics/Matrices.html or http://mathworld.wolfram.com/topics/...perations.html or http://mathworld.wolfram.com/MatrixInverse.html
Re: matrices help again (inverse) please
thank you i will try those links now :)
Re: matrices help again (inverse) please
A more general solution
VB Code:
Public Function MxInverse(Matrix() As Double) As Double()
Dim i As Long
Dim j As Long
Dim Rows As Long
Dim Cols As Long
Dim Tmp() As Double
Dim Ret() As Double
Dim Degree As Long
Tmp = Matrix
Rows = UBound(Tmp, 1)
Cols = UBound(Tmp, 2)
Degree = Cols + 1
'Augment Identity matrix onto matrix M to get [M|I]
ReDim Preserve Tmp(Rows, (Degree * 2) - 1)
For i = Degree To (Degree * 2) - 1
Tmp(i Mod Degree, i) = 1
Next
' Now find the inverse using Gauss-Jordan Elimination which should get us [I|A-1]
MxGaussJordan Tmp
' Copy the inverse (A-1) part to array to return
ReDim Ret(Rows, Cols)
For i = 0 To Rows
For j = Degree To (Degree * 2) - 1
Ret(i, j - Degree) = Tmp(i, j)
Next
Next
MxInverse = Ret
End Function
Public Sub MxGaussJordan(Matrix() As Double)
Dim Rows As Long
Dim Cols As Long
Dim P As Long
Dim i As Long
Dim j As Long
Dim m As Double
Dim d As Double
Dim Pivot As Double
Rows = UBound(Matrix, 1)
Cols = UBound(Matrix, 2)
' Reduce so we get the leading diagonal
For P = 0 To Rows
Pivot = Matrix(P, P)
For i = 0 To Rows
If Not P = i Then
m = Matrix(i, P) / Pivot
For j = 0 To Cols
Matrix(i, j) = Matrix(i, j) + (Matrix(P, j) * -m)
Next
End If
Next
Next
'Divide through to get the identity matrix
'Note: the identity matrix may have very small values (close to zero)
'because of the way floating points are stored.
For i = 0 To Rows
d = Matrix(i, i)
For j = 0 To Cols
Matrix(i, j) = Matrix(i, j) / d
Next
Next
End Sub
It is not optimised. You should use LU Decomposition for better algorithmic performance, and make of CopyMemory to increase the code performance. Nevertheless; it works
Re: matrices help again (inverse) please
Here is a tutorial with fully worked examples on LU decomposition and its application tfor finding the inverse of a matrix.
And this is from the very famous "Numerical Recipes" book that's available on-line: http://www.library.cornell.edu/nr/bookcpdf/c2-3.pdf
Re: matrices help again (inverse) please
Let Matrix A =
(a b)
(c d)
So the inverse = A^-1 =
(d -b) x 1/[ad-bc]
(-c a)
So for your matrix, the inverse of
(19 81)
(2 10)
is
(10 -81) x 1/(190-162) =
(-2 19)
([5/14] [-81/28])
([-1/14] [19/28]).
Re: matrices help again (inverse) please
Several years ago there was a thread at this forum whihc descibed matrix inversion, determinant evaluation, and solution of simultaneous linear equations.
A search might find it.
Re: matrices help again (inverse) please
Quote:
Originally Posted by lakitu
hi there would anyone be able to give me a link or guidence as how i would go about finding the inverse of A? I have a book that tells me add subtract and multiply.
the question is this: find the inverse of A
A =
(19 81)
(2 10)
sorry for the crude matrices. any help would be great :)
lakitu
For your martix:
A inverse =
(10 -81)
(-2 19)
Re: matrices help again (inverse) please
You didn't multiply by the reciprocal of the determinant x-ice.