You're right! The factorial inverse has problems. I had always used it in the simplest case where I want to determine how big a factorial is needed to give desired precision. But now having looked at it more closely it behaves badly around zero and negative numbers. Complex numbers are even stranger. Although it finds inverses that when taken the factorial of gives the original numbers, they are not what you would call "principle values".
I found a way to give the inverse as it works now without using D: or the calculus library. But, like you said, more work needs to be done to make it solid. factinv=:3 : 0 d=: 1 : '0.001%~[:-/[:u 0.001 0+]' (-(!-y"_)%0.001&*!"0 d])^:_<.&170^:(-:+)^.y ) The adverb "d" simply replaces the D: and performs the same function. It need not be a conjunction by removing the 1. Why I think it would be nice to support factorial inverse as a primitive is that it is a good "Oh Wow!" to show off J. Something no other programming language attempts. I'm curious. I will play with this some more. On Tue, Sep 3, 2019 at 8:44 AM Henry Rich <[email protected]> wrote: > If you need the inverse to !, you can use Roger's > > 3 : '(-(!-y"_)%0.001&*!"0 D:1])^:_<.&170^:(-:+)^.y' > > replacing D: with sslope_jcalculus_ (untested). You could even fix it > up to avoid the NaN error. > > Henry Rich > > > > On 9/3/2019 10:39 AM, Don Guinn wrote: > > Well I previously reported it to beta. So here it is again. > > > > To determine the inverse of factorial uses D: . In J807 forcing a > > deliberate error give the following: > > > > ! inv 0.001 > > > > |NaN error > > > > | (-(!-y"_)%0.001&*!"0 D:1])^:_<.&170^:(-:+)^.y > > > > In the middle of the magic function is D: . > > > > JVERSION > > > > Engine: j807/j64/windows > > > > Release-d: commercial/2019-03-18T13:21:35 > > > > Library: 8.07.26 > > > > Qt IDE: 1.7.10/5.9.7 > > > > Platform: Win 64 > > > > Installer: J807 install > > > > InstallPath: c:/j64-807 > > > > Contact: www.jsoftware.com > > > > ! inv 6 > > > > 3 > > > > Works just fine in 807. But in latest beta > > > > ! inv 6 > > > > |domain error > > > > | !inv 6 > > > > JVERSION > > > > Engine: j901/j64avx/windows > > > > Beta-i: commercial/2019-08-29T09:48:23 > > > > Library: 9.01.09 > > > > Qt IDE: 1.8.3/5.12.3 > > > > Platform: Win 64 > > > > Installer: J901 install > > > > InstallPath: c:/j64-j901 > > > > Contact: www.jsoftware.com > > > > > > There is nothing about factorial inverse being dropped in the release > > notes. I don't know if the inverse of factorial should be dropped or not. > > But I have found it quite useful. > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > --- > This email has been checked for viruses by AVG. > https://www.avg.com > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
