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


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

⍝ so its not the ∘. its the 1500

⍝ if it deals with 100↑, maybe its just that 0,⍳1500 is too Long?

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

⍝ maybe 500 is still too long, lets try just 50

⍝ damn it, even 50 elements is too Long

⍝ 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)
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."
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

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

But this one is fast:
Code: Select all

As an aside, not sure what you intend with ⍳1501-1. Do you mean ⍳1500 or ¯1+⍳1500 or ?
Posts: 96
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: 571
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
   me 750 logbc 1500
7.22463 449
   1e5 logbc 1.5e5
   me 1e5 logbc 1.5e5
3.37374 41462
   ⍝ that is,  750!1500 ←→ 7.22463E449  and  1e5!1.5e5 ←→ 3.37374E41462 .
Posts: 232
Joined: Thu Jul 28, 2011 10:53 am

Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest