In this blog post, we explore incorrect calculations of the tangent function tand(x) and cotangent function cotd(x) of which the independent variable is in degrees in MATLAB.
Example 1. Given that x1 = 444555666.777 and x2=444555666.777e16, calculate tand(x1), cotd(x1), tand(x2), and cotd(x2).
Using MATLAB, I computed the values of tand(x) and cosd(x) at x1 and x2. The results are shown in the following screenshot.
From the above screenshot, it can be seen that the outputs from MATLAB are and respectively.
However, the correct values, rounded to 16 significant digits, are -0.1337846899800357e1, -0.7474696844229537, -0.1732050807568877e1, and -0.5773502691896258, respectively (as provided by ISRealsoft).
Therefore, the error rates for the significant digits of the first two are 6/16 = 37.5% and 7/16 = 43.75%, respectively; while the last two have completely incorrect digits, resulting in an error rate of 100% for each.
Top comments (0)