# Strange warning regarding accuracy of computation in Matlab ?

17 Ansichten (letzte 30 Tage)
Tuong am 31 Dez. 2023
Kommentiert: Tuong am 1 Jan. 2024
Dear Matlab community,
Currently, I have been running into some accuracy problem regarding my Matlab program. Particulalrly I receive this warning:
Warning: Result may not be exact. Coefficient has a maximum relative error of 2.2204e-16, corresponding to absolute error 2
I do not understand this warning, between relative error and absolute error 2 which one is more dangeroud ?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Benjamin Kraus am 31 Dez. 2023
Bearbeitet: Benjamin Kraus am 31 Dez. 2023
Consider these two numbers: 100 and 101
If 100 is the "correct" answer, then 101 has an absolute error of 1 and a relative error of 0.01.
Now consider 1000000 (one million) and 1000001 (one million one).
If 1000000 is the "correct" answer, then 1000001 has an absolute error of 1 and a relative error of 0.000001. As your numbers get larger, the absolute error is probably less relevant.
Now consider 0.0001 and 0.00011.
If 0.0001 is the "correct" answer, then 0.00011 has an absolute error of 0.00001 and a relative error of 0.1 (or 10%). The relative error captures the magnitude of the values better.
Which is more dangerous depends a lot on the problem you are analyzing, so it would be hard to provide much more help without knowing more about what you are doing in MATLAB.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Hassaan am 31 Dez. 2023
Bearbeitet: Hassaan am 31 Dez. 2023
The warning from Matlab indicates a small relative error in your computation, suggesting you are at the limit of precision for double-precision floating-point numbers. Relative error is significant when comparing errors in numbers of varying magnitudes, while absolute error matters when values are within a similar range. The relative error of 2.2204e-16 is close to the machine epsilon, which is the smallest distinguishable difference from 1.0 in double-precision. This is usually not a cause for concern unless your specific application requires higher precision, in which case you might need to look into more numerically stable algorithms.
• Relative Error: It is more informative when the values you are dealing with span multiple orders of magnitude. A relative error of 2.2204e-16 is typically considered very small and would indicate high accuracy in most engineering and scientific computations since it is close to the precision limit of double-precision floating-point numbers in computers.
• Absolute Error: It is more useful when the values are expected to be in a similar range. An absolute error of 2 might be significant or negligible depending on the expected magnitude of your values.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Tuong am 1 Jan. 2024

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Logical finden Sie in Help Center und File Exchange

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by