help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use GNU MP in octave?


From: Keith Goodman
Subject: Re: How to use GNU MP in octave?
Date: Mon, 23 May 2005 20:28:36 -0700

On 5/23/05, lming_44 <address@hidden> wrote:
>     I have a problem in calculating 1000! in octave. By default, octave
> will return "ans=Inf". So I have to write a C program with GNU MP lib.
> It is much more difficult to write a C program. Is there a method to
> calculate very large/small numbers in octave?

You can write a program in Octave.

Here's a quote from google which I found by searching on google
(which, with the growth of google, reminds me of a quote I recently
heard: In a few years you will drive your google to the google to get
some google for your google.) Scarry. By the way Matlab also gives
Inf.

Quote:

The standard trick is to use the logaritm in base 10. 

Let x = lg(8600!). Since lg(xy)=lg(x)+lg(y) you have

x = sum(lg(k),k=1..86000) 

Define floor(x) as the integer part of x. Then 

86000! = 10^(x-floor(x))*10^floor(x). 

You can evaluate x to the degree of accuracy you want, for example, 
using Maple I got:

86000! = 7.91222558*10^372239

The compuation time was close to 0.



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]