This is a followup question to the thread

    
http://groups.google.com/group/sage-devel/browse_thread/thread/70deae9d64ec7840

which I'm not sure how to append to.

I'd like to use the numerical linear algebra features in SAGE to
produce a numerical solution for a vector in the nullspace of a
(numerically degenerate) system of linear equations, with known error
bounds for the solution vector.  It was suggested to try using the
interval arithmetic in ComplexIntervalField, but when I do this and
solve, it only produces the zero vector as a solution.  Here the
starting matrix is V, and below are some attempts to find the
nullspace.  I tried:

1) V \ b
2) V.eigenspaces(even_if_inexact=True)
3) V_approx = V.numerical_approx()
4) Solving via the numpy interface

I didn't try octave, because it doesn't seem to keep track of the
cumulative errors.  Any suggestions are appreciated.  Thanks,

-Jon
 =)

P.S.  Is there any online documentation available for numpy?  From
their webpage there is a way of buying a documentation book, but is
this the only way of learning about it?  I wasn't sure if numpy
actually keeps track of the error or not in some way when solving
linear equations.

Also my main reference for these attempts was 
http://www.sagemath.org/doc/html/const/node35.html



======================================================

sage: V.nrows(), V.ncols()
(10, 10)
sage: V.rank()
10
sage: abs(V.det())
[3.2685889670973850025414811602682e-105 ..
3.2685889670973850025414811656615e-105]


Solve with V \ b:
------------------------
sage: b = vector(CIF,[0  for i in range(10)])
sage:
sage: V \ b
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)


sage: V.eigenspaces(even_if_inexact=True)
---------------------------------------------------------------------------
<type 'exceptions.NotImplementedError'>   Traceback (most recent call
last)

/Users/jonhanke/Documents/sage-3.0.1/<ipython console> in <module>()

/Users/jonhanke/Documents/sage-3.0.1/matrix2.pyx in
sage.matrix.matrix2.Matrix.eigenspaces (sage/matrix/matrix2.c:14186)()

/Users/jonhanke/Documents/sage-3.0.1/matrix2.pyx in
sage.matrix.matrix2.Matrix.fcp (sage/matrix/matrix2.c:5890)()

/Users/jonhanke/Documents/sage-3.0.1/polynomial_element.pyx in
sage.rings.polynomial.polynomial_element.Polynomial.factor (sage/rings/
polynomial/polynomial_element.c:15876)()

<type 'exceptions.NotImplementedError'>:


sage: V_approx = V.numerical_approx()
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call
last)

/Users/jonhanke/Documents/sage-3.0.1/<ipython console> in <module>()

/Users/jonhanke/Documents/sage-3.0.1/matrix2.pyx in
sage.matrix.matrix2.Matrix.numerical_approx (sage/matrix/matrix2.c:
22383)()

/Users/jonhanke/Documents/sage-3.0.1/matrix0.pyx in
sage.matrix.matrix0.Matrix.change_ring (sage/matrix/matrix0.c:4367)()

/Users/jonhanke/Documents/sage-3.0.1/local/lib/python2.5/site-packages/
sage/matrix/matrix_space.py in __call__(self, entries, coerce, copy,
rows)
    351             return self(entries.matrix(), copy=False)
    352
--> 353         return self.matrix(entries, copy=copy, coerce=coerce,
rows=rows)
    354
    355     def change_ring(self, R):

/Users/jonhanke/Documents/sage-3.0.1/local/lib/python2.5/site-packages/
sage/matrix/matrix_space.py in matrix(self, x, coerce, copy, rows)
    964                 x = new_x
    965
--> 966         return self.__matrix_class(self, entries=x, copy=copy,
coerce=coerce)
    967
    968     def matrix_space(self, nrows=None, ncols=None,
sparse=False):

/Users/jonhanke/Documents/sage-3.0.1/matrix_generic_dense.pyx in
sage.matrix.matrix_generic_dense.Matrix_generic_dense.__init__ (sage/
matrix/matrix_generic_dense.c:1688)()

/Users/jonhanke/Documents/sage-3.0.1/local/lib/python2.5/site-packages/
sage/rings/complex_field.py in __call__(self, x, im)
    207             except AttributeError:
    208                 pass
--> 209         return complex_number.ComplexNumber(self, x, im)
    210
    211     def _coerce_impl(self, x):

/Users/jonhanke/Documents/sage-3.0.1/complex_number.pyx in
sage.rings.complex_number.ComplexNumber.__init__ (sage/rings/
complex_number.c:1981)()

<type 'exceptions.TypeError'>: unable to coerce to a ComplexNumber



Numpy Attempt:
------------------------
sage: from numpy import arange, eye, linalg
sage: V_numpy = V.numpy()
sage: b = arange(1,11)
sage: b
array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=object)
sage: x = linalg.solve(V,b)
---------------------------------------------------------------------------
<type 'exceptions.AttributeError'>        Traceback (most recent call
last)

/Users/jonhanke/Documents/sage-3.0.1/<ipython console> in <module>()

/Users/jonhanke/Documents/sage-3.0.1/local/lib/python2.5/site-packages/
numpy/linalg/linalg.py in solve(a, b)
    171     if one_eq:
    172         b = b[:, newaxis]
--> 173     _assertRank2(a, b)
    174     _assertSquareness(a)
    175     n_eq = a.shape[0]

/Users/jonhanke/Documents/sage-3.0.1/local/lib/python2.5/site-packages/
numpy/linalg/linalg.py in _assertRank2(*arrays)
    113 def _assertRank2(*arrays):
    114     for a in arrays:
--> 115         if len(a.shape) != 2:
    116             raise LinAlgError, '%d-dimensional array given.
Array must be \
    117             two-dimensional' % len(a.shape)

<type 'exceptions.AttributeError'>:
'sage.matrix.matrix_generic_dense.Matrix_generic_de' object has no
attribute 'shape'


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to