Strict inequalities are not supported (learn why)
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello everyone
I need your help please , I am student and am working in LQR control by LMI
i face probleme with inequalities , firstly i was thinking that becose the version of matlab 2020 but now i am working with 2024
2 Commenti
Walter Roberson
il 25 Giu 2024
Are you talking about the fact that for various routines you can put on restrictions A*x <= b, and A*x == b, but not A*x < b ?
Risposte (1)
John D'Errico
il 25 Giu 2024
Modificato: John D'Errico
il 25 Giu 2024
It is NOT related to the release number. Sorry. That has nothing to do with it. This has been the case since release 0 of MATLAB. (To be pedantic, back then, they were called versions, not releases as I recall. And I'm not sure what the first version was, since the first one I had was either version 1 or version 3. I had them both, but I did not really start using MATLAB until version 3.)
A strict inequality, something of the general form x > a, relies on knowing ALL of the digits of a number. And the problem is, even for a number like 1/3, you cannot store that number exactly in floating point arithmetic. And worse, any computations done using floating point numbers end up having some slop in them, in the least significant bits. We can see the perfect axample here:
0.3 - 0.1 - 0.2 == -0.2 - 0.1 + 0.3
Now surely that is a mathematical equality, right? And since we are talking strict inequalities, this next one yields a true result!
0.3 - 0.1 - 0.2 > -0.2 - 0.1 + 0.3
How could that possibly be true? Another example you should consider is this one:
1 + 1e-20 > 1
Now, surely that should have be true, right? At least it must be true if a strict inequality could ever be employed in any code. In fact, as far as double precision arithmetic is concerned, we have this counter-intuitive result instead:
1 + 1e-20 == 1
Again, you cannot trust the least significant bits of a floating point number. (Well, at least not unless you fully understand everything I have written here, and far more about floats and how to work with them. And even then, don't trust the least significant bits. And since you asked this question, you are not even close to that point.)
All of this gets worse when you are working with linear algebra, where many hundreds, thousands, or millions of adds, subtracts and multiplies are performed. The point is, asking for a STRICT inequality to be recognized and enforced is impossible.
3 Commenti
John D'Errico
il 26 Giu 2024
This is a compeltely different question. Ask it in a new question, as otherwise, you make this question into a long random thread that just asks for gneral consulting.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!