octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #65720] The Result of cos (3 * pi / 2) should


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #65720] The Result of cos (3 * pi / 2) should be "0"
Date: Fri, 10 May 2024 09:58:32 -0400 (EDT)

Follow-up Comment #4, bug #65720 (group octave):

understanding the real issue isunderstanding the limitation of numerical
mathematics (the output is smaller than the numerical precision limit,
`eps`):

>> eps
ans = 2.2204e-16

>> cos(3*pi/2)
ans = -1.8369e-16

>> ans/eps
ans = -0.8273


and limits of numerical precision and pi prevent perfect function output from
all trig functions:

>> sin(0:pi/2:2*pi)
ans =
        0   1.0000   0.0000  -1.0000  -0.0000

>> ans - [0 1 0 -1 -0]
ans =
            0            0   1.2246e-16            0  -2.4492e-16

>> cos(0:pi/2:2*pi)
ans =
   1.0000e+00   6.1230e-17  -1.0000e+00  -1.8369e-16   1.0000e+00

>> ans - [1 0 -1 -0 1]
ans =
            0   6.1230e-17            0  -1.8369e-16            0

>> tan(0:pi/2:2*pi)
ans =
            0   1.6331e+16  -1.2246e-16   5.4437e+15  -2.4493e-16


it may be worth pointing out that the decimal versions of the trig functions,
which can take 'exact' critical values as inputs, are written to produce
'exact' 0 outputs. 

e.g.:

>> sind(0:90:390)
ans =
   0   1   0  -1   0

>> ans - [0 1 0 -1 -0]
ans =
   0   0   0   0   0

>> cosd(0:90:360)
ans =
   1   0  -1   0   1

>> ans - [1 0 -1 -0 1]
ans =
   0   0   0   0   0

>> tand(0:90:360)
ans =
     0   Inf     0   Inf     0



so if that is 'needed' by the user in non-symbolic computation, this might
provide a useful option.



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65720>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]