Page 1 of 1

reciprocal of a complex number

Posted: Mon Sep 19, 2011 2:31 pm
by giangiquario
In Dyalog 13.0

Code: Select all

     ÷ .5E160J.5e160
DOMAIN ERROR
      ÷5E159J5E159
     ∧


I think that it is a overflow pitfall.

I suggest to change the implementation of "reciprocal" into the interpreter.
For example you could do something like :

Code: Select all

Reci←{
     ReIm←{9 11○⍵}⍵
     recip←{>/|⍵:{q←÷/⌽⍵ ⋄ 1(-q)÷+/⍵×1 q}⍵
         {q←÷/⍵ ⋄ q ¯1÷+/⍵×q 1}⍵}ReIm ⍝(avoiding overflow)
     {+/1 0J1×⍵}recip
 }


In fact:

Code: Select all

     Reci .5E160J.5e160
1E¯160J¯1E¯160

Re: reciprocal of a complex number

Posted: Tue Sep 20, 2011 1:42 pm
by Jay|Dyalog
Well spotted! I have raised this as issue 7628.

A very simple work around is to use divide instead of reciprocal:

Code: Select all

      1÷.5E160J.5e160
1E¯160J¯1E¯160


Thanks,
Jay.