Ask Your Question

Revision history [back]

One way is to use less accurate floating point numbers.

This can be done using

  • the method change_ring of a matrix
  • the function RealField

Define a matrix:

sage: a = matrix(RR, 3, [j * 100./99 for j in (1 .. 9)])
sage: a
[1.01010101010101 2.02020202020202 3.03030303030303]
[4.04040404040404 5.05050505050505 6.06060606060606]
[7.07070707070707 8.08080808080808 9.09090909090909]

Change to 20-bit floating point numbers

sage: b = a.change_ring(RealField(20))
sage: b
[1.0101 2.0202 3.0303]
[4.0404 5.0505 6.0606]
[7.0707 8.0808 9.0909]