Discussion Overview
The discussion revolves around an unexpected output from the "find" command in MATLAB, specifically when checking for equality in floating-point arithmetic. Participants explore potential causes and solutions related to the behavior of the "real" array and floating-point precision issues.
Discussion Character
- Technical explanation
- Debate/contested
- Mathematical reasoning
Main Points Raised
- One participant reports an unexpected error output of "error=4 7" while all elements of the "real" array appear to be 1.
- Another participant suggests checking the output of the "real" vector and proposes alternative methods to find the indices.
- A different participant mentions that the issue may stem from floating-point arithmetic and roundoff errors, indicating that exact equality checks can be misleading.
- Evidence is presented showing that subtracting 1 from the "real" array does not yield all zeros, suggesting precision issues.
- One participant recommends using a comparison tolerance to avoid the problem of floating-point inaccuracies.
- Another participant recalls a similar issue encountered in optimization code related to small values close to zero.
- Concerns are raised about the use of "real" as a variable name, which conflicts with a built-in MATLAB function, potentially causing further confusion.
Areas of Agreement / Disagreement
Participants express differing views on the cause of the unexpected output, with some attributing it to floating-point precision issues while others focus on the naming conflict with MATLAB functions. No consensus is reached on a single solution, and multiple approaches are suggested.
Contextual Notes
Participants note the limitations of floating-point arithmetic and the importance of using appropriate variable names to avoid conflicts with built-in functions.