# [Numpy-discussion] How to solve homogeneous linear equations with NumPy?

Charles R Harris charlesr.harris@gmail....
Thu Dec 3 00:04:05 CST 2009

```On Wed, Dec 2, 2009 at 10:40 PM, Peter Cai <newptcai@gmail.com> wrote:

> How to solve homogeneous linear equations with NumPy?
>
>
>
> If I have homogeneous linear equations like this
>
> array([[-0.75,  0.25,  0.25,  0.25],
>       [ 1.  , -1.  ,  0.  ,  0.  ],
>       [ 1.  ,  0.  , -1.  ,  0.  ],
>       [ 1.  ,  0.  ,  0.  , -1.  ]])
>
> And I want to get a non-zero solution for it. How can it be done with
> NumPy?
>
> linalg.solve only works on A * x = b where b does not contains only 0.
>
>
>
One way is to use the singular value decomposition

In [16]: a = array([[-0.75,  0.25,  0.25,  0.25],
[ 1.  , -1.  ,  0.  ,  0.  ],
[ 1.  ,  0.  , -1.  ,  0.  ],
[ 1.  ,  0.  ,  0.  , -1.  ]])

In [20]: l,v,r = svd(a)

In [21]: v
Out[21]:
array([  2.17944947e+00,   1.00000000e+00,   1.00000000e+00,
1.11022302e-16])

In [22]: dot(a,r[-1])
Out[22]:
array([ -6.93889390e-17,   5.55111512e-17,   1.11022302e-16,1.11022302e-16])

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091202/33f55a13/attachment.html
```

More information about the NumPy-Discussion mailing list