用 Python 解方程

发布于 2024-11-30 15:41:38 字数 118 浏览 0 评论 0 原文

我正在尝试解方程,但我不知道如何做到这一点。我有一个向量 x 实际上是一个矩阵类型,我想求解方程 x.transpose()*v=0 其中 v 是另一个向量

有人可以帮助我吗?

我预先感谢你

i'm trying to solve an equation but I don't know the way to do this. I've got a vector x wich is actually a matrix type and I would like to solve the equation x.transpose()*v=0 where v is another vector

Can someone help me?

I thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情泪▽动烟 2024-12-07 15:41:38

取任何向量并将其投影到x正交补中。

Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> x = numpy.matrix([1, 3.14, 2.73]).T
>>> P = x * x.T / (x.T * x) # projector onto the space spanned by x
>>> Pperp = numpy.identity(3) - P # projector onto x's orthogonal complement
>>> Pperp * x
matrix([[  0.00000000e+00],
        [  0.00000000e+00],
        [ -2.22044605e-16]])
>>> y = numpy.matrix(numpy.ones((3,1)))
>>> yperp = Pperp * y
>>> yperp
matrix([[ 0.62484642],
        [-0.17798225],
        [-0.02416928]])
>>> x.T * yperp
matrix([[ -4.16333634e-16]])

正如所写,这是非常不受限制的,并且给出了相当任意的解决方案,但是可以建立相同的想法来为所有解决方案找到一组基向量。

Take any vector at all and project it into the orthogonal complement of x.

Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> x = numpy.matrix([1, 3.14, 2.73]).T
>>> P = x * x.T / (x.T * x) # projector onto the space spanned by x
>>> Pperp = numpy.identity(3) - P # projector onto x's orthogonal complement
>>> Pperp * x
matrix([[  0.00000000e+00],
        [  0.00000000e+00],
        [ -2.22044605e-16]])
>>> y = numpy.matrix(numpy.ones((3,1)))
>>> yperp = Pperp * y
>>> yperp
matrix([[ 0.62484642],
        [-0.17798225],
        [-0.02416928]])
>>> x.T * yperp
matrix([[ -4.16333634e-16]])

As written, this is quite unrestrained and gives a fairly arbitrary solution, but the same idea can be built up to find a set of basis vectors for all solutions.

谜兔 2024-12-07 15:41:38

xT*v 是向量之间点积的另一种编写方式< code>x 和 v,所以听起来你想找到一个向量 v,它是 x 正交。对于一般情况,有无限多个解(在 3 维中,想象垂直于 x 的平面中的任何向量v)。

您在评论中说过,您知道有很多可能的解决方案,以及如何才能找到一个解决方案,所以这里有一个适合您的解决方案:

v = 0

x.T*v is another way of writing the dot product between vectors x and v, so it sounds like you want to find a vector v which is orthogonal to x. For the general case, there are infinitely many solutions (in 3 dimensions, imagine any vector v in the plane perpendicular to x).

You have said in your comment you know there are a lot of possible solutions, and how can you get one, so here is one for you:

v = 0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文