t=x^4+24*x^2+585*x+1791;nf=initalgred(t);A=nf[1]
%1 = x^4 - x^3 - 21*x^2 + 17*x + 133
th=initalgred2(t)
%2 = mod(x^2 + x - 11, x^4 - x^3 - 21*x^2 + 17*x + 133)
alp=modreverse(th)
%3 = mod(-1/147*x^3 - 1/147*x^2 + 8/49*x - 138/49, x^4 + 24*x^2 + 585*x + 1791)
u=mod(x^3-5*x^2-8*x+56,A)/7
%4 = mod(1/7*x^3 - 5/7*x^2 - 8/7*x + 8, x^4 - x^3 - 21*x^2 + 17*x + 133)
u^3
%5 = mod(-1, x^4 - x^3 - 21*x^2 + 17*x + 133)
1/u
%6 = mod(-1/7*x^3 + 5/7*x^2 + 8/7*x - 7, x^4 - x^3 - 21*x^2 + 17*x + 133)
norm(u)
%7 = 1
pol=char(u,x)
%8 = x^4 - 2*x^3 + 3*x^2 - 2*x + 1
minpol=pol/gcd(pol,pol')
%9 = x^2 - x + 1
galois(A)
%10 = [8, -1, 1]
gc=galoisconj(nf)
%11 = [x, 0, -1/7*x^3 + 5/7*x^2 + 1/7*x - 7, 0]
aut=gc[3]
%12 = -1/7*x^3 + 5/7*x^2 + 1/7*x - 7
char(mod(aut,A),x)
%13 = x^4 - x^3 - 21*x^2 + 17*x + 133
pd=primedec(nf,7)
%14 = [[7, [0, 1, 0, 0]~, 1, 1, [3, 1, -3, 0]~], [7, [2, 0, 0, 1]~, 1, 1, [1, 3, 5, 5]~], [7, [-1, -3, 0, 1]~, 1, 1, [6, 2, 3, 2]~], [7, [-2, 1, 0, 0]~, 1, 1, [0, 3, -1, 0]~]]
pr1=pd[1]
%15 = [7, [0, 1, 0, 0]~, 1, 1, [3, 1, -3, 0]~]
hp=idealmul(nf,idmat(4),pr1)
%16 = 
[7 0 0 3]

[0 1 0 0]

[0 0 1 0]

[0 0 0 1]

hp3=idealmul(nf,hp,idealmul(nf,hp,hp))
%17 = 
[343 28 245 290]

[0 1 0 0]

[0 0 1 0]

[0 0 0 1]

\\ or hp3=idealpow(nf,hp,3)
for(j=1,4,print(idealval(nf,hp3,pd[j])))
3
0
0
0
hpi3=[hp3,[0.,0.]];hr1=ideallllred(nf,hpi3,0)
%18 = [[7, 0, 0, 3; 0, 7, 0, 1; 0, 0, 7, 5; 0, 0, 0, 1], [-4.085702385516797582107781425 + 6.119327347678028563112407553*i, -3.697938210704455638313629547 - 0.9243603728874249447769451134*i]]
hr=hr1;for(j=1,3,hr=ideallllred(nf,hr,[1,5]);print(hr))
[[13, 0, 0, 10; 0, 13, 0, 2; 0, 0, 13, 11; 0, 0, 0, 1], [-11.08019657445019643233443616 + 0.5713014921172203398445403919*i, -5.106123826398533439456520476 + 4.181407879830437973455329286*i]]
[[7, 0, 6, 0; 0, 7, 2, 0; 0, 0, 1, 0; 0, 0, 0, 7], [-18.57040515282912967439530292 + 1.598260473179652104337195512*i, -7.256673469459523710661468786 + 0.07725564640791804240906371216*i]]
[[7, 0, 0, 3; 0, 7, 0, 1; 0, 0, 7, 5; 0, 0, 0, 1], [-24.58749563430444214291782212 + 2.522802228940798887773275272*i, -9.023223584205464462560360559 - 0.3320952868382636354992195499*i]]
arch=hr[2]-hr1[2];l1=arch[1];l2=arch[2];
s=real(l1+l2)/4;v1=[l1,l2,conj(l1),conj(l2)]~/2-[s,s,s,s]~
%20 = [-3.794126968821658934140827422 - 1.798262559368614837669566140*i, 3.794126968821658934140827421 + 0.2961325430245806546388627817*i, -3.794126968821658934140827422 + 1.798262559368614837669566140*i, 3.794126968821658934140827421 - 0.2961325430245806546388627817*i]~
m1=nf[5][1];m=matrix(4,4,j,k,if(j<=2,m1[j,k],conj(m1[j-2,k])));
v=exp(v1);au=gauss(m,v)
%22 = [-79.00000000000000000000000005 - 1.615587133448570966000000000 E-27*i, 24.00000000000000000000000002 - 2.274377438239753246000000000 E-27*i, 14.00000000000000000000000000 +  0.E-27*i, -15.00000000000000000000000001 +  0.E-27*i]~
vu=round(real(au))
%23 = [-79, 24, 14, -15]~
u=mod(nf[7]*vu,A)
%24 = mod(-15/7*x^3 + 68/7*x^2 + 78/7*x - 79, x^4 - x^3 - 21*x^2 + 17*x + 133)
norm(u)
%25 = 1
f1=factor(subst(char(u,x),x,x^2))
%26 = 
[x^4 + 13*x^3 + 42*x^2 - 8*x + 1 1]

[x^4 - 13*x^3 + 42*x^2 + 8*x + 1 1]

v=sqrt(v)
%27 = [0.09334880794728281557422432615 - 0.1174246256960511585313775710*i, 6.593348807947282815574224325 + 0.9834500294804898052951007425*i, 0.09334880794728281557422432615 + 0.1174246256960511585313775710*i, 6.593348807947282815574224325 - 0.9834500294804898052951007425*i]~
au=gauss(m,v)
%28 = [-4.079490831526613599392561952 +  0.E-28*i, 0.9623261373956720055191059527 + 1.776857373304665088000000000 E-29*i, 1.007652680516380682499122747 + 5.456055251881480216000000000 E-29*i, -0.9733355227802970462076159317 - 6.445153582841157913000000000 E-29*i]~
v[1]=-v[1];v[3]=-v[3];au=gauss(m,v)
%29 = [-4.000000000000000000000000005 - 4.038967832922935485000000000 E-28*i, 1.000000000000000000000000001 - 5.330572120845317840000000000 E-29*i, 1.000000000000000000000000000 + 5.456055251881480216000000000 E-29*i, -1.000000000000000000000000000 - 4.296769056469202041000000000 E-29*i]~
vu2=round(real(au))
%30 = [-4, 1, 1, -1]~
u2=mod(nf[7]*vu2,A)
%31 = mod(-1/7*x^3 + 5/7*x^2 + 1/7*x - 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
q=polred2(f1[1,1])
%32 = 
[1 x - 1]

[-1/7*x^3 - 2*x^2 - 7*x + 8/7 x^2 - x + 1]

[-x - 3 x^4 - x^3 - 21*x^2 + 17*x + 133]

[-4/7*x^3 - 7*x^2 - 21*x + 32/7 x^4 - 2*x^3 + 6*x^2 - 5*x + 133]

up2=modreverse(mod(q[3,1],f1[1,1]))
%33 = mod(-x - 3, x^4 - x^3 - 21*x^2 + 17*x + 133)
mod(subst(lift(up2),x,aut),A)
%34 = mod(1/7*x^3 - 5/7*x^2 - 1/7*x + 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
r=f1[1,1]%(x^2-u);-coeff(r,0)/coeff(r,1)
%35 = mod(1/7*x^3 - 5/7*x^2 - 1/7*x + 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
al=mod(x^2-9,A)
%36 = mod(x^2 - 9, x^4 - x^3 - 21*x^2 + 17*x + 133)
principalidele(nf,al)
%37 = [[-9; 0; 1; 0], [4.071180332419999163417166456 - 2.351990513650678045072327170*i, -0.1793600343093725532064609704 + 1.836799691135712939544530673*i]~]
for(j=1,4,print(j,": ",idealval(nf,al,pd[j])))
1: 0
2: 1
3: 1
4: 0
norm(al)
%38 = 49
pd23=idealmul(nf,pd[2],pd[3])
%39 = 
[7 4 5 0]

[0 1 0 0]

[0 0 1 0]

[0 0 0 7]

idealmul(nf,al,idmat(4))
%40 = 
[7 4 5 0]

[0 1 0 0]

[0 0 1 0]

[0 0 0 7]

setrand(1);v=buchgenfu(A)[,1]
%41 = [x^4 - x^3 - 21*x^2 + 17*x + 133, [0, 2], [18981, 7], [1, x, x^2, 1/7*x^3 + 2/7*x^2 - 1/7*x], [4, [4], [[7, 0, 6, 0; 0, 7, 2, 0; 0, 0, 1, 0; 0, 0, 0, 7]]], 3.794126968821658934140827422, 0.8807495110615015829159599180, [6, 1/7*x^3 - 5/7*x^2 - 8/7*x + 8], [1/7*x^3 - 5/7*x^2 - 1/7*x + 4], 105]
uf=mod(v[9][1],A)
%42 = mod(1/7*x^3 - 5/7*x^2 - 1/7*x + 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
uu=mod(v[8][2],A)
%43 = mod(1/7*x^3 - 5/7*x^2 - 8/7*x + 8, x^4 - x^3 - 21*x^2 + 17*x + 133)
cu2=log(conjvec(u2));cuf=log(conjvec(uf));cuu=log(conjvec(uu));
lindep(real([cu2[1],cuf[1],cuu[1]]))
%45 = [0, 0, 1]
lindep([cu2[1],cuf[1],cuu[1],2*i*pi])
%46 = [1, -1, -3, 0]
uf*uu^3
%47 = mod(-1/7*x^3 + 5/7*x^2 + 1/7*x - 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
ru=nf[8]*vvector(4,j,coeff(v[8][2],j-1))
%48 = [8, -2, -1, 1]~
mod(nf[7]*ru,A)
%49 = mod(1/7*x^3 - 5/7*x^2 - 8/7*x + 8, x^4 - x^3 - 21*x^2 + 17*x + 133)
setrand(1);bnf=buchinitfu(A);
bnf[8]
%51 = [[4, [4], [[7, 0, 6, 0; 0, 7, 2, 0; 0, 0, 1, 0; 0, 0, 0, 7]]], 3.794126968821658934140827422, 0.8807495110615015829159599180, [6, 1/7*x^3 - 5/7*x^2 - 8/7*x + 8], [1/7*x^3 - 5/7*x^2 - 1/7*x + 4], 105]
nf=bnf[7];
hp4=idealpow(nf,hp,4)
%53 = 
[2401 1743 1617 2320]

[0 1 0 0]

[0 0 1 0]

[0 0 0 1]

vis=isprincipalgen(bnf,hp4)
%54 = [[0]~, [-20, 4, 3, -2]~, 96]
alpha=mod(nf[7]*vis[2],A)
%55 = mod(-2/7*x^3 + 17/7*x^2 + 30/7*x - 20, x^4 - x^3 - 21*x^2 + 17*x + 133)
norm(alpha)
%56 = 2401
idealhermite(nf,alpha)
%57 = 
[2401 1743 1617 2320]

[0 1 0 0]

[0 0 1 0]

[0 0 0 1]

vit=isprincipalgen(bnf,hp)
%58 = [[3]~, [-20/343, 4/343, 3/343, -2/343]~, 80]
pp=isprincipalgen(bnf,pd23)
%59 = [[0]~, [-40, 7, 6, -7]~, 97]
al2=mod(nf[7]*pp[2],A)
%60 = mod(-x^3 + 4*x^2 + 8*x - 40, x^4 - x^3 - 21*x^2 + 17*x + 133)
u3=al2/al
%61 = mod(-1/7*x^3 + 5/7*x^2 + 1/7*x - 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
char(u3,x)
%62 = x^4 - 13*x^3 + 42*x^2 + 8*x + 1
me=concat(bnf[3],[2,2]~)
%63 = 
[-3.794126968821658934140827422 - 1.798262559368614837669566140*i 2]

[3.794126968821658934140827422 - 5.987052764155005822286423985*i 2]

cu3=principalidele(nf,u3)[2]
%64 = [-3.794126968821658934140827422 + 4.484922747810971639255720625*i, 3.794126968821658934140827422 + 0.2961325430245806546388627815*i]~
xc=gauss(real(me),real(cu3))
%65 = [1.000000000000000000000000000,  0.E-38]~
xd=cu3-me*xc
%66 = [-1.175494350492954254000000000 E-38 + 6.283185307179586476925286766*i, 1.175494350492954254000000000 E-38 + 6.283185307179586476925286766*i]~
xu=principalidele(nf,uu)[2]
%67 = [3.190917410306750285830286471 E-124 + 2.094395102393195492308428922*i, 4.727285052306296719748572550 E-125 - 2.094395102393195492308428922*i]~
xd[1]/xu[1]
%68 = 3.000000000000000000000000000 + 5.612572094425559043000000000 E-39*i
isunit(bnf,u3)
%69 = [1, mod(3, 6)]
uu^3*uf
%70 = mod(-1/7*x^3 + 5/7*x^2 + 1/7*x - 4, x^4 - x^3 - 21*x^2 + 17*x + 133)
\q
Good bye!
