Find the value of r such that the determinant of A is zero.
18 次查看(过去 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)
0 个评论
采纳的回答
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
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)]
det(A)
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
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))
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)
loglog(r,arrayfun(@(r) det(fun(r)), r))
更多回答(1 个)
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
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!