From wdunlap at tibco.com  Fri Sep  9 21:05:44 2016
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 9 Sep 2016 12:05:44 -0700
Subject: [Rd] Different results for tan(pi/2) and tanpi(1/2)
In-Reply-To: <CAML4n3P6duAC75ewwEtxaqsX6scygbstOjvn98AC7RUa0Mth=g@mail.gmail.com>
References: <CAML4n3NUKBMtXSt=naEktP4udKruenhG9N-Kdyx=sjpcx-BXvA@mail.gmail.com>
	<CAF8bMcbA8aToZg1KezJh7WYOYh-S9rByxbsd6m_AvMJugNkn-g@mail.gmail.com>
	<CAML4n3P6duAC75ewwEtxaqsX6scygbstOjvn98AC7RUa0Mth=g@mail.gmail.com>
Message-ID: <CAF8bMcYuUpLZ7hhwM81AVSMG6Dq-kOiJfOvGEW9mc2rL9P9wTQ@mail.gmail.com>

tanpi(x) should be more accurate than tan(pi*x), especially near multiples
of pi/2.

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Fri, Sep 9, 2016 at 11:55 AM, Hans W Borchers <hwborchers at gmail.com>
wrote:

> The same argument would hold for tan(pi/2).
> I don't say the result 'NaN' is wrong,
> but I thought,
> tan(pi*x) and tanpi(x) should give the same result.
>
> Hans Werner
>
>
> On Fri, Sep 9, 2016 at 8:44 PM, William Dunlap <wdunlap at tibco.com> wrote:
> > It should be the case that tan(pi*x) != tanpi(x) in many cases - that is
> why
> > it was added.  The limits from below and below of the real function
> > tan(pi*x) as x approaches 1/2 are different, +Inf and -Inf, so the limit
> is
> > not well defined.   Hence the computer function tanpi(1/2) ought to
> return
> > Not-a-Number.
> >
> > Bill Dunlap
> > TIBCO Software
> > wdunlap tibco.com
> >
> > On Fri, Sep 9, 2016 at 10:24 AM, Hans W Borchers <hwborchers at gmail.com>
> > wrote:
> >>
> >> 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
> >>
> >> ______________________________________________
> >> R-devel at r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-devel
> >
> >
>

	[[alternative HTML version deleted]]



[Rd] Different results for tan(pi/2) and tanpi(1/2)
William Dunlap