Matlab's numeric solution to det of Matrix is incorrect
47 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
I have an equation derived as the det of a matrix, which I have already solved in another software numerically and verified with the respective PhD Thesis' data. However, I now try to get more accustomed to Matlab and hence I tried to reproduce the problem and find its solution at this platform with vpasolve.
To my surprise, the Matlab solution is different! I also saw the plot, and it differs as well from the one the other software produces (which matches the one on the PhD Thesis). I even specify the solution of the textbook to define the area (else the initial solution of Matlab is vastly different, see below).
So my code is the following:
syms L
B = [(-cos(L)+cosh(L))/(2*L^2) (-sin(L)+sinh(L))/(2*L^3); (-L*sin(L)+L*sinh(L))/(2*L^2) (-L*cos(L)+L*cosh(L))/(2*L^3)]
vpasolve (det(B) == 0, L, 4.7000) % L=4.73004 is the initial solution from PhD Thesis %
fplot (det(B), [-10, 10])
And the solution I get is 3.9407331356929149250770292025221 (instead of 4.73004). If I do not specify the area of the initial solution, the answer is -226.94495142003040084517833499812.
What am I doing wrong?
Thank you for reading my post.
3 comentarios
Torsten
el 1 de Jul. de 2023
As you can see from the last line of Paul's code, det(B) = -0.05757... for L = 4.73004 and det(B) = 1.2645e-37 for L = 3.940733. So either your definition of B is wrong or the other software is wrong. Nothing else is possible.
Respuestas (4)
Paul
el 1 de Jul. de 2023
Hi ThanosST,
Are you sure the expressions in B are entered correctly? Asking because it sure looks like L = 3.9407 is the solution closest to 4.7. How did you get the solution L = 4.7304 in the other software?
syms L
B = [(-cos(L)+cosh(L))/(2*L^2) (-sin(L)+sinh(L))/(2*L^3); (-L*sin(L)+L*sinh(L))/(2*L^2) (-L*cos(L)+L*cosh(L))/(2*L^3)]
vpasolve (det(B) == 0, L, 4.7000) % L=4.73004 is the initial solution from PhD Thesis %
fplot (det(B), [-10, 10]),grid,xline(double(ans))
vpa(subs(det(B),L,[4.73004 ans]))
Steven Lord
el 1 de Jul. de 2023
Let's plot your solution from the thesis and the solution returned by MATLAB.
syms L
B = [(-cos(L)+cosh(L))/(2*L^2) (-sin(L)+sinh(L))/(2*L^3); (-L*sin(L)+L*sinh(L))/(2*L^2) (-L*cos(L)+L*cosh(L))/(2*L^3)];
sol = vpasolve (det(B) == 0, L, 4.7000); % L=4.73004 is the initial solution from PhD Thesis %
fplot (det(B), [-10, 10])
yline(0, 'r')
hold on
f = @(x) double(subs(det(B), L, x)); % Evaluate the determinant at a specified point
plot(double(sol), f(sol), 'ko')
plot(4.73004, f(4.73004), 'kx')
It certainly looks to me like the black circle is at the intersection of the blue curve of the determinant and the red line y = 0. To my eye, the solution you said was given in the thesis (the black x) is one of the values of L for which the determinant is (roughly) -0.05.
The fact that the common factor of L was not cancelled out in the numerator and denominator of the elements in the second row of B makes me a little suspicious that you made an error converting the expression in the thesis into code. I suppose it could have been left in to demonstrate a pattern in the elements down the columns of B, but I'd still double-check to be safe.
Andreas
el 14 de Oct. de 2025 a las 10:30
The number 3.94073313569... is one solution of the equation e^(-x) = cos(x) - sin(x). Does this help or make sense?
2 comentarios
Dyuman Joshi
el 15 de Oct. de 2025 a las 9:10
@Andreas, How is your statement related to this thread?
Andreas
el 15 de Oct. de 2025 a las 9:52
I just found by Google search of the solution to the above equality that the same number was a result of this thread. See below my second comment. I only wanted to know what is the reason for this
Andreas
el 14 de Oct. de 2025 a las 12:23
Dyuman Joshi
ha marcado con alerta este/a respuesta
The number 3.9407331356929149250770292025221… is not random. It is the exact solution to the equation:
e−x=cos(x)−sin(x)e^{-x} = \cos(x) - \sin(x)e−x=cos(x)−sin(x)
This equation has a root at that value, which can be verified numerically to extremely high precision. The fact that this same number appears as the result of a determinant calculation in MATLAB suggests that the matrix or the numerical method used may be implicitly linked to this equation — possibly through rounding behavior, algorithmic structure, or hidden mathematical resonance.
If anyone can confirm or further explore this connection, it would be greatly appreciated.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!