Page 1 of 1

invet matrix (bis bis)

Posted: Thu Feb 17, 2005 10:04 am
by cchab
Clearly Vesnim does'nt use the determinant of a matrix to compute the inverse.

Try the following tittle vensim program :
!****************************
liA:
(lia1-lia2)
~
~ |

"inv(mat a)"[cola,llA]=
invert matrix(mat A[llA,cola],ELMCOUNT(cola))
~
~ |

"mata *inv( mat A)"[liA,llA]=
SUM(mat A[liA,cola!]*"inv(mat a)"[cola!,llA])
~
~ ~ :SUPPLEMENTARY
|

cola:
(cola1-cola2)
~
~ |

mat A[liA,cola]=TABBED ARRAY(
6 12
1 2)
~
~ |

llA<->liA
~
~ |
**********************

The program computes the inverse of matrix A, then multiply A by invert (A). We should obtain a I matrix.

if A is singular (has determinant =0) as in the program you will obtained a wrong result because Vensim try to invert a singulat matrix. With a non singular A matrix the result is OK .

The question is : how to test non singularity of a matrix before using the INVERT MATRIX function ?

REgards

Posted: Thu Feb 17, 2005 2:07 pm
by bob@vensim.com
There is indeed a problem when INVERT MATRIX is passed a singular matrix. We will correct this in the next release to issue an error message and return a 0 matrix.

If you want to test for this condition in the current release you can multiply the matrix and its inverse and test that against an identiry matrix. The attached model shows one way to do this.

It would be helpful going forward if you could post message related to a single topic in a single thread.