Find the value of r such that the determinant of A is zero.

31 ビュー (過去 30 日間)
Emilia
Emilia 2022 年 7 月 24 日
コメント済み: Bruno Luong 2022 年 7 月 25 日
Hello,
I am have matrix A with r as the parameter. I want to find the value of r such that the determinant of A is zero.
A=[cosd(90),0,-r*sind(90);0,1,0;sind(90),0,r*cosd(90)]
Answer should be r=0 , But I got it r=-5.5511e-17 that is incorrect.
Thanks in advance :)
fun = @(r)[cosd(90),0,-r*sind(90);0,1,0;sind(90),0,r*cosd(90)];
r_val = fzero(@(r)det(fun(r)),1)

採用された回答

Jan
Jan 2022 年 7 月 24 日
Remember, that Matlab uses IEEE754 doubles with limited precision. Then -5.5511e-17 is almost 0. The result is correct.
  5 件のコメント
John D'Errico
John D'Errico 2022 年 7 月 25 日
Is it true this is not impacted by floating point arithmetic? In fact, the true value of that determinant is zero, when r==0. But if you are using floating point arithmetic (in the form of calls to fzero, and more deeply to det) to compute the solution, then floating point arithmetic is very much used. And that makes it a problem of the floating point representations of your numbers.
syms r
A=[cosd(90),0,-r*sind(90);0,1,0;sind(90),0,r*cosd(90)]
A = 
det(A)
ans = 
r
Of course, we can see here that the determinant will be zero only when r==0. But fzero CANNOT know that. So it uses a root finding algorithm, treating the determinant as a nonlinear function. In fact the determinant here is actually linear in r. But that does not seem relevant to me, as long as fzero is used. You get a non-zero value BECAUSE floating point arithemtic was used.
Bruno Luong
Bruno Luong 2022 年 7 月 25 日
fun = @(r)[cosd(90),0,-r*sind(90);0,1,0;sind(90),0,r*cosd(90)];
r_val = fzero(@(r)det(fun(r)),1,struct('TolX',1e-30))
r_val = 0
To me in this particular example, fzero stops because it estimates it close less tha 1e-16 to the solution.
Again in THIS specific case, there is no issue of precision issue when r get closer to 0
r=logspace(0,-30)
r = 1×50
1.0000 0.2442 0.0596 0.0146 0.0036 0.0009 0.0002 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
loglog(r,arrayfun(@(r) det(fun(r)), r))

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 7 月 24 日
syms r
A=[cosd(90),0,-r*sind(90);0,1,0;sind(90),0,r*cosd(90)]
solve(det(A))
This will get you the exact 0

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by