TP Maple : courbes elliptiques

Voici les fonctions Jokers du TP Maple sur les courbes elliptiques : un copier-coller vaut mieux qu'une longue frappe ! Consacrez plutôt votre temps à réfléchir...

Si des étudiants de DUT INFO survolent cet article, ils pourront apprécier l'emploi de la théorie des groupes en informatique ;-)


Le poly au format PDF et au format TEX


Une proposition de corrigé au format PDF et au format mws

Maple
anim_elliptic:=proc()
   local P,a,b;
   P:=NULL;
   for a from -10 to 5 by 2 do
     for b from -10 to 5 by 2  do
       if (4*a^3+27*b^2)<>0 then
        P:=P,plots[implicitplot](y^2 = x^3 + a*x + b,x = -10..10,y=-10..10);
   fi;od;od;
   plots[display]([P],insequence=true,view=[-10..10,-10..10]);
end:
 
dessin_elliptic:=proc(P1,P2,a,b)
    local P3,P4,y2,E,x,L1;
    P3 := somme(P1,P2,a,b);
    if P1 = [O] or P2 = [O] or P3 = [O] 
       then RETURN(`Point à l infini`);fi;
    P4 := [P3[1],-P3[2]];
    E := plots[implicitplot](y^2 = x^3 + a*xx + b, xx = -10..10,y = -10..10,color=green);
    L1 := plot([P1,P4,P3],color=blue,thickness=3);
    plots[display]([E,L1]);
end:
 
 
proc1 := proc(x,p)
  local i,r;
  r:=NULL;
  for i from 0 to p-1 do 
    if i^2 mod p = x 
    then r := r,i;
    fi;
  od;
  RETURN([r]);
end:
 
 
proc2 := proc(P1,P2,a,b,p)
   local x1,x2,y1,y2,x3,y3,lambda;
   if (4*a^3+27*b^2) mod p = 0  then RETURN(`Delta nul`);fi;
   if  (P1=[O] or appart_p(a,b,P1,p)) and (P2=[O] or appart_p(a,b,P2,p))   then
     if P1 = [O] then RETURN(P2); fi;
     if P2 = [O] then RETURN(P1); fi;
     x1:=P1[1] mod p;y1:=P1[2] mod p;x2:=P2[1] mod p;y2:=P2[2] mod p;
     if x1 = x2 mod p and y1 = -y2 mod p then RETURN([O]);fi;
     if P1 = P2 then 
        if y1 = 0 mod p then RETURN([O]);fi;
           if igcd(y1,p) <  1 then RETURN([`Diviseur`,igcd(y1,p)]);fi; 
        lambda := (3*x1^2+a)/(2*y1) mod p;
     else
        if igcd(x1-x2,p) <  1 then RETURN([`Diviseur`,igcd(x1-x2,p)]);fi; 
        lambda := (y1-y2)/(x1-x2) mod p;
     fi;
     x3 := (lambda^2-x1-x2) mod p;
     y3 := (-y1 +lambda*(x1-x3)) mod p;
     RETURN([x3,y3]):
   else RETURN(`Mauvais points`);
   fi;
end:
 
 
proc3 := proc(x,a,b,p)
    local X;
    X := x;
    while sqrt_p((X^3+a*X+b) mod p,p) = [] and X < p do
      X := X+1;
    od;
    RETURN([X,sqrt_p((X^3+a*X+b) mod p,p)[1]]);
end:
 
 
proc4 := proc(x1,x2,a,b,p)
    local y2,E,x,i,P1,P2,P,lambda;
    if (4*a^3+27*b^2) mod p = 0 then RETURN(`Delta nul`);fi;
    P1 := point_courbe_p(x1,a,b,p);
    P2 := point_courbe_p(x2,a,b,p);
    E := []; P:= [P1,P2]; 
    lambda := (P2[2]-P1[2])/(P2[1]-P1[1]) mod p;
    for x from 0 to p-1 do
      y2 := (x^3 + a*x + b) mod p;
      for i in sqrt_p(y2,p) do
        E := [op(E),[x,i]];
        P := [op(P),[x,(lambda*(x-P1[1])-P1[2]) mod p]];
      od;
    od;
    E := plot(E,style=point,symbol=diamond,color=red);
    P := plot(P,style=point,symbol=circle,color=blue);
    plots[display]([E,P]);
end:
 
proc5 := proc(P,k,a,b,p)
  local K,M,Q,r;
  K:=k; M:=[O]; Q := P mod p;
  while K   0 do
    r := K mod 2; 
    if r = 1 then M := somme_p(M,Q,a,b,p); fi; 
    if member(`Diviseur`,M) then RETURN(M);fi;   
    Q := somme_p(Q,Q,a,b,p);
    if member(`Diviseur`,Q) then RETURN(Q);fi;
    K := iquo(K,2);
    od;
  RETURN(M);
end:
 
proc6 := proc(n)
  local deux,trois,sept,onze,h;
  deux:=2;trois:=3;sept:=7;onze:=11;
  h:=rand(n);
  while deux <= h() do deux := deux*2;od;
  while trois <= h() do trois := trois*3;od;
  while sept <= h() do sept := sept*7;od;
  while onze <= h() do onze := onze*11;od;
  RETURN(deux*trois*sept*onze/462);
end:
 
proc7 := proc(n)
  local kP,a,b,P,B,s,k;
  if isprime(n) then RETURN(`premier!`);fi;
  P:=[0,1];
  s := ceil(sqrt(n)):
  B:=s+1+2*ceil(sqrt(s));
  k:=friable(B);
  a:=1;b:=1;
  kP:=k_multiple_p(P,k,a,b,n);
  while not member(`Diviseur`,kP) do
    a := a+1; # on peut choisir de jouer aussi sur B
    # k := friable(B);
    kP:=k_multiple_p(P,k,a,b,n);
    od;
  printf(`%a = %a * %a avec a = %a`,n,kP[2],n/kP[2],a);
end: