# commons-issues mailing list archives

##### Site index · List index
Message view
Top
From "Raymond DeCampo (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (MATH-1414) Method reciprocal() in Complex for complex numbers with parts very close to 0.0
Date Wed, 19 Apr 2017 11:48:42 GMT
```
[ https://issues.apache.org/jira/browse/MATH-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15974486#comment-15974486
]

Raymond DeCampo commented on MATH-1414:
---------------------------------------

0.01 is way too large of a tolerance.

I think a better approach would be to detect if one of the real or imaginary parts is going
to be infinite or NaN and then return the proper result.  We need to determine what the desired
result in this situation is, e.g. in the example above one could make a case for {{Complex.INF}};
{{Double.NEGATIVE_INFINTITY}} or {{Double.POSITIVE_INFINITY}} (where the last two have imaginary
part zero).

> Method reciprocal() in Complex for complex numbers with parts very close to 0.0
> -------------------------------------------------------------------------------
>
>                 Key: MATH-1414
>                 URL: https://issues.apache.org/jira/browse/MATH-1414
>             Project: Commons Math
>          Issue Type: Improvement
>            Reporter: Gunel Jahangirova
>            Priority: Minor
>
> 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.
> I think the code in the method
> {code}
> if (real == 0.0 && imaginary == 0.0) {
>       return INF;
> }
> {code}
> should be replaced by the equality check with some tolerance (0.01 in this case):
> {code}
> if (equals(this, ZERO, 0.01)) {
>      return INF;
> }
> {code}

--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

```
Mime
View raw message