For some reason, these two arguments are not equal...

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 Comments

- (50*x^3)/21 + (50*x^2)/7 - (269*x)/42 + 11/7
is not equal to
-1/0.42*(x^3-3.0-x^2+2.69*x-0.66)
since 3-x^2 is not 3*x^2.
Sorry it should be like this -1/0.42*(x^3-3*x^2+2.69*x-0.66)
Sorry for the mispelled.
I can't see a big difference.
y0 = 1.6094;
x = -10:0.1:10;
L01 = - (50*x.^3)/21 + (50*x.^2)/7 - (269*x)/42 + 11/7;
L02 = -1/0.42*(x.^3-3*x.^2+2.69*x-0.66)
L01y = y0*L01;
L02y = y0*L02;
plot(x,L01y-L02y)
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???
@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 ;-)

Sign in to comment.

Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 15 May 2022

Commented:

Jan
on 15 May 2022

Community Treasure Hunt

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

Start Hunting!