Questions tagged [pari-gp]

Questions about the computer algebra system PARI/GP, including questions about the GP scripting language and the gp interactive shell. Please use the tag [pari] for the PARI C library.

The description in the tag exerpt is a direct quotation from the PARI/GP Development Headquarters, taken on Apr. 5, 2013. This tag is intended for questions about the computer algebra system PARI/GP, including questions about the GP scripting language and the gp interactive shell. See the separate tag for the PARI C library.

114 questions
0
votes
2 answers

Most common term in a vector - PARI/GP

I feel like I'm being really stupid here as I would have thought there's a simple command already in Pari, or it should be a simple thing to write up, but I simply cannot figure this out. Given a vector, say V, which will have duplicate entries, how…
Mystery_Jay
  • 161
  • 5
0
votes
1 answer

Is there a better way to get substring in PARI/gp?

? substr(s,n,m)=concat(Vec(s)[n..n+m-1]) %1 = (s,n,m)->concat(Vec(s)[n..n+m-1]) ? s="h0getcwdfailedNosuchfileordirectory" %2 = "h0getcwdfailedNosuchfileordirectory" ? substr(s,4,8) %3 = "etcwdfai" Question: Is there a better way (built-in…
g.kov
  • 333
  • 2
  • 10
0
votes
1 answer

Copy paste to PARI/GP

I have a text in my notebook and I'd like to copy it to PARI/GP. The text is a little bit long, but I'm not sure if I'm not getting it just because of that. I've tried CTRL C + CTRL V and Copy-Paste and none of them worked. Any suggestions? Thanks…
Anonymous
  • 49
  • 1
  • 9
0
votes
1 answer

Printing what number Pari/GP is working on for a parallel computation

I am using Pari/GP to test (pseudo)primality of a sequence of numbers f(n), where f(n) is some function. I have parallelized the code as test(a) = parfor(n = 1, +oo, if(ispseudoprime(f(n)), print("PRIME "n));) This works very well but I would also…
Ricky
  • 101
  • 3
0
votes
1 answer

pointer optional argument in pari gp functions programming

look at this example please f(a,{e})={ispower(a,3,&e)} i did that to store the result in e but when I in call the function as f(27,t) the program don't store the "3" in t any help
Don Freecs
  • 133
  • 3
0
votes
1 answer

How to obtain the representation of a fraction in a particular base (in GP shell)?

How to obtain the representation of an arbitrary fraction in a particular base? For example, the representation of 1/3 in base 2 should be [[0], [0, 1, 0, 1, 0, 1, ...] But when I type digits(1/3, 2) in GP shell and press Enter, all I see is the…
lyrically wicked
  • 1,185
  • 12
  • 26
0
votes
1 answer

Fastest way to count Goldbach Partitions in Pari/GP

I am trying to calculate the number of Goldbach Partitions and hitting a wall when n is large. Any advice on how I can make this code as fast as possible would be helpful. Here is the best I have been able to do so far: n=1000; x=0; forprime(i=n,…
Goldbug
  • 206
  • 2
  • 8
0
votes
2 answers

Convert a p-adic number to a vector in Pari/GP

I want to extract the elements of a Pari/GP p-adic number to a vector. I.e., if this is my p-adic number: O(5^8)+1/3 > 2 + 3*5 + 5^2 + 3*5^3 + 5^4 + 3*5^5 + 5^6 + 3*5^7 + O(5^8) I want to be able to extract a vector like this: [2,3,1,3,1,3,1,3] Is…
Joe Slater
  • 115
  • 3
0
votes
1 answer

How to modify a Pari code to test a conjecture

liste(lim,mul,base=34,step=5590,offset=588)=my(v=List(),X=mul*base); lim\=1; while(X
0
votes
1 answer

Removing items from a vector in a loop - PARI/GP

I am looking at vectors [a,b,c], for a,b,c in [-1,0,1] along with a function, cycle, which shifts each entry of a vector one to the left: cycle( v ) = [v[3], v[1], v[2]]. I want to only consider vectors such that no two vectors are…
Mystery_Jay
  • 161
  • 5
0
votes
1 answer

How to use PARI/GP for calculating the inverse of a power series?

I want to invert a power series with PARI/GP: if $y=a[1]*x+a[2]*x^2+...+O(x^N)$ is encoded by a given array, say a=vector(N-1), I want PARI to produce the vector b such that $x=b[1]*y+b[2]*y^2+...+O(y^N)$. This can be done using the Bell…
Wolfgang
  • 103
  • 2
0
votes
1 answer

Calling an external function from pari/gp

Is it possible to call the primesieve (Kim Walisch tool), from the pari/gp and pass the value in a variable in pari/gp? I would like to replace the primePi () function with this (as external function, maybe with system("f") command), because the…
0
votes
1 answer

bitcount in PARI/GP

Is there a method to get the position of the most significant bit, that is floor(log(x)/log(2)) + 1? Currently I'm running the following abomination: bitcount(a)={ my(l2, ap, l2ap); if(a == 0, return(0); ); \\ TODO: set upper…
deamentiaemundi
  • 5,502
  • 2
  • 12
  • 20
0
votes
1 answer

In PARI/GP in function FACTOR the -1 is a bug or means somthing else?

First run the function b(n): ? b(n) = lcm(vector(n, i, i))/n After function c(n): ? c(n)=sum(j=1,n,sum(i=1,n,(-1)^(i+j)/(i+j-1))) Last run d(n): ? d(n)=factor(denominator(c(n))/b(n))~ and test with 202 ? d(202) The result is: %8 = [3 7 17 19 31…
0
votes
1 answer

Can you get a list of the powers in a polynomial? Pari GP

I'm working with single variable polynomials with coefficients +1/-1 (and zero). These can be very long and the range of powers can be quite big. It would be convenient for me to view the powers as a vector - is there any way of doing this quickly?…
Mystery_Jay
  • 161
  • 5