Inverse of an interval matrix

52 views
Skip to first unread message

nil...@googlemail.com

unread,
Feb 24, 2012, 9:59:52 AM2/24/12
to mpmath
Is it possible to compute the inverse of an interval matrix with
mpmath ?
An example would be appreciated.
How do I define the upper and lower bounds of each matrix entry ?

http://mpmath.googlecode.com/svn/trunk/doc/build/matrices.html#interval-and-double-precision-matrices

Fredrik Johansson

unread,
Feb 24, 2012, 10:19:10 AM2/24/12
to mpm...@googlegroups.com
On Fri, Feb 24, 2012 at 15:59, nil...@googlemail.com
<nil...@googlemail.com> wrote:
> Is it possible to compute the inverse of an interval matrix with
> mpmath ?
> An example would be appreciated.
> How do I define the upper and lower bounds of each matrix entry ?

Yes, it should work. Here is a simple example:

from mpmath import mp, iv

A = iv.matrix(3,3)
for i in range(3):
for j in range(3):
value = mp.rand()
error = mp.rand() * 1e-5
A[i,j] = iv.mpf([value-error, value+error])

B = iv.inverse(A)

>>> print iv.norm(A * B - iv.eye(3))
[0.0, 0.0018296896896417072509]

Fredrik

Nils Wagner

unread,
Feb 24, 2012, 10:42:43 AM2/24/12
to mpm...@googlegroups.com
Thank you for your example.
The inverse of a symmetric interval matrix should be symmetric !
Am I missing something ?

from mpmath import iv
#
# Symmetric interval matrix
#
A = iv.matrix(3,3)

A[0,0] = iv.mpf([1.-0.2,1.+0.2])
A[0,1] = iv.mpf([4.-0.2,4.+0.2])
A[0,2] = iv.mpf([5.-0.2,5.+0.2])

A[1,0] = iv.mpf([4.-0.2,4.+0.2])
A[1,1] = iv.mpf([2.-0.2,2.+0.2])
A[1,2] = iv.mpf([6.-0.2,6.+0.2])

A[2,0] = iv.mpf([5.-0.2,5.+0.2])
A[2,1] = iv.mpf([6.-0.2,6.+0.2])
A[2,2] = iv.mpf([3.-0.2,3.+0.2])

print A

#
# Inverse of a symmetric interval matrix should be symmetric as well
#
inv_A = iv.inverse(A)

print inv_A

> --
> You received this message because you are subscribed to the Google Groups
> "mpmath" group.
> To post to this group, send email to mpm...@googlegroups.com.
> To unsubscribe from this group, send email to
> mpmath+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mpmath?hl=en.
>
>

Fredrik Johansson

unread,
Feb 24, 2012, 11:12:10 AM2/24/12
to mpm...@googlegroups.com
On Fri, Feb 24, 2012 at 16:42, Nils Wagner <nil...@googlemail.com> wrote:
> Thank you for your example.
> The inverse of a symmetric interval matrix should be symmetric !
> Am I missing something ?

Not usually. If the input matrix contains large errors, the computed
inverse will have even larger errors, and the symmetricity is likely
to be lost in the process. Interval arithmetic is not really good at
*tightly* preserving error bounds across complex calculations (such as
matrix computations), especially if there is an implied dependency
between multiple variables. For example when setting

A[0,1] = iv.mpf([4.-0.2,4.+0.2])

A[1,0] = iv.mpf([4.-0.2,4.+0.2])

the matrix actually "contains" a matrix where one entry is 3.8 and the
other is 4.2, which is not particularly symmetric. The intervals in
the output cannot be expected to be symmetric even if the input
intervals are, since the order of operations strongly affects the way
errors propagate.

That said, there are probably more sophisticated algorithms for
inverting an interval matrix than the simple LU decomposition used in
mpmath, that might work better in some cases.

Fredrik

Reply all
Reply to author
Forward
0 new messages