Domain error on binomial ( "!" )

General APL language issues

Domain error on binomial ( "!" )

Postby tclviii-dyalog on Wed Feb 12, 2020 7:30 pm

so I tried this and got a domain error

temp∘.!temp←0,⍳1501-1
DOMAIN ERROR
temp∘.!temp←0,⍳1501-1

⍝ hmmm, is the ∘. too big? if so why domain and not wsfull?


sink←(0,⍳1500)!1500
DOMAIN ERROR
⍝ so its not the ∘. its the 1500

sink←(100↑0,⍳1500)!1500
⍝ if it deals with 100↑, maybe its just that 0,⍳1500 is too Long?

sink←(¯100↑0,⍳1500)!1500
⍝ and same here, ¯100↑0,⍳1500 ok, maybe I can do this in chunks?

sink←(¯500↓500↓,⍳1500)!1500
DOMAIN ERROR
⍝ maybe 500 is still too long, lets try just 50

sink←(¯725↓725↓,⍳1500)!1500
DOMAIN ERROR
sink←(¯725↓725↓,⍳1500)!1500
⍝ damn it, even 50 elements is too Long

sink←(750)!1500
DOMAIN ERROR
⍝ double daggummit! even 1 number is too much!?!?!?


i s'pose there are lots more ways to choose from the middle of the 1500th line
of pascals triangle than either end of the 1500th line, i.e lots more ways to chose
750 out of 1500 than 100 out of 1500 ... maybe domain error means it's that
the middle choices are too big an INTEGER?

but it that is the case (it's to big an INTEGER), how can I get at least a
floatingpoint approximation to 750!1500 (or better yet even 5000!10000)
tclviii-dyalog
 
Posts: 14
Joined: Tue Mar 02, 2010 6:04 pm

Re: Domain error on binomial ( "!" )

Postby tclviii-dyalog on Thu Feb 13, 2020 5:55 am

Actually, when I said:

"i.e lots more ways to chose 750 out of 1500 than 100 out of 1500" ....

I may have I got that totally backwards ... The number of ways to take 750things out of 1500things at least SEEMS to be a far more constrained problem than taking 100things out of 1500things

on the other hand, the numbers in the middle of Pascal's triangle are always bigger than the numbers at the edges... I probably should stop trying to do APL while I'm drinking Frozen Irish coffees on "Mercredi avant Mercredi Gras" in the window at Molly's (see "New Orleans Mon Amour" chapter on Molly's):

"We hung out endlessly at Molly’s under the kind but no-nonsense auspices of Jim Monaghan, whose sharp Irish wit and shrewd business sense added the necessary realism to our flights of fancy. Molly’s was home to the demimonde, to artists, journalists, retired teachers, lawyers, politicians, cops, and people of uncertain description ...
... During the dire days of Katrina and its aftermath, while the whole city, except for a few areas, lay underwater, Jim kept Molly’s open. Huddling there, without electricity or working phones, the surviving tribes of the French Quarter drank liquor without ice and defied orders to abandon the city."
tclviii-dyalog
 
Posts: 14
Joined: Tue Mar 02, 2010 6:04 pm

Re: Domain error on binomial ( "!" )

Postby petermsiegel on Thu Feb 13, 2020 6:05 am

Have you tried ⎕FR←1287? ⍝ Was: 645
Your results will have exponents that are too large for 64-bit floats (≥ about 1.8E308).
128-bit decimals allow exponents up to 1E6145.
Code: Select all
      ⎕FR←1287
      750!1500
7.224628924E449

Some of your calculations will take a long time with ⎕FR←1287.

But this one is fast:
Code: Select all
      ⎕FR←1287 
      5000!10000
1.591790264E3008


As an aside, not sure what you intend with ⍳1501-1. Do you mean ⍳1500 or ¯1+⍳1500 or ?
petermsiegel
 
Posts: 77
Joined: Thu Nov 11, 2010 11:04 pm

Re: Domain error on binomial ( "!" )

Postby Phil Last on Thu Feb 13, 2020 9:21 am

User avatar
Phil Last
 
Posts: 543
Joined: Thu Jun 18, 2009 6:29 pm

Re: Domain error on binomial ( "!" )

Postby Roger|Dyalog on Thu Feb 13, 2020 6:12 pm

For the really large binomial coefficients, have you tried working with their logarithms? For example:

Code: Select all
   logbc ← {⎕io←1 ⋄ (+/10⍟⍳⍵)-(+/10⍟⍳⍵-⍺)++/10⍟⍳⍺}    ⍝ 10⍟⍺!⍵
   me    ← {(10*1|⍵),⌊⍵}    ⍝ mantissa and exponent from base 10 log

   750 logbc 1500
449.859
   me 750 logbc 1500
7.22463 449
   1e5 logbc 1.5e5
41462.5
   me 1e5 logbc 1.5e5
3.37374 41462
   ⍝ that is,  750!1500 ←→ 7.22463E449  and  1e5!1.5e5 ←→ 3.37374E41462 .
Roger|Dyalog
 
Posts: 205
Joined: Thu Jul 28, 2011 10:53 am


Return to Language

Who is online

Users browsing this forum: No registered users and 0 guests