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

10 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Interpolation 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by