From hwborchers at gmail.com  Fri Sep  9 19:24:32 2016
From: hwborchers at gmail.com (Hans W Borchers)
Date: Fri, 9 Sep 2016 19:24:32 +0200
Subject: [Rd] Different results for tan(pi/2) and tanpi(1/2)
Message-ID: <CAML4n3NUKBMtXSt=naEktP4udKruenhG9N-Kdyx=sjpcx-BXvA@mail.gmail.com>

As the subject line says, we get different results for tan(pi/2) and
tanpi(1/2), though this should not be the case:

    > tan(pi/2)
    [1] 1.633124e+16

    > tanpi(1/2)
    [1] NaN
    Warning message:
    In tanpi(1/2) : NaNs produced

By redefining tanpi with sinpi and cospi, we can get closer:

    > tanpi <- function(x) sinpi(x) / cospi(x)

    > tanpi(c(0, 1/2, 1, 3/2, 2))
    [1]    0  Inf    0 -Inf    0

Hans Werner



[Rd] Different results for tan(pi/2) and tanpi(1/2)
Hans W Borchers