[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-commons-dev
Subject: [jira] [Commented] (NUMBERS-22) Method reciprocal() in Complex for complex numbers with parts very c
From: "Eric Barnhill (JIRA)" <jira () apache ! org>
Date: 2017-08-31 8:14:00
Message-ID: JIRA.13065067.1492604649000.167880.1504167240998 () Atlassian ! JIRA
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/NUMBERS-22?page=com.atlassian.jira.plugin. \
system.issuetabpanels:comment-tabpanel&focusedCommentId=16148629#comment-16148629 ]
Eric Barnhill commented on NUMBERS-22:
--------------------------------------
I have looked into this a bit.
There was, it turns out, no C99 standards for the reciprocal.
complex-js, whose formulas are always conformed to standards, was here no help as it \
has no reciprocal function.
The result comes from the lines:
double q = imaginary / real;
double scale = 1. / (imaginary * q + real);
return new Complex(scale, -scale * q);
when the real value is small enough, and imag is zero, q evaluates to 0 and scale to \
negInf. However that last imaginary quantity, -scale*q, evaluates to NaN because in \
Java, zero times inf is Nan.
Any suggestions for the cleanest way to proceed? I can always just check for this \
particular configuration with an if statement.
> Method reciprocal() in Complex for complex numbers with parts very close to 0.0
> -------------------------------------------------------------------------------
>
> Key: NUMBERS-22
> URL: https://issues.apache.org/jira/browse/NUMBERS-22
> Project: Commons Numbers
> Issue Type: Improvement
> Reporter: Gunel Jahangirova
> Priority: Minor
> Fix For: 1.0
>
>
> I have been redirected here from the issue repository of Apache Commons Math, as \
> the Complex class will likely be deprecated in favour of its equivalent in "Commons \
> Numbers". In class Complex method reciprocal() returns INF only if the real and \
> imaginary parts are exactly equal to 0.0. In the cases when real and imaginary \
> parts are double numbers very close to 0.0, it does not hold. For example, if we \
> run this code {code}
> Complex complex0 = new Complex((-2.44242319E-315));
> Complex complex1 = complex0.reciprocal();
> {code}
> the value of complex1.getReal() will be -Infinity and the value of \
> complex1.getImaginary() will be NaN, instead of complex1 being equal to INF. The \
> suggested solutions after the discussion are either checking the equality to ZERO \
> with some tolerance or to detect if one of the real or imaginary parts is going to \
> be infinite or NaN and then return the proper result.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic