using pari in giacpy

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

using pari in giacpy

Message par jocaps » jeu. nov. 30, 2017 8:01 pm

Hi,

I am trying to use a pari command in giacpy but I am not able to do this. I am not sure what I am doing wrong. Here is a code where I want initiate the splitting field of a polynomial over the rationals:

Code : Tout sélectionner

from giacpy import giac
giac("pari()")
pari_nfinit=giac("pari_nfinit")
pari_nfinit("x^4-x+1")
The last command delivers "undef" . nfinit is a typical pari command (I could check it by running gp). Any help would be appreciated!

Jose

frederic han
Messages : 1113
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: using pari in giacpy

Message par frederic han » jeu. nov. 30, 2017 10:13 pm

Hello,

this is very indirect to use pari from giac from python, I guess problems will occur.

But here it seem that your problem is just with the way giac prints the powers. (it depends on some settings) and pari doesn't understand **.

Code : Tout sélectionner

>>> from giacpy import giac
// Giac share root-directory:/usr/share/giac/
// Giac share root-directory:/usr/share/giac/
Help file /usr/share/giac/doc/fr/aide_cas not found
Added 0 synonyms
>>> giac("pari()")
"All PARI functions are now defined with the pari_ prefix.
PARI functions are also defined without prefix except:
% abs acos acosh apply arg asin asinh atan atanh binomial bitand bitor bitxor break ceil charpoly concat conj content cos cosh default divisors erfc eval exp factor factorial floor frac gcd global hilbert imag input isprime kill lcm length local matrix max min next nextprime norm plot print printf read real round select shift sign simplify sin sinh solve sqrt subst sum tan tanh taylor trace truncate type until valuation vector version write 
When working with p-adic numbers use them in a pari() call
Type ?pari for short help
Inside xcas, try Help->Manuals->PARI for HTML help"
>>> pari_nfinit=giac('pari_nfinit')
>>> x=giac('x')
>>> giac("printpow(1)")  # trick to force the ^ printing with giac
"^"
>>> P=x**4-x+1
>>> P
x^4-x+1
>>> pari_nfinit(P)
[x^4-x+1,[0,2],229,1,[matrix[[1,-1.01891279438515584478657958863659654800+0.602565419998599026043984421971929910310*i,-0.675098197183678828942622523369462482858+1.22792323178127520618179096233315788890*i,0.727136084491196839976675658674961369087+0.430014288329715776416519858396023127093*i],[1,0.518912794385155844786579588636596547998+0.666609844932018579153758800733003308252*i,0.175098197183678828942622523369462482858-0.691824754796658357872859141951662719018*i,-0.727136084491196839976675658674961369087+0.934099289460529439639030287105823295682*i]],matrix[[1,-0.416347374386556818742595166664666637688,0.552825034597596377239168438963695406043,1.15715037282091261639319551707098449618],[1,-1.62147821438375487083056401060852645831,-1.90302142896495403512441348570262037176,0.297121796161481063560155800278938241994],[1,1.18552263931717442394033838936959985625,-0.516726557612979528930236618582200236160,0.206963204969332599662354628430861926595],[1,-0.147697050546862734367179212096406760254,0.866922951980337186815481665321125201876,-1.66123537395172627961570594578078466477]],matrix[[1,0,1,1],[1,-2,-2,0],[1,1,-1,0],[1,0,1,-2]],matrix[[4,-1,-1,0],[-1,1,1,-4],[-1,1,-3,-1],[0,-4,-1,0]],matrix[[229,58,158,75],[0,1,0,0],[0,0,1,0],[0,0,0,1]],matrix[[55,3,-12,-16],[3,-4,16,-55],[-12,16,-64,-9],[-16,-55,-9,-12]],[229,matrix[[-75,-1,-58,-100],[100,-75,1,57],[58,-158,-233,1],[1,-58,-158,-75]]],[229]],[0.727136084491196839976675658674961369087+0.430014288329715776416519858396023127093*i,-0.727136084491196839976675658674961369087+0.934099289460529439639030287105823295682*i],[1,x^3-1,x^3+x^2-1,x],matrix[[1,0,0,1],[0,0,-1,1],[0,0,1,0],[0,1,0,0]],matrix[[1,0,0,0,0,0,0,-1,0,0,-1,0,0,-1,0,0],[0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,-1],[0,0,1,0,0,-1,-1,0,1,-1,-1,0,0,0,0,1],[0,0,0,1,0,0,-1,0,0,-1,-1,0,1,0,0,0]]]

jocaps
Messages : 118
Inscription : lun. avr. 17, 2017 4:32 pm

Re: using pari in giacpy

Message par jocaps » ven. déc. 01, 2017 7:46 am

Hello,

Thank you Frederic. With your suggestion it works! Maybe this should be documented somewhere. It is a pity if only a selected few know about this.

Jose

Répondre