[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Large factorials?
From: |
M. Schmidt |
Subject: |
Re: Large factorials? |
Date: |
Thu, 28 Aug 1997 16:16:20 +0200 (MET DST) |
> From address@hidden Thu Aug 28 12:30:05 1997
> From: address@hidden (Ted Harding)
> Subject: Re: Large factorials?
>
[...]
> >
> > Is there an easy way in octave
> > either provided by built-in capabilities,
> > or via programming,
> > or via setup,
> > or via selection of parameters
> > to get large factorials not as floating point numbers
> > but as representation of very long integers.
> >
> > E.g. 50! (or in octave: prod(1:50)) does need more than 60 digits.
> > How can this be handled to output not in floating point numbers
> > but as 60+ digit integer??
> >
[...]
>
> Since 50! > 10^60, the number cannot be represented exactly in 32-bit
> floating point. Therefore you are basically stuck.
>
> In /theory/ it is possible to program "symbolic" arithmetic in octave,
> i.e. (for istance) 123 * 57 could be worked out by breaking it down
> into ["1","2","3","*","5","7"] and feeding this to an octave program which
> would manipulate it and return ["7","0","1","1"], but I wouldn't like to
> do this unless I really had to. However, this would allow you to do
> arbitrary-precision arithmetic within octave.
>
> On my UNIX (actually Linux) system I have the "arbitrary precision
> calculator" called "bc" which is something of a UNIX classic. This is
> ideal for that type of calculation; here is a short "bc" session for 50!
[...snipped...]
Thanks for your fast feedback. Good support on this mailing list :-)
Originally I tried to use output_max_field_width in octave,
but even setting this to e.g. output_max_field_widht=1000
and then doing a prod(1:50) in octave gives a different result than
calculating 50! in bc. How that??
The purpose of the whole thing has been that just for fun I have tried
to check the machine power and to calculate many digits of PI using
Chudnovsky's formula (fine formula, converges linearly, but very fast).
Now I have written it in bc and it's working just fine.
Well, I did know of bc, but originally I have thought octave would be faster,
isn't it?
BTW besides the subject:
Your mail header states that you are using elm pl23. Please be informed that
a long time ago there has been a CERT alert that all elm patchlevels<=24
are vulnerable having a security hole. Take care of this...
Have a nice day
Michael
--
Michael Schmidt address@hidden
SAMBA Admin
Server fuer / Server for MS + Win95 + WinNT + LANManager
Fachhochschule Koblenz