Incorrect calculations by the computer: tan(x) and cot(x) for large values of x

Caleb Zhao - Nov 5 - - Dev Community

In this blog post, we explore incorrect calculations of the tangent function tan(x) and the cotangent function cot(x) for large numbers in MATLAB.

Example 1. Suppose x=235556677777.87. x=235556677777.87\,. Calculate tan(x) \tan(x) and cot(x) \cot(x) in MATLAB.

Let's just post the figure directly.

MATLAB outputFrom the above figure, it can be seen that the two outputs from MATLAB are
1.429064236906033 1.4290\red{64236906033} and 0.699758607188316. 0.69975\red{8607188316} .

However, the correct values with 16 significant digits are 0.1429079091621959e1 and 0.6997513334724058, respectively (as provided by ISRealsoft).

As a result, both outputs from MATLAB contain 11 incorrect digits, with an error rate of 11/16 = 68.75% for the significant figures.

. . .
Terabox Video Player