adventures in code coverage: Newton iteration failure

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

adventures in code coverage: Newton iteration failure

In f⍣¯1⊢⍵ (the inverse of f) Newton iteration is employed for certain operands f. The code quits if the iteration still has not converged after 1000 iterations, at which point a DOMAIN ERROR is signaled. For code coverage how is the DOMAIN ERROR to be reached?

`      {11::⍵ ⋄ 0⊣!⍣¯1⊢⍵}¨ 10*90+⍳101E90 1E91 1E92 1E93 1E94 1E95 1E96 0 1E98 0      !⍣¯1 ⊢1e90DOMAIN ERROR      !⍣¯1 ⊢1E90      ∧`

A non-zero value means the Newton iteration ran into trouble, or did not terminate after 1000 iterations. These values serve to reach the DOMAIN ERROR until the time (if ever) when !⍣¯1 is improved. For example:

`      factInv ← {⍵ {⍵-(fx-⍺)÷((!⍵×1+d)-fx←!⍵)÷⍵×d←1e¯6}⍣≡ (!⍳171)⍸⍵}      ⊢ a← factInv¨ 10*90+⍳1064.495 65.0461 65.596 66.1449 66.6926 67.2394 67.785 68.3297 68.8733 69.4159      !a1E90 1E91 1E92 1E93 1E94 1E95 1E96 1E97 1E98 1E99`

By the way:

`      cmpx '!⍣¯1 ⊢100' 'factInv 100'  !⍣¯1 ⊢100   → 9.53E¯4 |   0% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  factInv 100 → 4.88E¯5 | -95% ⎕⎕`
Roger|Dyalog

Posts: 231
Joined: Thu Jul 28, 2011 10:53 am