[英]inv(A)*B vs A\B - Why this weird behavior in MatLab?
Lets create two random matrices,让我们创建两个随机矩阵,
A = randn(2)
B = randn(2)
both inv(A)*B
and A\B
give the same result inv(A)*B
和A\B
都给出相同的结果
inv(A)*B
A\B
ans =
0.6175 -2.1988
-0.7522 5.0343
ans =
0.6175 -2.1988
-0.7522 5.0343
unless I multiply with some factor.除非我乘以某个因素。 Why is this?
为什么是这样?
.5*A\B
.5*inv(A)*B
ans =
1.2349 -4.3977
-1.5045 10.0685
ans =
0.3087 -1.0994
-0.3761 2.5171
This is very annoying since MatLab always nudges me to use A\B
instead of inv(A)*B
and it took me years to figure out why my code was not working.这很烦人,因为 MatLab 总是让我使用
A\B
而不是inv(A)*B
并且我花了好几年才弄清楚为什么我的代码不起作用。
When A
is non-singular matrix , then inv(A) * B = A \ B
.当
A
是非奇异矩阵时,则inv(A) * B = A \ B
。
Your calculation is as follows: .5 * A\B = (0.5 * A) \ B
vs .5* inv(A) * B = 0.5 * (A\B)
.您的计算如下:
.5 * A\B = (0.5 * A) \ B
vs .5* inv(A) * B = 0.5 * (A\B)
。 As such, it will give your unequal result.因此,它会给你带来不平等的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.