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

4 views (last 30 days)
Emilia on 24 Jul 2022
Commented: Bruno Luong on 25 Jul 2022
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 on 24 Jul 2022
Remember, that Matlab uses IEEE754 doubles with limited precision. Then -5.5511e-17 is almost 0. The result is correct.
Bruno Luong on 25 Jul 2022
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)) ### More Answers (1)

Walter Roberson on 24 Jul 2022
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
##### 1 CommentShowHide None
Emilia on 24 Jul 2022
Thank you! :)