Talk:Pascal matrix generation: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎range of numbers: Don't calculate factorials.)
Line 9: Line 9:


Because the Pascal symmetric matrix uses &nbsp; &nbsp; <big>'''i+j'''</big> &nbsp; &nbsp; in the computation of the binomial coefficients (combinations), the calculation of the factorials can exceed the (default) maximum amount for some computer programming languages (number types) unless specified otherwise. &nbsp; I found that with REXX's default digits of &nbsp; '''9''', &nbsp; it lead to generating numbers that weren't integers &nbsp; (close, but no cigar) &nbsp; with a matrix size of &nbsp; '''11'''. &nbsp; It would be interesting to know what the (practical) limitations of each language entry is, if any &nbsp; (as far as generating exact integers). -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 21:07, 16 May 2015 (UTC)
Because the Pascal symmetric matrix uses &nbsp; &nbsp; <big>'''i+j'''</big> &nbsp; &nbsp; in the computation of the binomial coefficients (combinations), the calculation of the factorials can exceed the (default) maximum amount for some computer programming languages (number types) unless specified otherwise. &nbsp; I found that with REXX's default digits of &nbsp; '''9''', &nbsp; it lead to generating numbers that weren't integers &nbsp; (close, but no cigar) &nbsp; with a matrix size of &nbsp; '''11'''. &nbsp; It would be interesting to know what the (practical) limitations of each language entry is, if any &nbsp; (as far as generating exact integers). -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 21:07, 16 May 2015 (UTC)

:If you use the following instead of the factorial version then you can reduce the onset of overflow problems: <math>\frac{n(n-1)(n-2)\ldots(n-k+1)}{k(k-1)(k-2)\ldots 1}</math>
:By calculating the numerator and denominator and comparing them separately to 2<sup>x</sup> you could explore when overflow might affect the calculation. --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 05:50, 17 May 2015 (UTC)

Revision as of 05:50, 17 May 2015

task clarification

When this Rosetta Code task asked     ··· to write functions ···     it seemed to imply to write a function for each form of the Pascal matrices.   Is the coding of a singular function to generate all three forms of Pascal matrices acceptable? -- Gerard Schildberger (talk) 21:07, 16 May 2015 (UTC)

Individual functions was my intention. Is there really that much to gain by having one function parametrised with the output required?
I guess if there is documented language style for having one parameterised function in a similar area then it might be good to reference the standard library function(s) that you copying the style of then have the one function, but three functions is what the task expects. --Paddy3118 (talk) 05:37, 17 May 2015 (UTC)

range of numbers

Because the Pascal symmetric matrix uses     i+j     in the computation of the binomial coefficients (combinations), the calculation of the factorials can exceed the (default) maximum amount for some computer programming languages (number types) unless specified otherwise.   I found that with REXX's default digits of   9,   it lead to generating numbers that weren't integers   (close, but no cigar)   with a matrix size of   11.   It would be interesting to know what the (practical) limitations of each language entry is, if any   (as far as generating exact integers). -- Gerard Schildberger (talk) 21:07, 16 May 2015 (UTC)

If you use the following instead of the factorial version then you can reduce the onset of overflow problems:
By calculating the numerator and denominator and comparing them separately to 2x you could explore when overflow might affect the calculation. --Paddy3118 (talk) 05:50, 17 May 2015 (UTC)