Matlab's numeric solution to det of Matrix is incorrect

조회 수: 47 (최근 30일)
ThanosST
ThanosST 2023년 7월 1일
댓글: Andreas 2025년 10월 15일 9:52
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)]
B = 
vpasolve (det(B) == 0, L, 4.7000) % L=4.73004 is the initial solution from PhD Thesis %
ans = 
3.9407331356929149250770292025221
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
ThanosST
ThanosST 2023년 7월 1일
Matrix is identical. For sure.
Torsten
Torsten 2023년 7월 1일
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.

댓글을 달려면 로그인하십시오.

답변 (4개)

Paul
Paul 2023년 7월 1일
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)]
B = 
vpasolve (det(B) == 0, L, 4.7000) % L=4.73004 is the initial solution from PhD Thesis %
ans = 
3.9407331356929149250770292025221
fplot (det(B), [-10, 10]),grid,xline(double(ans))
vpa(subs(det(B),L,[4.73004 ans]))
ans = 
  댓글 수: 1
ThanosST
ThanosST 2023년 7월 1일
Thank you i will look at it again, at least my use of vpasolve in the code is correct from what I understand.

댓글을 달려면 로그인하십시오.


Steven Lord
Steven Lord 2023년 7월 1일
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.
  댓글 수: 1
ThanosST
ThanosST 2023년 7월 1일
Thank you for your time I will look at it again. At least I verified after your post that there is nothing wrong with my code or sth that I am missing with vpasolve's functionality.

댓글을 달려면 로그인하십시오.


Andreas
Andreas 2025년 10월 14일 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
Dyuman Joshi
Dyuman Joshi 2025년 10월 15일 9:10
@Andreas, How is your statement related to this thread?
Andreas
Andreas 2025년 10월 15일 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
Andreas 2025년 10월 14일 12:23
이 답변에 Dyuman Joshi 님이 플래그를 지정함
The number 3.9407331356929149250770292025221… is not random. It is the exact solution to the equation:
ex=cos(x)sin(x)e^{-x} = \cos(x) - \sin(x)ex=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.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by