Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 214579FE4 for ; Fri, 27 Jan 2012 03:56:35 +0000 (UTC) Received: (qmail 44700 invoked by uid 500); 27 Jan 2012 03:56:31 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 43586 invoked by uid 500); 27 Jan 2012 03:56:12 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 43532 invoked by uid 99); 27 Jan 2012 03:56:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 03:56:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jan 2012 03:56:02 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 35048166C40 for ; Fri, 27 Jan 2012 03:55:41 +0000 (UTC) Date: Fri, 27 Jan 2012 03:55:41 +0000 (UTC) From: =?utf-8?Q?S=C3=A9bastien_Brisard_=28Commented=29_=28JIRA=29?= To: issues@commons.apache.org Message-ID: <1155045200.84166.1327636541219.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1208586051.60306.1323466540374.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (MATH-722) [math] Complex Tanh for "big" numbers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-722?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D131944= 19#comment-13194419 ]=20 S=C3=A9bastien Brisard commented on MATH-722: ---------------------------------------- I've run some tests comparing the two formulas: I didn't notice any major d= ifference. Therefore I suggest to stick with the existing formula. Meanwhile, the fix proposed by Juan must be implemented. It can be proved m= athematically that for any value of {{b}}, the value of {{tanh(a + i * b)}}= is within one ulp of 1.0 for {{abs(a) > 18.9}}, so the proposed threshold = (20.0) is fairly safe, and consistent with other parts of CM. Note that the= same fix must be implemented for {{tan}} also. =20 > [math] Complex Tanh for "big" numbers > ------------------------------------- > > Key: MATH-722 > URL: https://issues.apache.org/jira/browse/MATH-722 > Project: Commons Math > Issue Type: Bug > Affects Versions: 2.2 > Environment: I'm working with Eclipse 3.6.2 on Windows XP, but th= e bug is Enviroment independent > Reporter: Juan Barandiaran > Assignee: S=C3=A9bastien Brisard > Priority: Minor > Labels: patch > Fix For: 3.0 > > Original Estimate: 0.25h > Remaining Estimate: 0.25h > > Hi, > In Complex.java the tanh is computed with the following formula: > tanh(a + bi) =3D sinh(2a)/(cosh(2a)+cos(2b)) + [sin(2b)/(cosh(2a)+cos(2b)= )]i > The problem that I'm finding is that as soon as "a" is a "big" number, > both sinh(2a) and cosh(2a) are infinity and then the method tanh returns = in > the real part NaN (infinity/infinity) when it should return 1.0. > Wouldn't it be appropiate to add something as in the FastMath library??: > if (real>20.0){ > return createComplex(1.0, 0.0); > } > if (real<-20.0){ > return createComplex(-1.0, 0.0); > } > Best regards, > JBB -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira