Did mldivide Implementation Change in R2022b?
조회 수: 2 (최근 30일)
이전 댓글 표시
When I run this code here on 2022b (actually, 2023a now, but I saw the same effect on 2022b) I get:
load('mldivdivideex')
format long e
clsys.A\clsys.B
But when I run on my local installation using 2022a I get
>> clsys.A\clsys.B
ans =
-1.000000000000000e+00 2.168317634010083e-17
-6.812536955189428e-12 1.287988200135117e-13
-1.000000000000000e+00 1.999999999991291e-02
-9.670661834891370e-13 8.679999999981482e+01
-2.428571428833527e-03 3.004408164584182e-04
The second row is obviously different, as are the (4,1) and (1,2) elements. Even the "large" elements can be different in the last digit.
The 2022b release notes do mention "mldivide and pagemldivide Functions: Improved performance with small matrices." But the release notes don't say anything about expecting different answers.
댓글 수: 9
답변 (1개)
Matt J
2023년 3월 17일
편집: Matt J
2023년 3월 17일
The condition number of clsys.A is very poor, so you should not expect any consistency in the result among different implementations of the mldivide operation nor among different CPUs.
load('mldivdivideex')
size(clsys.A)
cond(clsys.A)
댓글 수: 5
Steven Lord
2023년 3월 17일
Let's take a sample matrix with a condition number of 1e9.
format longg
A = [1 0; 0 1e9]
cond(A)
Now let's multiply A by two vectors that are very close to one another.
x1 = [1; 1]
y1 = A*x1
x2 = [1; 1.1]
y2 = A*x2
How different are y1 and y2? The first elements are the same. The second elements:
difference = y2(2)-y1(2)
The differences in the second element of the x vectors was only 0.1. The differences in the second elements of the y vectors was much, much larger. Granted this was a contrived example, but hopefully you can see that badly conditioned matrices can magnify differences or errors quite substantially.
From the Wikipedia entry on condition number: "As a rule of thumb, if the condition number , then you may lose up to k digits of accuracy on top of what would be lost to the numerical method due to loss of precision from arithmetic methods."
Bruno Luong
2023년 3월 17일
편집: Bruno Luong
2023년 3월 17일
"As a rule of thumb, if the condition number is 10^k, then you may lose up to k digits of accuracy on top of what would be lost to the numerical method due to loss of precision from arithmetic methods."
Hmmm I admit I don't understand this sentence from Wikipedia. Or at least I'm not sure how to interpret it correctly.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!