NetBSD Problem Report #44170

From www@NetBSD.org  Mon Nov 29 10:15:44 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 7EC9E63BAE8
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 29 Nov 2010 10:15:44 +0000 (UTC)
Message-Id: <20101129101544.3D53463BAE5@www.NetBSD.org>
Date: Mon, 29 Nov 2010 10:15:44 +0000 (UTC)
From: henning.petersen@t-online.de
Reply-To: henning.petersen@t-online.de
To: gnats-bugs@NetBSD.org
Subject: Bug in jn and jnf.
X-Send-Pr-Version: www-1.0

>Number:         44170
>Category:       lib
>Synopsis:       Bug in jn and jnf.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 29 10:20:01 +0000 2010
>Closed-Date:    Mon Nov 29 15:12:10 +0000 2010
>Last-Modified:  Mon Nov 29 15:15:04 +0000 2010
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
With program

#include <stdio.h>
#include <math.h>

int main(void)
{
int n;
double z;

z = 2.4048255576957729;
for(n = 2; n < 10; n++)
{
printf("%d %e\n", n, jn(n,z));
}
return 0;
}
i have following errors.

2 4.317548e-01
3 -inf
4 4.069027e-02
5 -inf
6 3.247664e-03
7 -inf
8 7.495602e-05
9 -inf

>How-To-Repeat:

>Fix:
diff -u -r1.13 e_jn.c
--- lib/libm/src/e_jn.c	20 Aug 2007 16:01:39 -0000	1.13
+++ lib/libm/src/e_jn.c	29 Nov 2010 07:27:52 -0000
@@ -203,7 +203,12 @@
 			}
 	     	    }
 		}
-	    	b = (t*__ieee754_j0(x)/b);
+		z = __ieee754_j0(x);
+		w = __ieee754_j1(x);
+		if (fabs(z) >= fabs(w))
+			b = (t*z/b);
+		else
+			b = (t*w/a);
 	    }
 	}
 	if(sgn==1) return -b; else return b;
diff -u -r1.10 e_jnf.c
--- lib/libm/src/e_jnf.c	19 Jan 2009 05:58:27 -0000	1.10
+++ lib/libm/src/e_jnf.c	29 Nov 2010 07:27:52 -0000
@@ -157,7 +157,12 @@
 			}
 	     	    }
 		}
-	    	b = (t*__ieee754_j0f(x)/b);
+		z = __ieee754_j0f(x);
+		w = __ieee754_j1f(x);
+		if (fabsf(z) >= fabsf(w))
+			b = (t*z/b);
+		else
+			b = (t*w/a);
 	    }
 	}
 	if(sgn==1) return -b; else return b;


>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: drochner@NetBSD.org
State-Changed-When: Mon, 29 Nov 2010 15:12:10 +0000
State-Changed-Why:
patch applied, thanks


From: "Matthias Drochner" <drochner@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44170 CVS commit: src/lib/libm/src
Date: Mon, 29 Nov 2010 15:10:07 +0000

 Module Name:	src
 Committed By:	drochner
 Date:		Mon Nov 29 15:10:06 UTC 2010

 Modified Files:
 	src/lib/libm/src: e_jn.c e_jnf.c

 Log Message:
 fix accuracy problems in argument ranges where j0(x) is small, closes
 PR lib/44170 by Henning Petersen
 (originally from Steven G. Kargl per FreeBSD PR bin/144306)


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.14 src/lib/libm/src/e_jn.c
 cvs rdiff -u -r1.10 -r1.11 src/lib/libm/src/e_jnf.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.