Filter löschen
Filter löschen

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

10 Ansichten (letzte 30 Tage)
Emilia
Emilia am 24 Jul. 2022
Kommentiert: Bruno Luong am 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)

Akzeptierte Antwort

Jan
Jan am 24 Jul. 2022
Remember, that Matlab uses IEEE754 doubles with limited precision. Then -5.5511e-17 is almost 0. The result is correct.
  5 Kommentare
John D'Errico
John D'Errico am 25 Jul. 2022
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 am 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))

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 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

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by