Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I'm trying to due high precision numerical work so I need to use mpf numbers. When we define matrices in sage using mpmath it seems that it loses the linalg operations such as inversion, so you can't calculate the inverse of a matrix as before. Is there a specific command for it?

For example:

Sage: M=matrix([[2,0],[0,2]])

Sage: M**-1

[1/2 0]

[ 0 1/2]

But:

Sage: M=mp.matrix([[2,0],[0,2]])

Sage: M**-1

Gives the error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_27.py", line 10, in <module> exec compile(u'open("___code___.py","w").write("# -- coding: utf-8 --\n" + _support_.preparse_worksheet_cell(base64.b64decode("TT1tcC5tYXRyaXgoW1syLDBdLFswLDJdXSkKTSoqLTE="),globals())+"\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in <module>

File "/tmp/tmps6geGH/___code___.py", line 4, in <module> exec compile(u'M**-_sage_const_1 File "", line 1, in <module>

File "/sagenb/sage_install/sage-5.4-sage.math.washington.edu-x86_64-Linux/local/lib/python2.7/site-packages/mpmath/matrices/matrices.py", line 603, in __pow__ raise ValueError('only integer exponents are supported') ValueError: only integer exponents are supported

It seems that Sage is not very friendly with mpmath. Is there something that should be imported or a specific command to use?

Thank you.