Find the value of r such that the determinant of A is zero.
조회 수: 17 (최근 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!