In this blog post, we explore incorrect calculations of the cosecant function csc(x) in MATLAB near numbers around
k π.
k\,\pi.
kπ.
Example 1. Given that
x1=0.942477796123e1≈3 π
x_1=0.942477796123\textup{e}1 \approx 3\,\pix1=0.942477796123e1≈3π
and
x2=0.7853981633974e2≈25 π ,x_2=0.7853981633974\textup{e}2 \approx 25\,\pi\,,
x2=0.7853981633974e2≈25π,
calculate
csc(x1)
\csc(x_1)
csc(x1)
and
csc(x2)
\csc(x_2)
csc(x2)
in MATLAB.
Using MATLAB, we computed the values of
csc(x1)
\csc(x_1)
csc(x1)
and
csc(x2).
\csc(x_2).
csc(x2).
The result is shown in the following screenshot.
).
Thus, the output of MATLAB contains only 6 and 4 correct digits, with error rates of (16-6)/16 = 62.5% and (16-4)/16 = 75% respectively for the significant figures.
SOCIAL SHARE CARD GENERATOR