From commits-return-70725-archive-asf-public=cust-asf.ponee.io@commons.apache.org Thu Dec 5 16:50:38 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2865118065B for ; Thu, 5 Dec 2019 17:50:38 +0100 (CET) Received: (qmail 83289 invoked by uid 500); 5 Dec 2019 16:50:36 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 83147 invoked by uid 99); 5 Dec 2019 16:50:35 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Dec 2019 16:50:35 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 13F0E8B68F; Thu, 5 Dec 2019 16:50:34 +0000 (UTC) Date: Thu, 05 Dec 2019 16:50:40 +0000 To: "commits@commons.apache.org" Subject: [commons-numbers] 06/08: Fix sinh conjugate and odd equality for infinite real, finite imaginary. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: aherbert@apache.org In-Reply-To: <157556463459.26824.2528166071927218061@gitbox.apache.org> References: <157556463459.26824.2528166071927218061@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: commons-numbers X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Rev: 5af4d3c2ad599fa28a0b7f9a67eda34e1aa682e6 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191205165035.13F0E8B68F@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-numbers.git commit 5af4d3c2ad599fa28a0b7f9a67eda34e1aa682e6 Author: aherbert AuthorDate: Thu Dec 5 12:36:59 2019 +0000 Fix sinh conjugate and odd equality for infinite real, finite imaginary. --- .../java/org/apache/commons/numbers/complex/Complex.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java index aa169e5..f0efa8b 100644 --- a/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java +++ b/commons-numbers-complex/src/main/java/org/apache/commons/numbers/complex/Complex.java @@ -1511,9 +1511,16 @@ public final class Complex implements Serializable { return constructor.create(real, imaginary); } // inf * cis(y) - final double re = real * Math.cos(imaginary); - final double im = real * Math.sin(imaginary); - return constructor.create(re, im); + // ISO C99: Preserve the equality + // sinh(conj(z)) = conj(sinh(z)) + // and the odd function: f(z) = -f(-z) + // by always computing on a positive valued Complex number. + // Math.cos(-x) == Math.cos(x) so ignore sign transform. + final double signIm = imaginary < 0 ? -1 : 1; + final double re = Double.POSITIVE_INFINITY * Math.cos(imaginary); + final double im = Double.POSITIVE_INFINITY * Math.sin(imaginary * signIm); + // Transform back + return constructor.create(real < 0 ? -re : re, im * signIm); } // imaginary is infinite or NaN return constructor.create(Double.POSITIVE_INFINITY, Double.NaN); @@ -1879,7 +1886,7 @@ public final class Complex implements Serializable { *
      * real    imaginary    g(z)
      * +       +            identity
-     * -       +            negateReal
+     * -       +            negateReal (negate && conjugate)
      * +       -            conjugate
      * -       -            negate
      *