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
9
votes
1 answer

How to make multi-line nested for loops in PARI/GP?

How can I make nested loops in PARI/GP that span multiple lines at each level? I often have to do multiple things inside for loops, and for readability I don't like writing my loops on a single line. For a loop over one variable, I've been doing…
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
7
votes
1 answer

How to use PARI C library

I have already searched for some tutorial on how to use the PARI library in a C program, but unfortunatelly I found nothing but generic tutorials of using the GP package in command line interface. Could anyone help? For instance, I would like to…
nullgeppetto
  • 539
  • 1
  • 8
  • 25
6
votes
3 answers

Calling PARI/GP from Python

I would like to call PARI/GP from Python only to calculate the function nextprime(n) for different ns that I define. Unfortunately I can't get pari-python to install so I thought I would just call it using a command line via os.system in Python. I…
Simd
  • 19,447
  • 42
  • 136
  • 271
3
votes
2 answers

Identify loops over a vector of indices; make list, minus rotations

I work with vectors of natural numbers of length N and sum-of-entries S, for instance, with (N,S)=(4,7) one example vector E=[1,2,1,3] where all entries in the vector are assumed > 0. I want to list all vectors with the same configuration…
3
votes
2 answers

Is there a comfortable way to generate the combinations k out of n in PARI/GP?

Suppose, I have a vector in PARI/GP with n elements. I want to generate the combinations k out of n elements. For example, if the vector is [3,7,11,14,18] and k=3, the output should…
Peter
  • 214
  • 1
  • 10
3
votes
1 answer

Pari/GP: the user defined function as a return value

I have a problem with Pari/GP user defined functions making use of user defined functions returning functions. Here is a dumbed-down example: ? f(x) = { (t) -> x + t } %1 = (x)->(t)->x+t ? g(x) = { local(y); y = f(x); (t) -> y(t) } %2 =…
Alexander Klauer
  • 957
  • 11
  • 18
3
votes
1 answer

Pari/GP: user defined functions

I have defined a couple of functions of arity 1, say func1(-) and func2(-). I have tested them and seen that they actually do what they are supposed to. I wish to define a third function, say func3(-), that outputs the difference of func1(-) and…
absalon
  • 133
  • 1
  • 5
2
votes
1 answer

How to calculate the Modular multiplicative inverse in pari?

The modular multiplicative inverse is an integer ‘x’ such that. a x ≡ 1 (mod m). So, is there any way to calculate the Modular multiplicative inverse in pari\gp calculator ? I am really sorry if this question is trivial or duplicated.
2
votes
1 answer

Simple way to request a factorization over the Gaussians

I work in the Gaussian integers and use factor on them with success. However, occasionally the imaginary part can vanish, but I still want a factorization in the Gaussian integers. As an example, the program for(j=-3, 3, print(j,":…
Jeppe Stig Nielsen
  • 60,409
  • 11
  • 110
  • 181
2
votes
1 answer

Plotting multiple lists in Pari

I have two (pairs of) lists which I want to plot. I know, that I can plot each separably, using the plothraw function. But how can I plot them in the same picture, such that I end up with two curves in different colours?
klirk
  • 127
  • 4
2
votes
1 answer

Function to find the least prime factor

Does PARI/GP have a function for finding the smallest prime factor of a t_INT or otherwise perform a partial factorization of an integer? For example, if I have the…
Jeppe Stig Nielsen
  • 60,409
  • 11
  • 110
  • 181
2
votes
1 answer

How to construct fields in bnfinit()?

I am new to PARI/GP, learning about different number fields. I am trying to construct the field k = Q(\zeta_23) using bnfinit (23rd cyclotomic field) to run the following script: v=[]; w=[]; j=0; l=0; forprime(p=29, 100000, { if(p%46==1, j++;…
J. Linne
  • 275
  • 4
  • 15
2
votes
1 answer

Radiroot package in GAP generating errors

When I run the following commands g := UnivariatePolynomial(Rationals, [12,-5,0,0,0,1]); RootsOfPolynomialAsRadicals(g); I get this error *** too many arguments: ...;,nf=nfinit([f,nfbasis(f,1)]);fac=lift(nffact *** …
Ben
  • 470
  • 1
  • 6
  • 18
2
votes
3 answers

Finding entry of vector in PARI/GP?

With PARI/GP, if I have a vector with unique entries: a = [9, 7, 3, 5, 2, 8, 1, 0, 11] how do I get the position (index) of an entry in the vector a? like: i = vectorsearch(a, 8); a[i] %1 = 8 Converting into a set and using setsearch doesn't…
Ystar
  • 351
  • 1
  • 3
  • 8
2
votes
2 answers

How do I declare and call array in PARI/GP?

How do I declare and call array in PARI/GP? For example, I have the following in java: int[] myArray = new int[5]; for(int i = 0; i < 5; i++){ myArray[i] = i + 5; } How do I do the same thing while using PARI/GP?
geeceekay
  • 67
  • 8
1
2 3 4 5 6 7 8