# [Scilab-users] Computing with very large numbers in Scilab

4 messages
Open this post in threaded view
|

## [Scilab-users] Computing with very large numbers in Scilab

 Dear Scilab'ers, Happy New Year. Does someone know to perform in Scilab computations involving very large numbers? For example, the how to compute the following probability formula: 1-365!/((365-23)! *365^23) 1-factorial(365)/(factorial(365-23)* 365^23)   produces Nan in Scilab The correct answer (using Wolfram Alpha) is: 0.507... Thanks and regards Rafael G. _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: Computing with very large numbers in Scilab

 Le 01/01/2015 17:08, Rafael Guerra a écrit : > Dear Scilab'ers, > > Happy New Year. > Does someone know to perform in Scilab computations involving very large > numbers? > For example, the how to compute the following probability formula: > 1-365!/((365-23)! *365^23) > > 1-factorial(365)/(factorial(365-23)* 365^23)   produces Nan in Scilab > The correct answer (using Wolfram Alpha) is: 0.507... >     You should work around the formula such that too large numbers are avoided.    In your case it is easy :        365!/((365-23)! *365^23) = ((365-22)*(365-21)*.......*(365-0))/(365 * 365 * ..... * 365)          =  (343/365)*(344/365)*....*(364/365)*(365/365)   In scilab this can be coded this way :     1 - prod( (343:364)/365 )   hth B. _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: Computing with very large numbers in Scilab

 In reply to this post by Rafael Guerra Hi Rafael, You could use the function gammaln: 1-exp(gammaln(365 + 1)-(gammaln(365 - 23 + 1) + 23*log(365))) Regards, Calixte On 01/01/2015 17:08, Rafael Guerra wrote: > Dear Scilab'ers, > > Happy New Year. > Does someone know to perform in Scilab computations involving very large > numbers? > For example, the how to compute the following probability formula: > 1-365!/((365-23)! *365^23) > > 1-factorial(365)/(factorial(365-23)* 365^23)   produces Nan in Scilab > The correct answer (using Wolfram Alpha) is: 0.507... > > Thanks and regards > Rafael G. > > _______________________________________________ > users mailing list > [hidden email] > http://lists.scilab.org/mailman/listinfo/users-- Calixte Denizet Software Development Engineer ----------------------------------------------------------- Scilab Enterprises 143bis rue Yves Le Coz - 78000 Versailles, France http://www.scilab-enterprises.com_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: Computing with very large numbers in Scilab

 Calixte and Bruno, Thanks for the mathematical insight, and especially for the gammaln function, very good to know. For a general case, do we need to use Scilab's Multiple Precision Arithmetic Toolbox? (which does not seem to work for 64-bits version) Thanks again and regards, Rafael G. -----Original Message----- From: users [mailto:[hidden email]] On Behalf Of Calixte Denizet Sent: Thursday, January 01, 2015 5:05 PM To: [hidden email] Subject: Re: [Scilab-users] Computing with very large numbers in Scilab Hi Rafael, You could use the function gammaln: 1-exp(gammaln(365 + 1)-(gammaln(365 - 23 + 1) + 23*log(365))) Regards, Calixte On 01/01/2015 17:08, Rafael Guerra wrote: > Dear Scilab'ers, > > Happy New Year. > Does someone know to perform in Scilab computations involving very > large numbers? > For example, the how to compute the following probability formula: > 1-365!/((365-23)! *365^23) > > 1-factorial(365)/(factorial(365-23)* 365^23)   produces Nan in Scilab > The correct answer (using Wolfram Alpha) is: 0.507... > > Thanks and regards > Rafael G. > > _______________________________________________ > users mailing list > [hidden email] > http://lists.scilab.org/mailman/listinfo/users-- Calixte Denizet Software Development Engineer ----------------------------------------------------------- Scilab Enterprises 143bis rue Yves Le Coz - 78000 Versailles, France http://www.scilab-enterprises.com_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users