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

Peter Cai newptcai@gmail....
Thu Dec 3 00:13:40 CST 2009


Thanks a lot.

But my knowledge of linear equations are limited, so can explain in your
code,
 which result represent the solution set of solution?

BTW : since [1, 1, 1, 1] is an obviously non-trivial solution, can you prove
your method could verify it?

On Thu, Dec 3, 2009 at 2:04 PM, Charles R Harris
<charlesr.harris@gmail.com>wrote:

>
>
> 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
>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


-- 
look to the things around you,the immediate world around you, if you are
alive,it will mean something to you ——Paul Strand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091203/78cab3f7/attachment.html 


More information about the NumPy-Discussion mailing list