For some reason, these two arguments are not equal...
조회 수: 2 (최근 30일)
이전 댓글 표시
Hey everyone,
I do have a bit of a weird issue right now. I am currently on a project and I have got these arguments:
L0 = - (50*x^3)/21 + (50*x^2)/7 - (269*x)/42 + 11/7 and the L0 from the "Solutions" which is actually : -1/0.42*(x^3-3*x^2+2.69*x-0.66)
These two equations are perfeclty equals, in fact whenever I apply the function "isequal", it gives me as an outcome 1.
However whenever I try to multiply both of them with a value y0 (which is 1.6094) they are completely different and totally not equal. My question now is how ???? And also, is there perhaps a way in Matlab to make my L0 look like the L0 from the actualy solution?
Thanks in advance !
댓글 수: 5
dpb
2022년 5월 15일
Have to show us the exact code that gives an unexpected result -- they evaluate to the same numerically within machine precision if write a function as
fnD=@(x)L0(x)-LS(x);
where L0 and LS are anonymous functions of the two expressions above.
Multiplying either by a constant will again produce the same difference times that constant.
It's possible you made a typo in one place, perhaps??? When first cut 'n pasted the above text to build the comparison function, somehow a "-" got inserted in one of the expressions extraneously instead of the "*" which did produce bizarre results until I finally saw the mistake. Anything like that possibly the problem there, maybe???
Jan
2022년 5월 15일
@LUCA GIROTTI: Please post the code, which reproduces your observation. Then we can search for the difference.
"they are completely different and totally not equal." - Luckily they are not just a little bit not equal ;-)
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!