Re: Vectors and integer exponentiation

Bill Allombert <[email protected]>
Newsgroups gmane.comp.mathematics.pari.devel
Message-ID <YzsvLRQ786Xbe9L7@seventeen>
On Mon, Oct 03, 2022 at 11:52:29AM +0200, Martin Becker wrote:
> Hello,
> 
> In GP (tested with versions 2.15.0 and 2.13.1), the expression
> 
>     2^[4,6,8]
> 
> evaluates to a vector of floating point numbers, while
> 
>     [2^n|n<-[4,6,8]]
> 
> evaluates to a vector of integers.
> 
> I would have expected integers in the first case, too,
> or perhaps a type error if exponentiation was not meant to
> auto-unbox vectors.  Is this a bug?

No, this is the consequence of historical design before [<-|] was introduced
that allows transcendental functions to act component-wise on vectors:

? exp([1,2,3])
%6 = [2.7182818284590452353602874713526624978,7.3890560989306502272304274605750078132,20.085536923187667740928529654581717897]

and it happens that 2^[4,6,8] 
do the same thing as
exp(log(2)*[4,6,8])

Cheers,
Bill
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.