\documentclass{beamer}

\mode<presentation> {
  \usetheme{Montpellier}
  \setbeamercovered{transparent}
}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{times,url,tikz, tikz-cd}
\usepackage[T1]{fontenc}
\newcommand{\Cl}{\mathcal{C}\ell}
\newcommand{\N}{\mathcal{N}}
\renewcommand{\P}{\mathcal{P}}
\renewcommand{\O}{\mathcal{O}}
\newcommand{\p}{\mathfrak{p}}
\newcommand{\f}{\mathfrak{f}}
\renewcommand{\L}{\mathcal{L}}
\renewcommand{\S}{\mathfrak{S}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\PP}{\mathbb{P}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\FF}{\mathbb{F}}
\renewcommand{\d}{\mathrm{d}}
\newcommand{\Gal}{\mathrm{Gal}}
\newcommand{\frob}[2]{\left(\frac{#1}{#2}\right)}
\newcommand{\val}{v}
%\renewcommand{\theorem}{}
\newtheorem{defi}{Définition}
\newtheorem{theorema}{Théorème}
\newtheorem{lemmaa}[theorem]{Lemme}
\newtheorem{remark}[theorem]{Remarque}
\newtheorem{princip}[theorem]{Principe}
\newtheorem{algorithm}[theorem]{Algorithme}
\renewcommand{\theorem}{\theorema}
\renewcommand{\lemma}{\lemmaa}
\newcommand{\kbd}[1]{\texttt{#1}}

\title{Some new GP features}
\subtitle{A tutorial}

\author{B.~Allombert}
\institute
{
  IMB \\
  CNRS/Université de Bordeaux
}

\date{14/01/2019}

%\subject{Exposé}
%\logo{\pgfimage[height=1cm]{um2.png}}
%\logo{\pgfuseimage{um2}}
%\logo{\includegraphics[height=1.5cm]{um2.png}}
%\AtBeginSubsection[] {
%  \begin{frame}<beamer>{Lignes directrices}
%    \tableofcontents[currentsection,currentsubsection]
%  \end{frame}
%}

%\beamerdefaultoverlayspecification{<+->}

\begin{document}
\begin{frame}
  \titlepage
\input ../opendreamkit.tex
\end{frame}

%\begin{frame}
%  \tableofcontents
%  % Vous pouvez, si vous le souhaiter ajouter l'option [pausesections]
%\end{frame}

\section{New I/O interface}
\begin{frame}[fragile]{fileopen}
GP provides a new I/O interface that mirrors the C interface and is faster.
Files are opened with \kbd{fileopen} and closed with \kbd{fileclose}.

To create a file with the power of $2$ on separated lines:
\begin{verbatim}
? n = fileopen("myfile","w");
? for(i=1,10,filewrite(n,2^i));
? fileclose(n)
\end{verbatim}

to read a file physical line by physical line:

\begin{verbatim}
? n = fileopen("myfile");
? while (l = filereadstr(n), print(l))
? fileclose(n)
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{fileextern}
to read a file logical line by logical line:

\begin{verbatim}
? n = fileopen("myfile");
? while (l = fileread(n), print(l))
? fileclose(n)
\end{verbatim}

to read "ls" output line by line:

\begin{verbatim}
? n = fileextern("ls /");
? while (l = filereadstr(n), print(l))
? fileclose(n)
\end{verbatim}

\end{frame}
\begin{frame}[fragile]{forprimestep}
To loop over prime number in an arithmetic progression:
\begin{verbatim}
? forprimestep(p = 2, 50, Mod(1,5), print(p))
\end{verbatim}
  \begin{verbatim}
11
31
41
  \end{verbatim}
For consistency, \kbd{forstep} also allow this:
\begin{verbatim}
? forstep(p = 2, 20, Mod(1,5), print(p))
\end{verbatim}
  \begin{verbatim}
6
11
16
  \end{verbatim}
\end{frame}

\begin{frame}[fragile]{forsquarefree}
\kbd{forsquarefree} is identical to \kbd{forfactored} except
that it only loops over squarefree numbers
\begin{verbatim}
? forsquarefree(N=1,10,print(N))
\end{verbatim}
  \begin{verbatim}
[1,matrix(0,2)]
[2,Mat([2,1])]
[3,Mat([3,1])]
[5,Mat([5,1])]
[6,[2,1;3,1]]
[7,Mat([7,1])]
[10,[2,1;5,1]]
  \end{verbatim}
\end{frame}

\begin{frame}[fragile]{forsquarefree}
\begin{verbatim}
? my(s=0.);forsquarefree(N=1,10^6, \
  s+=moebius(N)/N[1]^2);s
%16 = 0.60792710204046183281498023606240746441
? ##
  ***   last result computed in 729 ms.
? my(s=0.);forfactored(N=1,10^6, \
  s+=moebius(N)/N[1]^2);s
%17 = 0.60792710204046183281498023606240746441
? ##
  ***   last result computed in 1,060 ms.
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{factor}
\kbd{factor} allows now to specify the factorisation domain as a second parameter.
\begin{verbatim}
? factor(x^4+1)
%18 = Mat([x^4+1,1])
? factor(x^4+1,I)
%19 = [x^2-I,1;x^2+I,1]
? factor(x^4+1,Mod(1,3))
%20 = [Mod(1,3)*x^2+Mod(1,3)*x+Mod(2,3),1;Mod(1,3)*x^2+Mod(2,3)*x+Mod(2,3),1]
? factor(x^4+1,ffgen(9,'a))
%21 = [x+a,1;x+(a+1),1;x+2*a,1;x+(2*a+2),1]
? factor(x^4+1,Mod(a,a^2-2))
%22 = [x^2+Mod(-a,a^2-2)*x+1,1;x^2+Mod(a,a^2-2)*x+1,1]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{factormod}
factormod and polrootsmod now handle finite fields too:
\begin{verbatim}
? a=ffgen(3^2,'a);
? factormod((x^4+1)*Mod(1,3))
%24 = [Mod(1,3)*x^2+Mod(1,3)*x+Mod(2,3),1;Mod(1,3)*x^2+Mod(2,3)*x+Mod(2,3),1]
? factormod(x^4+1,3)
%25 = [Mod(1,3)*x^2+Mod(1,3)*x+Mod(2,3),1;Mod(1,3)*x^2+Mod(2,3)*x+Mod(2,3),1]
? factormod((x^4+1)*a^0)
%26 = [x+a,1;x+(a+1),1;x+2*a,1;x+(2*a+2),1]
? factormod(x^4+1,a)
%27 = [x+a,1;x+(a+1),1;x+2*a,1;x+(2*a+2),1]
? polrootsmod(x^4+1,a)
%28 = [a,a+1,2*a,2*a+2]~
? polrootsmod((x^4+1)*a^0)
%29 = [a,a+1,2*a,2*a+2]~
\end{verbatim}
\end{frame}
\begin{frame}[fragile]{factormodSQF, factormodDDF}
idem but return the square free factorization (resp. the distinct degree
factorization):

\begin{verbatim}
? factormodSQF(x*(x+1)*(x^2+1)^2,3)
%30 = [x^2+x,1;x^2+1,2]
? factormodDDF((x^4+1)*(x^2+a))
%31 = [x^4+1,1;x^2+a,2]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{plotexport}
The functions \kbd{plothexport} and \kbd{plotexport} 
return a string that is the SVG or PostScript representation of the plot.
\begin{verbatim}
? write("sin.svg",plothexport("svg",x=0,1,sin(x)))
? plotinit(1);plotmove(1,10,10);plotrbox(1,20,20);
? plotexport("ps",1)
%34 = "%!\n50 50 translate\n/p {moveto 0 2 rlineto
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{plotcolor}
\kbd{plotcolor} allows to specify arbitrary colors:
\begin{verbatim}
? {
  plotinit(1);
  plotcolor(1,"#003399");
  plotbox(1,600,400,1);
  plotcolor(1,"#ffcc00");
  for(j=0,11,
    plotmove(1,300+130*cos(2*Pi*j/12),
               200-130*sin(2*Pi*j/12));
    for(i=0,4,
      plotrline(1,cos(2*Pi*3*i/5)*40,
                 -sin(2*Pi*3*i/5)*40)));
  plotdraw([1,0,0]);
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{string functions}
The function \kbd{Strchr}, \kbd{Strexpand}, \kbd{Strprintf}, \kbd{Strtex}
has been renamed to \kbd{strchr}, \kbd{strexpand}, \kbd{strprintf}, \kbd{strtex}.

Two new functions have been added:
\begin{verbatim}
? strsplit("a,b,c,d",",")
%36 = ["a","b","c","d"]
? strjoin(["a","b","c"],":")
%37 = "a:b:c"
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{galoisgetname}
\kbd{galoisgetname(o,n)} returns a string describing the group
of order $o$ and index $n$ in the GAP4 library of small groups.
\begin{verbatim}
? N = galoisgetgroup(12); \\ # of abstract groups
? for(i=1, N, print(i,":",galoisgetname(12,i)))
\end{verbatim}
  \begin{verbatim}
1:C3 : C4
2:C12
3:A4
4:D12
5:C6 x C2
  \end{verbatim}
\end{frame}

\begin{frame}[fragile]{galoisgetgroup}
\kbd{galoisgetgroup(o,n)} returns the corresponding abstract group.
\begin{verbatim}
? G=galoisgetgroup(12,3);
? [T,o]=galoischartable(G);
? T~
%42 =
%[1    1    1  1]
%[1 -y-1    y  1]
%[1    y -y-1  1]
%[3    0    0 -1]
\end{verbatim}
\end{frame}


\begin{frame}[fragile]{qfbsolve}
\kbd{qfbsolve(q,n)} now accept non-prime $n$ and returns all the solutions up to
units of positive norms.
\begin{verbatim}
? qfbsolve(Qfb(1,0,1),65)
%43 = [[8,-1],[7,4],[7,-4],[-8,-1]]
? qfbsolve(Qfb(1,1,-1),-1)
%44 = [[0,1]]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{hypergeom}
\kbd{hypergeom} allow to compute hypergeometric functions
$\displaystyle hypergeom([a_1,...,a_p],[b_1,...,b_q],z) = \sum_{n=0}^{\infty}
\frac{\prod_{i=1}^p(a_i)_n}{\prod_{j=1}^q(b_j)_n}\*(z^n)/(n!)$
\begin{verbatim}
? hypergeom([],[],2)
%45 = 7.3890560989306502272304274605750078132
? f(z)=hypergeom([1,2],[3],z);
? lindep([f(1/2),f'(1/2),f''(1/2)])
%47 = [-8,4,1]~
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{airy}
\kbd{airy} allow to compute the Airy functions $Ai$ and $Bi$ which gives a basis of solutions of
the differential equation $y''=x\*y$.
\begin{verbatim}
? airy(2)
%48 = [0.03492413042327437914,3.298094999978214710]
? airy''(2)/2
%49 = [0.03492413042327437914,3.298094999978214711]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{lfunsympow}
\kbd{lfunsympow(E,m)} return the $L$-function associated to the
$m$ symmetric power of the elliptic curve $E$ defined over $\QQ$.
\begin{verbatim}
? E=ellinit([0,-1,1,-10,-20]);
? L=lfunsympow(E,2);
? lfun(L,2)
%52 = 1.0575992445909578493475116523231674725
? -(2*Pi*E.omega[1]*imag(E.omega[2]))/11
%53 = 1.0575992445909578493475116523231674725
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{polteichmuller}
This function allow to find a model of an unramified extension of $\QQ_p$
such that the Frobenius is given by $X \mod P \mapsto X^p \mod P$ up to
a fixed $p$-adic precision.
\begin{verbatim}
? T = ffinit(3, 3, 't)
%54 = Mod(1,3)*t^3 + Mod(1,3)*t^2 + Mod(1,3)*t + Mod(2,3)
? P = polteichmuller(T,3,5)
%55 = t^3 + 166*t^2 + 52*t + 242
? subst(P, t, t^3) % (P*Mod(1,3^5))
%56 = Mod(0, 243)
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{mfgaloisprojrep}
If $F$ is a modular form of weight $1$ and type $A_4$ or $S_4$,
\kbd{mfgaloisprojrep} gives a polynomial that defines the kernel of the
projective Artin representation attached to $F$.

\begin{verbatim}
? mfl=mfinit([124,1,0],1);
? apply(mfgaloistype,mfl)
%58 = [[],[-12]]
? mf=mfl[2];
? F=mfeigenbasis(mf)[1];
? P=mfgaloisprojrep(mf,F)
%61 = x^12+196*x^10+14376*x^8+469152*x^6+5836432*x^4+3505728*x^2+984064
? G=galoisinit(P);
? T=galoisfixedfield(G,G.gen[3],1)
%63 = x^4+392*x^3+57504*x^2+3741312*x+91097344
\end{verbatim}

\end{frame}

\begin{frame}[fragile]{ellisotree}
return the oriented graph of isogeny of prime degrees that preserve the Néron differential.
\begin{verbatim}
? E=ellinit([1, 0, 1, 1, 2]);
? [L,M]=ellisotree(E);
? M
%66 =
%[0 2 0 0 3 0 0 0]
%[0 0 2 2 0 3 0 0]
%[0 0 0 0 0 0 3 0]
%[0 0 0 0 0 0 0 3]
%[0 0 0 0 0 2 0 0]
%[0 0 0 0 0 0 2 2]
%[0 0 0 0 0 0 0 0]
%[0 0 0 0 0 0 0 0]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{ellisotree}
which is the adjacency matrix of the following graph:
\begin{equation*}
\begin{tikzcd}[row sep=large]
 && 30a5\arrow{r}{3}&30a8 \\
\color{red}{30a1} \arrow{r}{2}\arrow{rd}[left]{3}&30a2\arrow{rd}[left,near
start]{2}\arrow{ru}{2}\arrow{r}{3}&30a6\arrow{rd}{2}\arrow{ru}[right]{2}\\
&30a3\arrow[crossing over]{ru}[below right, very near start]{2}&30a4\arrow{r}[below]{3}&30a7
\end{tikzcd}
\end{equation*}
\end{frame}

\begin{frame}[fragile]{algebras}
The following functions for semi-simple algebras have been added:
\kbd{alglatadd}, \kbd{alglatcontains}, \kbd{alglatelement}, \kbd{alglathnf},
         \kbd{alglatindex}, \kbd{alglatinter}, \kbd{alglatlefttransporter}, \kbd{alglatmul},
         \kbd{alglatrighttransporter}, \kbd{alglatsubset}, \kbd{algsplit}

Please Ask aurel!
\end{frame}

\begin{frame}[fragile]{parallelism}
new functions \kbd{export}, \kbd{exportall}, \kbd{unexport}, \kbd{unexportall}

See tomorrow talk.
\end{frame}

\begin{frame}[fragile]{idealispower}
\kbd{idealispower} allow to compute the $n$-th root of an ideal when 
it exists.
\begin{verbatim}
? K = nfinit(x^3 - 2);
? A = [46875, 30966, 9573; 0, 3, 0; 0, 0, 3];
? idealispower(K, A, 3, &B)
%69 = 1
? B
%70 =
%[75 22 41]
%[ 0  1  0]
%[ 0  0  1]
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{idealredmodpower}
Try to reduce an ideal modulo powers.
\begin{verbatim}
? T = x^6+108; nf = nfinit(T); a = Mod(x,T);
? setrand(1); u = (2*a^2+a+3)*random(2^1000*x^6)^2;
? b = idealredmodpower(nf,u,2);
? v2 = nfeltmul(nf,u, nfeltpow(nf,b,2))
%74 = [34, 47, 15, 35, 9, 3]~
\end{verbatim}
\end{frame}


\begin{frame}[fragile]{Miscellaneous}
\begin{verbatim}
? dirpowers(10,3)
%75 = [1,8,27,64,125,216,343,512,729,1000]
? pollaguerre(5)
%76 = -1/120*x^5+5/24*x^4-5/3*x^3+5*x^2-5*x+1
? log1p(1)
%77 = 0.69314718055994530941723212145817656807
? log1p(10.^-30)
%78 = 9.9999999999999999999999999999950000000E-31
? log(1.+10.^-30)
%79 = 9.999999972936050969E-31
? serchop(1/x+x+3*x^2+O(x^3),0)
%80 = x+3*x^2+O(x^3)
? serchop(1/x+x+3*x^2+O(x^3),2)
%81 = 3*x^2+O(x^3)
\end{verbatim}
\end{frame}

\begin{frame}[fragile]{getlocalprec}
\begin{verbatim}
? localprec(100);getlocalprec()
%82 = 115
? localbitprec(1000);getlocalbitprec()
%83 = 1000
\end{verbatim}
\end{frame}

\end{document}
