On Saturday 03 March 2007 9:40 pm, pdenapo wrote:
> Hi,
>
> I was playing a little with sage, and I've found that there are some
> problems with the interface with gp when dealing with big numbers, due
> to
> the the fact that sage doesn not understand the gp exponential
> notation.
>
> One first example, is the following:
>
> a= factorial(100,'pari'); a
>
> works as expected and gives...
>
> 933262154439441526816992388562667004907159682643816214685929638952175999932
>2991
>
> However, the follwoing example (that should be equivalent), except for
> the
> fact that we are calling the gp interpreter instead of using the pari
> library, does not:
>
> age: b=gp.factorial(100)
> sage: b
> 9.332621544394415268169923886 E157

You are unfortunately confused by GP/PARI being, well, confusing.
The command for integer factorial in PARI is "!", whereas "factorial"
gives the floating point factorial:

sage: gp('100!')
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
sage: gp('factorial(100)')
9.332621544394415268169923886 E157

Thanks for your feedback, and for subscribing to sage-devel.

 -- William

> sage: type(b)
> <class 'sage.interfaces.gp.GpElement'>
> sage: int(b)
> ---------------------------------------------------------------------------
> <type 'exceptions.ValueError'>            Traceback (most recent call
> last)
>
> /hdc1/pablo.hdc1/mathsoft2/sage.new/<ipython console> in <module>()
>
> /hdc1/pablo.hdc1/mathsoft2/sage.new/local/lib/python2.5/site-packages/
> sage/inte
> /in __int__(self)
>     870
>     871     def __int__(self):
> --> 872         return int(str(self))
>     873
>     874     def bool(self):
>
> There are two problems there:
>
> * Python is confused in the conversion by exponential notation
> * precision is lost in a computation with integers (that should be
> exact!)
>
> This problem can be important for the functions in the pari library
> that does not have a direct wrapper (but are calling via gp.* version)
>
> best regards
> Pablo
>
>
> 
-- 
William Stein
Associate Professor of Mathematics
University of Washington

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to