Subject: lib/3917: gamma(3)/lgamma(3) man page is misleading
To: None <gnats-bugs@gnats.netbsd.org>
From: Krister Walfridsson <cato@ulysses.df.lth.se>
List: netbsd-bugs
Date: 07/25/1997 21:03:39
>Number:         3917
>Category:       lib
>Synopsis:       gamma(3)/lgamma(3) man page is misleading
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 25 12:05:02 1997
>Last-Modified:
>Originator:     Krister Walfridsson
>Organization:
	
>Release:        NetBSD-current 19 Jul 1997
>Environment:
	
System: NetBSD ulysses 1.2G NetBSD 1.2G (KWA) #0: Sun Jul 13 16:33:57 MEST 1997 cato@ulysses:/usr/src/sys/arch/sparc/compile/KWA sparc


>Description:
The man page gives the impression that gamma(3) calculates the gamma
function, but our gamma(3) is identical to lgamma(3), which calculates the
logarithm of the gamma function.

>How-To-Repeat:
	
>Fix:
In 4.4BSD and FreeBSD does gamma(3) actually calculate the gamma function,
so I think the best solution is to inport the 4.4BSD implementation.
If that has too much potential of breakage of existing code etc. do 
something like this to the man page

*** lgamma.3.bak        Sat Mar 30 13:32:09 1996
--- lgamma.3    Fri Jul 25 20:47:45 1997
***************
*** 44,49 ****
--- 44,53 ----
  .Fa signgam ;
  .sp
  .Ft double
+ .Fn gamma "double x"
+ .Ft float
+ .Fn gammaf "float x"
+ .Ft double
  .Fn lgamma "double x"
  .Ft float
  .Fn lgammaf "float x"
***************
*** 64,69 ****
--- 68,77 ----
  .Fa signgam
  returns the sign of \(*G(x).
  .Pp
+ .Fn Gamma
+ is identical to
+ .Fn lgamma
+ .Pp
  .Sh IDIOSYNCRASIES
  Do not use the expression
  .Dq Li signgam\(**exp(lgamma(x))
***************
*** 77,89 ****
  .Fn lgamma
  has returned can signgam be correct.
  .Pp
- For arguments in its range,
- .Fn gamma
- is preferred, as for positive arguments
- it is accurate to within one unit in the last place.
- Exponentiation of
- .Fn lgamma
- will lose up to 10 significant bits.
  .Sh RETURN VALUES
  .Fn Gamma
  and
--- 85,90 ----
***************
*** 98,106 ****
  .Va errno
  is set to
  .Er ERANGE
- For large non-integer negative values,
- .Fn gamma
- will underflow.
  .Sh SEE ALSO
  .Xr math 3
  .Sh HISTORY
--- 99,104 ----

>Audit-Trail:
>Unformatted: