In this blog post, we explore incorrect calculations of the cosine function cos(x) in MATLAB near numbers around
Example 1. Given that
and
calculate
and
in MATLAB.
Let's just post the figure directly.
From the above screenshot, it can be seen that the two outputs from MATLAB are
and
However, the correct values with 16 significant digits are -0.3012758451921695e-7 and -0.3765996542384011e-10, respectively (as provided by ISRealsoft).
Thus, the outputs of MATLAB contain 9 and 12 incorrect digits, with error rates of 9/16 = 56.25% and 12/16 = 75% respectively for the significant figures.
Top comments (0)