Incorrect calculations by the computer: sin(x) and cos(x)



This content originally appeared on DEV Community and was authored by Caleb Zhao

From IEEE-754-2019, it is known that the domain of trigonometric functions is the set of real numbers.
Example 1. Calculate sin⁡(20100) \sin(20^{100}) sin(20100) and cos⁡(20100) \cos(20^{100}) cos(20100) in MATLAB.

Let’s just post the picture directly.

MATLAB output
However, the correct values are 0.4559851… and -0.8899874…, respectively (as provided by ISRealsoft).
Thus, the outputs of MATLAB are all incorrect results.


This content originally appeared on DEV Community and was authored by Caleb Zhao