
\documentclass[12pt]{article}
\usepackage{fancyvrb,graphicx}
\usepackage[upright]{fourier}

\makeatletter
\newcommand{\executGiac}[1]{
\immediate\write18{giac  <#1 } }
\makeatother



\begin{VerbatimOut}{XcasTabSignL.meta}
signempL(L):={
L:=apply(f->unapply(f,x),[L])
n:=size(L);
Z:=NULL;
pour k de 0 jusque n-1 faire 
  si size(resoudre(L[k](x)=0)>0) alors
                      pour j de 0 jusque size(resoudre(L[k](x)=0))-1 faire 
                          Z:=Z,simplifier(resoudre(L[k](x)=0)[j]);
                      fpour;
  fsi;
fpour;
Z:=sort(Z);
nz:=size(Z);
pour u de 1 jusque nz-2 faire 
     si Z[u]==Z[u+1] alors Z:=Z[0..u-1],Z[u+1..nz-1];nz:=nz-1;
     fsi;
fpour;
nz:=size(Z);
l0:=" ";li:=" ";lr:=" "; 
pour m de 0 jusque nz-1 faire l0:=l0+"val(btex $"+latex(Z[m])+"$ etex);";fpour; 



for(p:=0;p<=n-1;p++){lp:=" ";                                     
     li:=li+"newLigneSignes(btex $\\hbox{\\bf Signe de }\\atop{\\displaystyle \\Mathbold{"+latex(L[p](x))+"}}$ etex);"+
           if(L[p](Z[0]-1.0)>0){"plus;"}else{"moins;"}+                               
                           for(r:=0; r<=nz-2;r++){  
                             lp:=lp+if(simplifier(L[p](Z[r]))==0){"valBarre(btex 0 etex);"}else{"barre;"}+ 
                             if(L[p]((Z[r]+Z[r+1])*.5)>0){"plus;"}else{"moins;"}}+ 
                           if(simplifier(L[p](Z[nz-1]))==0){"valBarre(btex 0 etex);"}else{"barre;"}+ 
                          if(L[p](Z[nz-1]+1.0)>0){"plus;"}else{"moins;"}
    };  


pour t de 0 jusque nz-2 faire 
                           lr:=lr+if(product(L[s]((Z[t]+Z[t+1])*.5),s,0,n-1)>0){"plus;"}else{"moins;"}+"valBarre(btex 0 etex);"                    
                         fpour

MetaL:=" input tableauVariation;
           verbatimtex
 %&latex
 \\documentclass{article}
 \\usepackage[upright]{fourier}
 \\usepackage{amsmath}
 \\newcommand{\\Mathbold}[1]{\\mbox{\\boldmath$#1$\\unboldmath}}
 \\begin{document}
 etex
          beginTableau(1)
newLigneVariables(btex $\\Mathbold{x}$ etex);
   val(btex $-\\infty$ etex);"+l0+"val(btex $+\\infty$ etex);"+
                     li
                     +
    " newLigneSignes(btex $\\hbox{\\bf Signe du }\\atop{{\\bf produit}}$ etex);"+ 
                         if(product(L[s](Z[0]-1.0),s,0,n-1)>0){"plus;"}else{"moins;"}+"valBarre(btex 0 etex);"+
                         lr+
                         if(product(L[s](Z[nz-1]+1.0),s,0,n-1)>0){"plus;"}else{"moins;"}+"
endTableau;"
;
return(MetaL);
 }:;
\end{VerbatimOut}




\begin{VerbatimOut}{XcasTabSign.meta}
signemp(a,b,c,d):={
zA:=resoudre(a*x+b=0,x)[0];
zB:=resoudre(c*x+d=0,x)[0];
zmin:=min(zA,zB);
zmax:=max(zA,zB);
  Meta:= " input tableauVariation;
           verbatimtex
 %&latex
 \\documentclass{article}
 \\usepackage[upright]{fourier}
 \\usepackage{amsmath}
 \\newcommand{\\Mathbold}[1]{\\mbox{\\boldmath$#1$\\unboldmath}}
 \\begin{document}
 etex
          beginTableau(1)
   newLigneVariables(btex $\\Mathbold{x}$ etex);
   val(btex $-\\infty$ etex);val(btex $"+latex(zmin)+"$ etex);
val(btex $"+latex(zmax)+"$etex);
val(btex $+\\infty$ etex); 
   newLigneSignes(btex $\\hbox{\\bf Signe de }\\atop{\\displaystyle \\Mathbold{"+if(a==1){"x+"}else{if(a==-1){"-x+"}else{a+"x+"}}+b+"}}$ etex);"
        +   if(a>0){"moins;"}else{"plus;"}+
                                 if(zmin==zA){"valBarre(btex 0 etex);"}else{"barre;"}+
                                 if(zmin==zA){si a>0 alors "plus;"; sinon "moins;";fsi}
                                             else{si a>0 alors "moins;"; sinon "plus;"; fsi}+
                                 if(zmin==zA){"barre;"}else{"valBarre(btex 0 etex);"}+
                                 if(a>0){"plus;"}else{"moins;"}
     +" newLigneSignes(btex $\\hbox{\\bf Signe de }\\atop{\\displaystyle \\Mathbold{"+if(c==1){"x+"}else{if(c==-1){"-x+"}else{c+"x+"}}+d+"}}$ etex);"
        +     if(c>0){"moins"}else{"plus"}+";"+
                                 if(zmin==zB){"valBarre(btex 0 etex);"}else{"barre;"}+
                                 if(zmin==zB){si c>0 alors "plus;"; sinon "moins;";fsi}
                                             else{si c>0 alors "moins;"; sinon "plus;"; fsi}+
                                 if(zmin==zB){"barre;"}else{"valBarre(btex 0 etex);"}+
                                 if(c>0){"plus;"}else{"moins;"}  
     
   +" newLigneSignes(btex $\\hbox{\\bf Signe de }\\atop{\\displaystyle \\Mathbold{("+if(a==1){"x+"}else{if(a==-1){"-x+"}else{a+"x+"}}+b+")("+if(c==1){"x+"}else{if(c==-1){"-x+"}else{c+"x+"}}+d+")}}$ etex);"
        +   si a*c>0 alors plus; sinon moins;fsi+";"+
                                 "valBarre(btex 0 etex);"+
                                 si a*c>0 alors moins; sinon plus;fsi+";"+
                                 "valBarre(btex 0 etex);"+
                                 si a*c>0 alors plus; sinon moins;fsi+";"+"
endTableau;"
;
return(Meta);
 }:;
\end{VerbatimOut}




\begin{VerbatimOut}{XCas.in}
maple_mode(0);
read("XcasTabSign.meta");
Sortie:=fopen("XCas.mp");
vect.xcas.out := read("XCas.out");
vxo := vect.xcas.out;
dim.vxo := dim(vxo);
nbr.line.vxo := dim.vxo;
Resultat:=cat(" "); 
for (j:=0;j<nbr.line.vxo;j++){rslt := vxo[j]; RslT:=cat(rslt);};
Resultat:=cat(Resultat,RslT);
fprint(Sortie,Unquoted,Resultat);
fclose(Sortie);
\end{VerbatimOut}

\newenvironment{TabS}
{\VerbatimEnvironment\begin{VerbatimOut}{XCas.out}}
{\end{VerbatimOut}
           \executGiac{XCas.in}

   \immediate\write18{mpost  XCas}

\begin{center}
  \includegraphics{XCas.1}
\end{center}

}




\begin{VerbatimOut}{XCasL.in}
maple_mode(0);
read("XcasTabSignL.meta");
Sortie:=fopen("XCasL.mp");
vect.xcas.out := read("XCasL.out");
vxo := vect.xcas.out;
dim.vxo := dim(vxo);
nbr.line.vxo := dim.vxo;
Resultat:=cat(" "); 
for (j:=0;j<nbr.line.vxo;j++){rslt := vxo[j]; RslT:=cat(rslt);};
Resultat:=cat(Resultat,RslT);
fprint(Sortie,Unquoted,Resultat);
fclose(Sortie);
\end{VerbatimOut}

\newenvironment{TabSL}
{\VerbatimEnvironment\begin{VerbatimOut}{XCasL.out}}
{\end{VerbatimOut}
           \executGiac{XCasL.in}

   \immediate\write18{mpost  XCasL}

\begin{center}
  \includegraphics{XCasL.1}
\end{center}

}

         

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Début du document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

%%% Pour des tableaux de deux facteurs affines

Le tableau de signe de $(-2x+3)(-x+5)$ est 


\begin{TabS}
signemp(-2,3,-1,5);
\end{TabS}

%%%%%% Pour des tableaux de plus de 2 facteurs

Le tableau de signe de $(-2x+3)(x^2-1)(x^2+1)(x-1)(x^2-2)$ est 


\begin{TabSL}
signempL(-2*x+3,x^2-1,x^2+1,x-1,x^2-2);
\end{TabSL}

\end{document}







%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
