delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/13/17:15:58

Message-ID: <364CAD3F.79419487@cyberoptics.com>
From: Eric Rudd <rudd AT cyberoptics DOT com>
Organization: CyberOptics
X-Mailer: Mozilla 4.05 [en] (Win95; U)
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: high precision nonlinear math functions ?
References: <4 DOT 1 DOT 19981112171650 DOT 00a26d70 AT hal DOT nt DOT tuwien DOT ac DOT at>
Lines: 25
Date: Fri, 13 Nov 1998 16:05:51 -0600
NNTP-Posting-Host: 206.144.150.73
X-Trace: news2.randori.com 910994698 206.144.150.73 (Fri, 13 Nov 1998 14:04:58 PDT)
NNTP-Posting-Date: Fri, 13 Nov 1998 14:04:58 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Anton Helm wrote:

> I've some problems with numerical precision of some math functions.
>
> log(tan(b/2.0 + PI/4.0))

There is a lot of cancellation in this formula for small b.  I would
suggest that you rewrite your algorithm to avoid such problems.  For
instance, one could use the formula for the tangent of the sum of two
angles to rewrite the above expression as

   log1p(2.*tan(0.5*b)/(1. - tan(0.5*b))

to avoid the cancellation.

> asin(e * sin(b))

Similar problems occur if e*sin(b) is near 1.  In general, one should try
pretty hard to come up with a good computational form, before resorting to
extended precision.  It is rarely necessary.

-Eric Rudd
rudd AT cyberoptics DOT com


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019