% proflycee-tools-analyse.tex
% Copyright 2023-2026 Cédric Pierquet
% Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt

%===trad fr/en ok
%===correction d'un bug sur la raacine carrée... le cas où ça fait 1 !
%===modif style signes +/- dans les minischémas

%%------SimplFrac nouvelle version latex3
\ExplSyntaxOn

\NewDocumentCommand\ConversionFraction{ s O{} m }{
  % * = moins sur le numérateur
  % #2 = argument optionnel [d/t/n/dec=...]
  % #3 = argument mandataire {calcul ou fraction}
  
  % Calcul et transformation en A/B
  \tl_set:Ne \l_tmpa_tl { \xintPRaw { \xintIrr { \xinteval{#3} } } }
  % Test si le symbole / apparaît (fraction ou entier)
  \tl_if_in:NnTF \l_tmpa_tl { / }
  { % C'est une fraction
    % Extraction du numérateur et dénominateur
    \seq_set_split:NnV \l_tmpa_seq { / } \l_tmpa_tl
    \tl_set:Ne \l_numerateur_tl { \seq_item:Nn \l_tmpa_seq { 1 } }
    \tl_set:Ne \l_denominateur_tl { \seq_item:Nn \l_tmpa_seq { 2 } }
    % Traitement selon l'argument optionnel
    \tl_if_empty:nTF {#2}
    { % Pas d'argument optionnel : \frac par défaut
      \IfBooleanTF{#1}
      { \ensuremath{ \frac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
      {
        \fp_compare:nNnTF { \l_numerateur_tl } < { 0 }
        { \ensuremath{ -\frac{\num{\fpeval{abs(\l_numerateur_tl)}}}{\num{\l_denominateur_tl}} } }
        { \ensuremath{ \frac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
      }
    }
    { % Argument optionnel présent
      \str_case:nnF {#2}
      {
        {d} { % \dfrac
          \IfBooleanTF{#1}
          { \ensuremath{ \dfrac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
          {
            \fp_compare:nNnTF { \l_numerateur_tl } < { 0 }
            { \ensuremath{ -\dfrac{\num{\fpeval{abs(\l_numerateur_tl)}}}{\num{\l_denominateur_tl}} } }
            { \ensuremath{ \dfrac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
          }
        }
        {t} { % \tfrac
          \IfBooleanTF{#1}
          { \ensuremath{ \tfrac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
          {
            \fp_compare:nNnTF { \l_numerateur_tl } < { 0 }
            { \ensuremath{ -\tfrac{\num{\fpeval{abs(\l_numerateur_tl)}}}{\num{\l_denominateur_tl}} } }
            { \ensuremath{ \tfrac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
          }
        }
        {n} { % \nicefrac
          \ensuremath{ \nicefrac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} }
        }
      }
      { % Cas par défaut : vérifier si "dec" est présent
        \tl_if_in:nnTF {#2} { dec }
        { % Forme décimale
          \tl_if_in:nnTF {#2} { = }
          { % Précision spécifiée
            \tl_set:Nn \l_tmpb_tl {#2}
            \seq_set_split:NnV \l_tmpb_seq { = } \l_tmpb_tl
            \tl_set:Ne \l_precdecimal_tl { \seq_item:Nn \l_tmpb_seq { 2 } }
            \ensuremath{ \num{ \xintfloateval{ round(#3,\l_precdecimal_tl) } } }
          }
          { % Pas de précision
            \ensuremath{ \num{ \xintfloateval{#3} } }
          }
        }
        { % Argument optionnel non reconnu : comportement par défaut
          \IfBooleanTF{#1}
          { \ensuremath{ \frac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
          {
            \fp_compare:nNnTF { \l_numerateur_tl } < { 0 }
            { \ensuremath{ -\frac{\num{\fpeval{abs(\l_numerateur_tl)}}}{\num{\l_denominateur_tl}} } }
            { \ensuremath{ \frac{\num{\l_numerateur_tl}}{\num{\l_denominateur_tl}} } }
          }
        }
      }
    }
  }
  { % C'est un entier
    \num{\l_tmpa_tl}
  }
}

\ExplSyntaxOff

%%------AideTds
\newcommand\tkzTabAideVI[2][red]{%
  \foreach \nbval/\labval in {#2}{%
    \draw (N\nbval1) node[text=#1,font=\tiny,above=0pt,inner sep=0.5pt] {\labval} ;
  }
}

\defKV[aidetds]{%
  Code=\def\tdsparam{#1},code=\def\tdsparam{#1},%
  Couleur=\def\tdscouleur{#1},color=\def\tdscouleur{#1},%
  Racines=\def\tdsracine{#1},roots=\def\tdsracine{#1},%
  Largeur=\def\tdslarg{#1},width=\def\tdslarg{#1},%
  Hauteur=\def\tdshaut{#1},height=\def\tdshaut{#1}
}

\setKVdefault[aidetds]{%
  Code=da+,code=da+,
  Couleur=red,color=red,%
  Largeur=2,width=2,%
  Hauteur=1,height=1,%
  Cadre=true,border=true,%
  Racines=2,roots=2
}

\NewDocumentCommand\schematdsaff{ s m m m m }{%pour les droites (interne)
  % * = étoilée -> a négatif
  % #2 = couleur
  % #3 = largeur
  % #4 = hauteur
  % #5 = racine
  \IfBooleanTF{#1}%si étoile := droite qui descend
    {%
      %\def\possgnavant{above right}\def\possgnapres{below left}\def\sgnavant{\strut+}\def\sgnapres{\strut-}%
      \def\possgnavant{above right}\def\possgnapres{below left}\def\sgnavant{\pflfacplus}\def\sgnapres{\pflfacminus}%
      \draw[thick,#2] ({-0.5*#3},{0.5*#4})--({0.5*#3},{-0.5*#4});
    }
    {%
      %\def\possgnavant{below right}\def\possgnapres{above left}\def\sgnavant{\strut-}\def\sgnapres{\strut+}%
	  \def\possgnavant{below right}\def\possgnapres{above left}\def\sgnavant{\pflfacminus}\def\sgnapres{\pflfacplus}%
      \draw[thick,#2] ({-0.5*#3},{-0.5*#4})--({0.5*#3},{0.5*#4});
    }
  %\draw[#2] ({-0.5*#3},0) node[inner sep=0pt,\possgnavant=1pt,font=\scriptsize] {\textcircled{$\sgnavant$}};
  %\draw[#2] ({0.5*#3},0) node[inner sep=0pt,\possgnapres=1pt,font=\scriptsize] {\textcircled{$\sgnapres$}};
  \draw[#2] ({-0.5*#3},0) node[inner sep=0pt,\possgnavant=1pt,font=\scriptsize] {\sgnavant};
  \draw[#2] ({0.5*#3},0) node[inner sep=0pt,\possgnapres=1pt,font=\scriptsize] {\sgnapres};
  \draw[#2] (0,0) node[inner sep=0pt,above=3pt,font=\scriptsize] {$\strut#5$} ;
  \filldraw[#2] (0,0) circle[radius=2pt] ;
}

\NewDocumentCommand\schematdsexpo{ s m m m }{%pour les expos (interne)
  % * = étoilée -> a négatif
  % #2 = couleur
  % #3 = largeur
  % #4 = hauteur
  \IfBooleanTF{#1}%si étoile := expo 'décroissante'
    {%
      \draw[thick,#2] ({-0.45*#3},{0.5*#4}) to[out=-75,in=179] ({0.5*#3},{-0.325*#4});
    }
    {%sinon := expo 'croissante'
      \draw[thick,#2] ({-0.5*#3},{-0.325*#4}) to[out=1,in=-105] ({0.5*#3},{0.5*#4});
    }
  \draw[#2] ({0},{0}) node[inner sep=0pt,above=0pt,font=\scriptsize] {\pflfacplus};.
}

\NewDocumentCommand\schematdsexposol{ s m m m o }{%pour les expos avec solution (interne)
  % * = étoilée -> a négatif
  % #2 = couleur
  % #3 = largeur
  % #4 = hauteur
  % #5 = racine
  \IfBooleanTF{#1}%si étoile := expo 'décroissante'
    {%
      \draw[thick,#2] ({-0.35*#3},{0.5*#4}) to[out=-75,in=179] ($({0.5*#3},{-0.325*#4})+(2mm,0)$) ;
      \filldraw[#2] ({-0.1925*#3},0) circle[radius=2pt] ;
      \draw[#2] ({0.5*#3},{-0.1625*#4}) node[inner sep=0pt,left=2pt,font=\scriptsize] {\pflfacminus} ;
      \draw[#2] ({-0.5*#3},{0.25*#4}) node[inner sep=0pt,right=1pt,font=\scriptsize] {\pflfacplus} ;
      \draw[#2] ({-0.1925*#3},0) node[inner sep=0pt,below left=1pt,font=\scriptsize] {$\strut#5$} ;
    }
    {%sinon := expo 'croissante'
      \draw[thick,#2] ({-0.5*#3},{-0.325*#4}) to[out=1,in=-105] ({0.35*#3},{0.5*#4});
      \filldraw[#2] ({0.1925*#3},0) circle[radius=2pt] ;
      \draw[#2] ({0.5*#3},{0.25*#4}) node[inner sep=0pt,left=1pt,font=\scriptsize] {\pflfacplus} ;
      \draw[#2] ({-0.5*#3},{-0.1625*#4}) node[inner sep=0pt,right=2pt,font=\scriptsize] {\pflfacminus} ;
      \draw[#2] ({0.1925*#3},0) node[inner sep=0pt,above left=1pt,font=\scriptsize] {$\strut#5$} ;
    }
}

\NewDocumentCommand\schematdslnsol{ s m m m o }{%pour les ln avec solution (interne)
  % * = étoilée -> a négatif
  % #2 = couleur
  % #3 = largeur
  % #4 = hauteur
  % #5 = racine
  \IfBooleanTF{#1}%si étoile := ln 'décroissante'
    {%
      %\draw[thick,#2] ({-0.35*#3},{0.5*#4}) to[out=75,in=179] ($({0.5*#3},{0.325*#4})+(2mm,0)$) ;
      %\filldraw[#2] ({-0.1925*#3},0) circle[radius=2pt] ;
      %\draw[#2] ({-0.5*#3},{-0.25*#4}) node[inner sep=0pt,right=1pt,font=\scriptsize] {\textcircled{$-$}} ;
      %\draw[#2] ({0.5*#3},{0.5*0.325*#4}) node[inner sep=0pt,left=1pt,font=\scriptsize] {\textcircled{$+$}} ;
      %\draw[thick,#2] ({-0.35*#3},{0.5*#4}) to[out=-75,in=179] ($({0.5*#3},{-0.325*#4})+(2mm,0)$) ;
      %\filldraw[#2] ({-0.1925*#3},0) circle[radius=2pt] ;
      %\draw[#2] ({0.5*#3},{-0.1625*#4}) node[inner sep=0pt,left=2pt,font=\scriptsize] {\textcircled{$-$}} ;
      %\draw[#2] ({-0.5*#3},{0.25*#4}) node[inner sep=0pt,right=1pt,font=\scriptsize] {\textcircled{$+$}} ;
    }
    {%sinon := ln 'croissante'
      \draw[thick,#2] ({-0.35*#3},{-0.5*#4}) to[out=75,in=-175] ($({0.5*#3},{0.45*#4})+(2mm,0)$) ;
      \filldraw[#2] ({-0.1975*#3},0) circle[radius=2pt] ;
      \draw[#2] ({-0.5*#3},{-0.25*#4}) node[inner sep=0pt,right=1pt,font=\scriptsize] {\pflfacminus} ;
      \draw[#2] ({0.5*#3},{0.5*0.425*#4}) node[inner sep=0pt,left=1pt,font=\scriptsize] {\pflfacplus} ;
      \draw[#2] ({-0.1925*#3},0) node[inner sep=0pt,above left=1pt,font=\scriptsize] {$\strut#5$} ;
    }
}

\NewDocumentCommand\schematdsparab{ m m m m m o }{%pour les paraboles (interne)
  % #1 = signe de a (1 ou -1) ?
  % #2 = couleur
  % #3 = largeur
  % #4 = hauteur
  % #5 = nb racine
  % #6 = liste racines (option)
  \xintifboolexpr{ #1 > 0 'and' #5 == 2 } %a>0 et delta>0
  {%
    \pflcutandsplit[mac]{#6}{/}{\xun}{\xdeux}%[mac] non utile ?
    %\saveexpandmode\expandarg
    %\StrCut{#6}{/}{\xun}{\xdeux}
    %\restoreexpandmode
    \draw[thick,#2] ({-0.375*#3},{0.5*#4}) parabola bend (0,{-0.5*#4}) ({0.375*#3},{0.5*#4}) ;
    \draw[#2] ({-0.5*#3},0) node[above right=1pt,inner sep=0pt,font=\scriptsize] {\pflfacplus};
    \draw[#2] ({0.5*#3},0) node[above left=1pt,inner sep=0pt,font=\scriptsize] {\pflfacplus};
    \draw[#2] (0,0) node[below=1pt,inner sep=0pt,font=\scriptsize] {\pflfacminus};
    \filldraw[#2] ({0.2625*#3},0) circle[radius=2pt] node[below right=1pt,inner sep=0pt,font=\scriptsize] {$\strut\xdeux$};
    \filldraw[#2] ({-0.2625*#3},0) circle[radius=2pt] node[below left=1pt,inner sep=0pt,font=\scriptsize] {$\strut\xun$};%
  }
  {}
  \xintifboolexpr{ #1 < 0 'and' #5 == 2 } %a<0 et delta>0
  {%
    \pflcutandsplit[mac]{#6}{/}{\xun}{\xdeux}%[mac] non utile ?
%    \saveexpandmode\expandarg
%    \StrCut{#6}{/}{\xun}{\xdeux}
%    \restoreexpandmode
    \draw[thick,#2] ({-0.375*#3},{-0.5*#4}) parabola bend (0,{0.5*#4}) ({0.375*#3},{-0.5*#4}) ;
    \draw[#2] ({-0.5*#3},0) node[below right=1pt,inner sep=0pt,font=\scriptsize] {\pflfacminus};
    \draw[#2] ({0.5*#3},0) node[below left=1pt,inner sep=0pt,font=\scriptsize] {\pflfacminus};
    \draw[#2] (0,0) node[above=1pt,inner sep=0pt,font=\scriptsize] {\pflfacplus};
    \filldraw[#2] ({0.2625*#3},0) circle[radius=2pt] node[above right=1pt,inner sep=0pt,font=\scriptsize] {$\strut\xdeux$};
    \filldraw[#2] ({-0.2625*#3},0) circle[radius=2pt] node[above left=1pt,inner sep=0pt,font=\scriptsize] {$\strut\xun$};%
  }
  {}
  \xintifboolexpr{ #1 > 0 'and' #5 == 1 } %a>0 et delta=0
  {%
    \draw[thick,#2] ({-0.375*#3},{0.5*#4}) parabola bend (0,0) ({0.375*#3},{0.5*#4}) ;
    \filldraw[#2] (0,0) circle[radius=2pt] node[below=3pt,inner sep=1pt,font=\scriptsize] {$#6$};
    \draw[#2] (0,0) node[above=3pt,inner sep=0pt,font=\scriptsize] {\pflfacplus};
  }
  {}
  \xintifboolexpr{ #1 < 0 'and' #5 == 1 } %a>0 et delta=0
  {%
    \draw[thick,#2] ({-0.375*#3},{-0.5*#4}) parabola bend (0,0) ({0.375*#3},{-0.5*#4}) ;
    \filldraw[#2] (0,0) circle[radius=2pt] node[above=3pt,inner sep=0pt,font=\scriptsize] {$#6$};
    \draw[#2] (0,0) node[below=3pt,inner sep=0pt,font=\scriptsize] {\pflfacminus};
  }
  {}
  \xintifboolexpr{ #1 > 0 'and' #5 == 0 } %a>0 et delta<0
  {%
    \draw[thick,#2] ({-0.375*#3},{0.5*#4}) parabola bend (0,{0.075*#4}) ({0.375*#3},{0.5*#4}) ;
    \draw[#2] (0,{0.075*#4}) node[above=2pt,inner sep=0pt,font=\scriptsize] {\pflfacplus};
  }
  {}
  \xintifboolexpr{ #1 < 0 'and' #5 == 0 } %a>0 et delta<0
  {%
    \draw[thick,#2] ({-0.375*#3},{-0.5*#4}) parabola bend (0,{-0.075*#4}) ({0.375*#3},{-0.5*#4}) ;
    \draw[#2] (0,{-0.075*#4}) node[below=2pt,inner sep=0pt,font=\scriptsize] {\pflfacminus};
  }
  {}
}

\NewDocumentCommand\MiniSchemaSignes{ s O{} D<>{} }{%
  \useKVdefault[aidetds]%
  \setKV[aidetds]{#2}%
  %en/fr
  \setKVbooltruedefaultmulti[aidetds]{border}{Cadre}%
  %simplification des codes
  \IfEq{\tdsparam}{da+}{\def\xcode{1}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{da-}{\def\xcode{-1}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{pa+d+}{\def\xcode{12}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{pa-d+}{\def\xcode{-12}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{pa+d0}{\def\xcode{11}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{pa-d0}{\def\xcode{-11}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{pa+d-}{\def\xcode{10}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{pa-d-}{\def\xcode{-10}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{expo+}{\def\xcode{20}\def\xcodehautaxe{-0.35}}{}%
  \IfEq{\tdsparam}{expo-}{\def\xcode{-20}\def\xcodehautaxe{-0.35}}{}%
  \IfEq{\tdsparam}{exposol+}{\def\xcode{30}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{exposol-}{\def\xcode{-30}\def\xcodehautaxe{0}}{}%
  \IfEq{\tdsparam}{lnsol+}{\def\xcode{40}\def\xcodehautaxe{0}}{}%
  %\IfEq{\tdsparam}{lnsol-}{\def\xcode{-40}\def\xcodehautaxe{0}}{}
  %si commande étoilée := commande autonome
  \IfBooleanTF{#1}%
    {\begin{tikzpicture}[#3,>=latex]}{}%
  %cadre si booléen true
  \ifboolKV[aidetds]{Cadre}%
    {\draw[lightgray] ({-0.5*\tdslarg},{-0.5*\tdshaut}) rectangle ({0.55*\tdslarg},{0.5*\tdshaut}) ;}%
    {}%
  %restriction de la petite fenêtre
  \clip ({-0.5*\tdslarg},{-0.5*\tdshaut}) rectangle ({0.55*\tdslarg},{0.5*\tdshaut}) ;
  %axe (Ox)
  \draw[semithick,->,>=latex] ({-0.5*\tdslarg},{\xcodehautaxe*(\tdshaut)})--({0.55*\tdslarg},{\xcodehautaxe*(\tdshaut)});
  %1er degré a+ code = 1
  \ifnum\xcode=1
    \schematdsaff{\tdscouleur}{\tdslarg}{\tdshaut}{\tdsracine}
  \fi
  %1er degré a- code = -1
  \ifnum\xcode=-1
    \schematdsaff*{\tdscouleur}{\tdslarg}{\tdshaut}{\tdsracine}
  \fi
  %2d degré a+delta+ code = 12
  \ifnum\xcode=12
    \schematdsparab{1}{\tdscouleur}{\tdslarg}{\tdshaut}{2}[\tdsracine]
  \fi
  %2d degré a-delta+ code = -12
  \ifnum\xcode=-12
    \schematdsparab{-1}{\tdscouleur}{\tdslarg}{\tdshaut}{2}[\tdsracine]
  \fi
  %2d degré a+delta0 code = 11
  \ifnum\xcode=11
    \schematdsparab{1}{\tdscouleur}{\tdslarg}{\tdshaut}{1}[\tdsracine]
  \fi
  %2d degré a-delta0 code = -11
  \ifnum\xcode=-11
    \schematdsparab{-1}{\tdscouleur}{\tdslarg}{\tdshaut}{1}[\tdsracine]
  \fi
  %2d degré a+delta- code = 10
  \ifnum\xcode=10
    \schematdsparab{1}{\tdscouleur}{\tdslarg}{\tdshaut}{0}
  \fi
  %2d degré a-delta- code = -10
  \ifnum\xcode=-10
    \schematdsparab{-1}{\tdscouleur}{\tdslarg}{\tdshaut}{0}
  \fi
  %expo croissante code = 20
  \ifnum\xcode=20
    \schematdsexpo{\tdscouleur}{\tdslarg}{\tdshaut}
  \fi
  %expo décroissante code = -20
  \ifnum\xcode=-20
    \schematdsexpo*{\tdscouleur}{\tdslarg}{\tdshaut}
  \fi
  %expo avec solution (croissante) code = 30
  \ifnum\xcode=30
    \schematdsexposol{\tdscouleur}{\tdslarg}{\tdshaut}[\tdsracine]
  \fi
  %expo avec solution (décroissante) code = -30
  \ifnum\xcode=-30
    \schematdsexposol*{\tdscouleur}{\tdslarg}{\tdshaut}[\tdsracine]
  \fi
  %ln avec solution (croissante) code = 40
  \ifnum\xcode=40
    \schematdslnsol{\tdscouleur}{\tdslarg}{\tdshaut}[\tdsracine]
  \fi
  %ln avec solution (décroissante) code = -40
  %\ifnum\xcode=-40
  %  \schematdslnsol*{\tdscouleur}{\tdslarg}{\tdshaut}[\tdsracine]
  %\fi
  \IfBooleanTF{#1}%
    {\end{tikzpicture}}{}%
}
\NewCommandCopy\pflschemasignes\MiniSchemaSignes
\NewCommandCopy\pflminisignplot\MiniSchemaSignes

%pour l'interaction avec tkz-tab
\defKV[aidetdstkz]{%
  Echelle=\def\tdstkzscale{#1},scale=\def\tdstkzscale{#1},%
  Decal=\def\tdstkzoffset{#1},offset=\def\tdstkzoffset{#1},%
}

\setKVdefault[aidetdstkz]{%
  Echelle=1,scale=1,%
  Decal=1.25,offset=1.25
}

\NewDocumentCommand\MiniSchemaSignesTkzTab{ o m O{0.85} O{1.5} }{%
  %#1 = codeaidetikz
  %#2 = numligne
  %#3 = échelle
  %#4 = décalage
  %\shorthandoff{:}\shorthandoff{!} %bizzzzzzzzare, non c'est babel !!!!!
  %\NoAutoSpacing
  \coordinate (ZZZ) at ($(T2#2)!.5!(T2\the\numexpr#2+1\relax)$) ;
  %\shorthandon{:}\shorthandon{!}
  \path (ZZZ.east) + (#4,0) pic[right,scale=#3,every node/.style={scale=#3}] {code={\MiniSchemaSignes[#1]}} ;
}
\NewCommandCopy\pflschemasignestkztab\MiniSchemaSignesTkzTab
\NewCommandCopy\pflminisignplottkztab\MiniSchemaSignesTkzTab
\NewCommandCopy\tkzTabMiniSignes\MiniSchemaSignesTkzTab

%%------TVISOLUTION
\defKV[dichoto]{%
  NomFct=\def\DHTnomfct{#1},fct name=\def\DHTnomfct{#1},%
  va=\def\DHTva{#1},%
  vb=\def\DHTvb{#1},%
  Precision=\def\DHTprec{#1},prec=\def\DHTprec{#1},%
  NomSol=\def\DHTnomsol{#1},sol name=\def\DHTnomsol{#1},%
  Stretch=\def\DHTstretch{#1},stretch=\def\DHTstretch{#1}
}

\setKVdefault[dichoto]{%
  NomFct=f,fct name=f,%
  Precision=2,prec=2,%
  NomSol=\alpha,sol name=\alpha,%
  Stretch=1.15,stretch=1.15,%
  Balayage=false,sweep=false,%
  Calculatrice=false,calculator=false,%
  Majuscule=true,capital=true
}

\makeatletter
\newcommand\SolutionTVI[3][]{%
  \useKVdefault[dichoto]%
  \setKV[dichoto]{#1}%
  %en/fr
  \setKVboolfalsedefaultmulti[dichoto]{sweep}{Balayage}%
  \setKVboolfalsedefaultmulti[dichoto]{calculator}{Calculatrice}%
  \setKVbooltruedefaultmulti[dichoto]{capital}{Majuscule}%
  %multilng
  \if@pfllngfr
    \def\labelsolutionseuilbalayage{ar balayage, on obtient~}
    \def\labelsolutionseuilbalayagemaj{P}
    \def\labelsolutionseuilbalayagemin{p}
    %
    \def\labelsolutionseuilcalc{ar calculatrice, on obtient~}
    \def\labelsolutionseuilcalcmaj{P}
    \def\labelsolutionseuilcalcmin{p}
    %
    \def\labelsolutionseuilet{~et~}
  \fi
  \if@pfllngen
    \def\labelsolutionseuilbalayage{y sweeping, we obtain~}
    \def\labelsolutionseuilbalayagemaj{B}
    \def\labelsolutionseuilbalayagemin{b}
    %
    \def\labelsolutionseuilcalc{ith a calculator, we get~}
    \def\labelsolutionseuilcalcmaj{W}
    \def\labelsolutionseuilcalcmin{w}
    %
    \def\labelsolutionseuilet{~and~}
  \fi
  \if@pfllngde
    \def\labelsolutionseuilbalayage{it einer Sweep-Methode ergibt sich~}
    \def\labelsolutionseuilbalayagemaj{M}
    \def\labelsolutionseuilbalayagemin{m}
    %
    \def\labelsolutionseuilcalc{it dem Taschenrechner erhält man~}
    \def\labelsolutionseuilcalcmaj{M}
    \def\labelsolutionseuilcalcmin{m}
    %
    \def\labelsolutionseuilet{~und~}
  \fi
  \if@pfllnges
    \def\labelsolutionseuilbalayage{ediante un barrido, se obtiene~}
    \def\labelsolutionseuilbalayagemaj{M}
    \def\labelsolutionseuilbalayagemin{m}
    %
    \def\labelsolutionseuilcalc{on la calculadora, se obtiene~}
    \def\labelsolutionseuilcalcmaj{C}
    \def\labelsolutionseuilcalcmin{c}
    %
    \def\labelsolutionseuilet{~y~}
  \fi
  %next
  \xintdeffloatfunc varfct(x) := #2 ;%
  \ifboolKV[dichoto]{Balayage}{\ifboolKV[dichoto]{Majuscule}{\labelsolutionseuilbalayagemaj}{\labelsolutionseuilbalayagemin}\labelsolutionseuilbalayage}{}%
  \ifboolKV[dichoto]{Calculatrice}{\ifboolKV[dichoto]{Majuscule}{\labelsolutionseuilcalcmaj}{\labelsolutionseuilcalcmin}\labelsolutionseuilcalc}{}%
  \ensuremath{%
    \left\lbrace \begin{tblr}{stretch=\DHTstretch,colsep=1pt,colspec={rll}}%
      {\DHTnomfct}{\left( \num{\DHTva} \right)} &\approx \num[minimum-decimal-digits=\DHTprec]{\xintFloatToDecimal{\xintfloateval{round(varfct(\DHTva),\DHTprec)}}} & \xintifGt{\xintfloateval{varfct(\DHTva)-#3}}{0}{> \num{#3}}{< \num{#3}} \: \\ %
      {\DHTnomfct}{\left( \num{\DHTvb} \right)} &\approx \num[minimum-decimal-digits=\DHTprec]{\xintFloatToDecimal{\xintfloateval{round(varfct(\DHTvb),\DHTprec)}}} & \xintifGt{\xintfloateval{varfct(\DHTvb)-#3}}{0}{> \num{#3}}{< \num{#3}} \:%
    \end{tblr}%
    \right|%
    \Rightarrow%
    \num{\DHTva} < \DHTnomsol < \num{\DHTvb}%
  }%
}
\makeatother

\NewCommandCopy\pflsoltvi\SolutionTVI
\NewCommandCopy\pflivtsol\SolutionTVI

%%------SIMPLIFRACINES
\DeclareDocumentCommand\SimplificationRacine{ m }{% argument mandataire {calcul ou fraction}
  \xdef\calculargument{\xintIrr{\xinteval{#1}}}%
  \xintifboolexpr{\calculargument == 1}%
    {%
      \ensuremath{1}%
    }%
    {%
      \IfEndWith{\calculargument}{/1}%
      {%si c'est un entier !
        \xdef\calculargument{\xintiieval{#1}}%
        \xdef\ExtractRacStop{\xintiFloor{\xintfloateval{sqrt(\calculargument)}}}%
        \xintFor* ##1 in {\xintSeq{1}{\ExtractRacStop}}\do{%
          \xintifboolexpr{ \xintiiRem{\calculargument}{\xintiieval{##1*##1}} == 0}%si le carré divise
          {\xdef\ExtractRacID{##1}}%
          {}%
        }%
        \xdef\ExtracReste{\xintiieval{\calculargument/(\ExtractRacID*\ExtractRacID)}}%
        \ensuremath{\xintifboolexpr{\ExtractRacID == 1 && \ExtracReste == 1}%
          {1}%
          { \xintifboolexpr{\ExtractRacID == 1}{}{\num{\xintiieval{\ExtractRacID}}}%
            \xintifboolexpr{\ExtracReste == 1}{}{\sqrt{\num{\ExtracReste}}} }}%
        %      }%
        }%
        {%on va mettre sous forme a\sqrt(d)/b := buggue avec des millièmes...
      \StrBefore{\calculargument}{/}[\numerateur]%on extrait le numérateur
      \StrBehind{\calculargument}{/}[\denominateur]%on extrait le dénominateur
      \xdef\ExtractRacNNum{\xintiieval{\numerateur*\denominateur}}%
      \xdef\ExtractRacStop{\xintiFloor{\xintfloateval{sqrt(\ExtractRacNNum)}}}%
      \xintFor* ##1 in {\xintSeq{1}{\ExtractRacStop}}\do{%
        \xintifboolexpr{ \xintiiRem{\ExtractRacNNum}{\xintiieval{##1*##1}} == 0}%si le carré divise
        {\xdef\ExtractRacID{##1}}%
        {}
      }%
      \xdef\ExtractRacGCD{\xintiiGCD{\ExtractRacID}{\denominateur}}%
      \xdef\RacNumSimpl{\xintiieval{\ExtractRacID/\ExtractRacGCD}}%simpl num
      \xdef\RacDenomSimpl{\xintiieval{\denominateur/\ExtractRacGCD}}%
      \xdef\RacRacSimpl{\xintiieval{\ExtractRacNNum/(\ExtractRacID*\ExtractRacID)}}%
      \ensuremath{\frac{%
          \xintifboolexpr{\RacNumSimpl == 1 && \RacRacSimpl == 1}%
          {1}%
          { \xintifboolexpr{\RacNumSimpl == 1}{}{\RacNumSimpl} \xintifboolexpr{\RacRacSimpl == 1}{}{\sqrt{\num{\RacRacSimpl}}} }%
        }%
        { \RacDenomSimpl }}%
        }%
    }%
}

%%------DICHOTOMIE
\defKV[SolDichoto]{%
  Precision=\def\DICHOTOstep{#1},prec=\def\DICHOTOstep{#1},%
  Intervalle=\def\DICHOTOinterv{#1},interval=\def\DICHOTOinterv{#1},%
  Variable=\def\DICHOTOvar{#1},var=\def\DICHOTOvar{#1}
}

\setKVdefault[SolDichoto]{%
  Precision=2,prec=2,%
  Variable=x,var=x,%
  Intervalle={0:10},interval={0:10}
}

\NewDocumentCommand\ResolutionApprochee{ O{} m O{masolution} }{%1=options,2=equation,3=macro
  \useKVdefault[SolDichoto]%
  %extraction fonction + valeur
  \setKV[SolDichoto]{#1}%
  \IfSubStr{#2}{=}%on coupe mmb gauche / mmb droit
    {\StrCut{#2}{=}{\SolDiFCT}{\SolDiVal}}%
    {\xdef\SolDiFCT{#2}\xdef\SolDiVal{0}}%
  %création des variables temporaires
  \xintdeffloatfunc dichotovarfct(\DICHOTOvar) := \SolDiFCT ;%
  \StrCut{\DICHOTOinterv}{:}{\varvala}{\varvalb}%
  \xdef\varstep{\fpeval{10**(-\DICHOTOstep-1)}}%un chiffre en plus :-)
  %boucles
  \whiledo{\xintGt{\xintfloateval{\varvalb-\varvala-\varstep}}{0} = 1}%
  {%
    \xdef\varvalm{\xintfloateval{(\varvala+\varvalb)*0.5}}%
    \xintifboolexpr{\xintGt{\xintfloateval{(dichotovarfct(\varvala)-\SolDiVal)*(dichotovarfct(\varvalm)-\SolDiVal)}}{0}==1}%
      {\xdef\varvala{\fpeval{\varvalm}}}%
      {\xdef\varvalb{\fpeval{\varvalm}}}%
  }%
  \xdef\varvalm{\xintfloateval{(\varvala+\varvalb)*0.5}}%
  \xdef\vartmpmd{\fpeval{floor(\varvalm,\DICHOTOstep)}}%
  \xdef\vartmpme{\fpeval{\vartmpmd+10**(-\DICHOTOstep)}}%
  %les variables créées
  \expandafter\def\csname#3d\endcsname{\fpeval{\vartmpmd}}%
  \expandafter\def\csname#3e\endcsname{\fpeval{\vartmpme}}%
  %valeur approchée
  \expandafter\def\csname#3a\endcsname{\fpeval{round(\varvalm,\DICHOTOstep)}}%
}
\NewCommandCopy\pflresolapproch\ResolutionApprochee
\NewCommandCopy\pflapproxsol\ResolutionApprochee

%==taux acroissement==
\defKV[tauxaccroiss]{%
  Precision=\def\TauxAccroisPrec{#1},prec=\def\TauxAccroisPrec{#1},%
  Signe=\def\TauxAccroisEqual{#1},sign=\def\TauxAccroisEqual{#1},%
  NomFct=\def\TauxAccroisFct{#1},fct name=\def\TauxAccroisFct{#1}
}

\setKVdefault[tauxaccroiss]{%
  Precision=3,prec=3,%
  AffFormule=false,disp formula=false,%
  Displaystyle=true,ds=true,%
  ResultatBrut=false,raw result=false,%
  Signe={\approx},sign={\approx},%
  NomFct=f,fct name=f
}

\NewDocumentCommand\TauxAccroissement{ O{} m m m }{%opts+fct+pt+h
  \useKVdefault[tauxaccroiss]%
  \setKV[tauxaccroiss]{#1}%
  %en/fr
  \setKVboolfalsedefaultmulti[tauxaccroiss]{raw result}{ResultatBrut}%
  \setKVboolfalsedefaultmulti[tauxaccroiss]{disp formula}{AffFormule}%
  \setKVbooltruedefaultmulti[tauxaccroiss]{ds}{Displaystyle}%
  %next
  \xintdeffloatfunc varfct(x) := #2 ;%
  \def\TmpRes{\xintfloateval{(varfct(#3+#4)-varfct(#3))/(#4)}}%
  \ifboolKV[methodeintegr]{ResultatBrut}%
    {\TmpRes}%
    {%
      \ifboolKV[tauxaccroiss]{AffFormule}%
        {%
          \ifboolKV[tauxaccroiss]{Displaystyle}{\displaystyle}{}%
          \frac{\TauxAccroisFct(\num{\xinteval{#3+#4}})-\TauxAccroisFct(\num{#3})}{\num{#4}} \TauxAccroisEqual}%
        {}%
      \num{\xintfloateval{round(\TmpRes,\TauxAccroisPrec)}}%
    }%
}
\NewCommandCopy\pfltxaccroiss\TauxAccroissement
\NewCommandCopy\pflgrowthrate\TauxAccroissement

%==approx intégrale==
\defKV[methodeintegr]{%
  Precision=\def\MethIntegrPrec{#1},prec=\def\MethIntegrPrec{#1},%
  NbSubDiv=\def\MethIntegrNb{#1},nb subdiv=\def\MethIntegrNb{#1},%
  Methode=\def\MethIntegrType{#1},method=\def\MethIntegrType{#1},%
  Signe=\def\MethIntegrEqual{#1},sign=\def\MethIntegrEqual{#1},%
  Expr=\def\MethIntegrFct{#1},expr=\def\MethIntegrFct{#1},%
  Variable=\def\MethIntegrVar{#1},var=\def\MethIntegrVar{#1}
}

\setKVdefault[methodeintegr]{%
  Precision=3,prec=3,%
  NbSubDiv=10,,nb subdiv=10,%
  Methode=Simpson,method=Simpson,%
  ResultatBrut=false,raw result=false,%
  AffFormule=false,disp formula=false,%
  Signe={\approx},sign={\approx},%
  Expr=f(x),expr=f(x),%
  Variable=x,var=x
}

\NewDocumentCommand\IntegraleApprochee{ O{} m m m }{%opts+fct+a+b
  \useKVdefault[methodeintegr]%
  \setKV[methodeintegr]{#1}%
  %en/fr
  \setKVboolfalsedefaultmulti[methodeintegr]{raw result}{ResultatBrut}%
  \setKVboolfalsedefaultmulti[methodeintegr]{disp formula}{AffFormule}%
  %next
  \xintdeffloatfunc varfct(x) := #2 ;%
  \def\TmpNmU{\xinteval{\MethIntegrNb-1}}%
  \IfSubStr{,RectanglesGauche,lrect,}{,\MethIntegrType,}%
  %\IfEq{\MethIntegrType}{RectanglesGauche}%
    {%
      \def\TmpRes{\xintfloateval{(#4-#3)/\MethIntegrNb*add(varfct(#3+i*(#4-(#3))/\MethIntegrNb), i=0..\TmpNmU)}}%
    }%
    {}%
  \IfSubStr{,RectanglesMilieu,mrect,}{,\MethIntegrType,}%
  %\IfEq{\MethIntegrType}{RectanglesMilieu}%
    {%
      \def\TmpRes{\xintfloateval{(#4-#3)/\MethIntegrNb*add(varfct(#3+(i+0.5)*(#4-(#3))/\MethIntegrNb), i=0..\TmpNmU)}}%
    }%
    {}%
  \IfSubStr{,RectanglesDroite,rrect,}{,\MethIntegrType,}%
  %\IfEq{\MethIntegrType}{RectanglesDroite}%
    {%
      \def\TmpRes{\xintfloateval{(#4-#3)/\MethIntegrNb*add(varfct(#3+i*(#4-(#3))/\MethIntegrNb), i=1..\MethIntegrNb)}}%
        }%
    {}%
  \IfSubStr{,Trapezes,trapez,}{,\MethIntegrType,}%
  %\IfEq{\MethIntegrType}{Trapezes}%
    {%
      \def\TmpRes{\xintfloateval{(#4-#3)/\MethIntegrNb*add(0.5*varfct(#3+i*(#4-(#3))/\MethIntegrNb)+0.5*varfct(#3+(i+1)*(#4-(#3))/\MethIntegrNb), i=0..\TmpNmU)}}%
        }%
    {}%
  \IfSubStr{,Simpson,simpson,}{,\MethIntegrType,}%
  %\IfEq{\MethIntegrType}{Simpson}%
    {%
      \def\TmpRes{\xintfloateval{(#4-#3)/(6*\MethIntegrNb)*(2*add(varfct(#3+i*(#4-(#3))/\MethIntegrNb), i=1..\TmpNmU)+varfct(#3)+varfct(#4)+4*add(varfct(#3+(i+0.5)*(#4-(#3))/\MethIntegrNb), i=0..\TmpNmU))}}%
        }%
    {}%
  \ifboolKV[methodeintegr]{ResultatBrut}%
    {\TmpRes}%
    {%
      \ifboolKV[methodeintegr]{AffFormule}%
        {%
          \int_{#3}^{#4} \MethIntegrFct\,\text{d}\MethIntegrVar\MethIntegrEqual%
        }%
        {}%
      \num{\xintfloateval{round(\TmpRes,\MethIntegrPrec)}}
    }%
}
\NewCommandCopy\pflintegrapproch\IntegraleApprochee
\NewCommandCopy\pflapproxintegral\IntegraleApprochee

%===intégrale 'brute'
\NewDocumentCommand\CalcIntegrale{ s O{} D<>{50} m m m }{%
  \xintdeffloatfunc varfct(x) := #4 ;%
  \def\TmpNmU{\xinteval{(#3)-1}}%
  \def\TmpRes{\xintfloateval{((#6)-(#5))/(6*(#3))*(2*add(varfct((#5)+i*((#6)-(#5))/(#3)),i=1..\TmpNmU)+varfct(#5)+varfct(#6)+4*add(varfct((#5)+(i+0.5)*((#6)-(#5))/(#3)), i=0..\TmpNmU))}}%
  \IfStrEq{#2}{}%
    {%
      \IfBooleanTF{#1}{\num{\TmpRes}}{\TmpRes}%
    }%
    {%
      \IfBooleanTF{#1}{\num{\xintfloateval{round(\TmpRes,#2)}}}{\xintfloateval{round(\TmpRes,#2)}}%
    }%
  \relax
}
\NewCommandCopy\pflvalintegr\CalcIntegrale
\NewCommandCopy\pflcalcintegral\CalcIntegrale

%===val moy 'brute'
\NewDocumentCommand\ValeurMoyenneIntg{ s O{} D<>{50} m m m }{%
  \xintdeffloatfunc varfct(x) := #4 ;%
  \def\TmpNmU{\xinteval{(#3)-1}}%
  \def\TmpRes{\xintfloateval{(1)/(6*(#3))*(2*add(varfct(#5+i*(#6-(#5))/(#3)),i=1..\TmpNmU)+varfct(#5)+varfct(#6)+4*add(varfct(#5+(i+0.5)*(#6-(#5))/(#3)), i=0..\TmpNmU))}}%
  \IfStrEq{#2}{}%
    {%
      \IfBooleanTF{#1}{\num{\TmpRes}}{\TmpRes}%
    }%
    {%
      \IfBooleanTF{#1}{\num{\xintfloateval{round(\TmpRes,#2)}}}{\xintfloateval{round(\TmpRes,#2)}}%
    }%
  \relax
}
\NewCommandCopy\pflvalmoyintegr\ValeurMoyenneIntg
\NewCommandCopy\pflaveragevalintegral\ValeurMoyenneIntg

%==intégrale tikz==

\defKV[methodeintegrtkz]{%
  Couleur=\def\MethIntegrTkzCol{#1},color=\def\MethIntegrTkzCol{#1},%%
  CouleurRemplissage=\def\MethIntegrTkzColOpak{#1},fill color=\def\MethIntegrTkzColOpak{#1},%
  NbSubDiv=\def\MethIntegrTkzNb{#1},nb sudiv=\def\MethIntegrTkzNb{#1},%%
  Methode=\def\MethIntegrTkzType{#1},method=\def\MethIntegrTkzType{#1},%
  Opacite=\def\MethIntegrTkzOpak{#1},opacity=\def\MethIntegrTkzOpak{#1},%%
  Epaisseur=\def\MethIntegrTkzThick{#1},thickness=\def\MethIntegrTkzThick{#1}
}

\setKVdefault[methodeintegrtkz]{%
  Couleur=red,color=red,%
  NbSubDiv=10,nb subdiv=10,%
  Methode=RectanglesGauche,method=lrect,%
  Remplir=true,fill=true,%
  CouleurRemplissage={\MethIntegrTkzCol!25},fill color={\MethIntegrTkzCol!25},%
  Opacite=0.25,opacity=0.25,%
  Epaisseur=semithick,thickness=semithick
}

\tikzset{figureintegr/.style={\MethIntegrTkzThick,\MethIntegrTkzCol,fill=\MethIntegrTkzColOpak,fill opacity=\MethIntegrTkzOpak}}%

\NewDocumentCommand\IntegraleApprocheeTikz{ O{} m m m }{%opts+nom_fct+a+b
  \useKVdefault[methodeintegrtkz]%
  \setKV[methodeintegrtkz]{#1}%
  \def\TmpH{(#4-#3)/\MethIntegrTkzNb}%
  %en/fr
  \setKVbooltruedefaultmulti[methodeintegrtkz]{fill}{Remplir}%
  %next
  %rectangles gauches
  \IfSubStr{,RectanglesGauche,lrect,}{,\MethIntegrTkzType,}%
  %\IfEq{\MethIntegrTkzType}{RectanglesGauche}%
    {%
      \foreach \i in {0,...,\inteval{\MethIntegrTkzNb-1}}%
        \draw[figureintegr] ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{#2(#3+\i*\TmpH)}) ;
    }%
    {}%
  \IfSubStr{,RectanglesDroite,rrect,}{,\MethIntegrTkzType,}%
  %\IfEq{\MethIntegrTkzType}{RectanglesDroite}%
    {%
      \foreach \i in {0,...,\inteval{\MethIntegrTkzNb-1}}%
        \draw[figureintegr] ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{#2(#3+(\i+1)*\TmpH)}) ;
    }%
    {}%
  \IfSubStr{,RectanglesMilieu,mrect,}{,\MethIntegrTkzType,}%
  %\IfEq{\MethIntegrTkzType}{RectanglesMilieu}%
    {%
      \foreach \i in {0,...,\inteval{\MethIntegrTkzNb-1}}%
        \draw[figureintegr] ({#3+\i*\TmpH},{0}) rectangle++ ({\TmpH},{#2(#3+(\i+0.5)*\TmpH)}) ;
    }%
    {}%
  \IfSubStr{,Trapezes,trapez,}{,\MethIntegrTkzType,}%
  %\IfEq{\MethIntegrTkzType}{Trapezes}%
    {%
      \foreach \i in {0,...,\inteval{\MethIntegrTkzNb-1}}%
        \draw[figureintegr] ({#3+\i*\TmpH},{0}) -- ({#3+\i*\TmpH},{#2(#3+\i*\TmpH)}) -- ({#3+(\i+1)*\TmpH},{#2(#3+(\i+1)*\TmpH)}) -- ({#3+(\i+1)*\TmpH},{0}) -- cycle ;
    }%
    {}%
}
\NewCommandCopy\pflintegrapprochtikz\IntegraleApprocheeTikz
\NewCommandCopy\pflapproxintegraltikz\CalcIntegrale

%==fonction affine==
\NewDocumentCommand\AffCoeffFAm{ O{d} m }{%
  \xintifboolexpr{#2 == 0}{}{}%
  \xintifboolexpr{#2 == 1}{x}{}%
  \xintifboolexpr{#2 == -1}{-x}{}%
  \xintifboolexpr{#2 != 0 'and' #2 !=1 'and' #2 != -1}{\ConversionFraction[#1]{#2} x}{}%
}

\NewDocumentCommand\AffCoeffFAp{ O{d} m }{%
  \xintifboolexpr{#2 == 0}%
    {}%
    {%
      \xintifboolexpr{#2 > 0}{+\ConversionFraction[#1]{#2}}{\ConversionFraction[#1]{#2}}%
    }%
}

\NewDocumentCommand\AffCoeffFloatPa{ O{d} m }{%
  \IfDecimal{#2}%
    {%
      \xintifboolexpr{#2 < 0}%
        {\left(\num{#2}\right)}%
        {\num{#2}}%
    }%
    {%
      \xintifboolexpr{#2 < 0}%
        {\left(\ConversionFraction[#1]{#2}\right)}%
        {\ConversionFraction[#1]{#2}}%
    }%
}

\NewDocumentCommand\AffCoeffFloat{ O{d} m }{%
  \IfDecimal{#2}%
    {%
      {\num{#2}}%
    }%
    {%
      {\ConversionFraction[#1]{#2}}%
    }%
}

\NewDocumentCommand\AffCoeffPa{ O{d} m }{%
  \xintifboolexpr{#2 < 0}%
    {\left(\ConversionFraction[#1]{#2}\right)}%
    {\ConversionFraction[#1]{#2}}%
}

\makeatletter

\NewDocumentCommand\EquationReduite{ O{d} m}{%
  \setsepchar[*]{,*/}%
  \readlist*\ListePoints{#2}%
  %Les cas particuliers
  \xintifboolexpr{\ListePoints[2,2] == \ListePoints[1,2] 'and' \ListePoints[2,3] == \ListePoints[1,3] }%
    {%
      \if@pfllngfr Les deux points donnés sont identiques, donc pas de droite\ldots\fi%
      \if@pfllngen The two given points are identical, so no line exists\ldots\fi%
      \if@pfllngde Die beiden gegebenen Punkte sind identisch, also gibt es keine Gerade\ldots\fi%
      \if@pfllnges Los dos puntos dados son idénticos, por lo tanto no hay recta\ldots\fi%
    }%
    {}%
  \xintifboolexpr{\ListePoints[2,2] == \ListePoints[1,2] 'and' \ListePoints[2,3] != \ListePoints[1,3] }%
    {%
      \if@pfllngfr Étant donné que $x_{\ListePoints[1,1]} = x_{\ListePoints[2,1]}$, la droite $(\ListePoints[1,1]\ListePoints[2,1])$ est verticale, dont une équation est $x=\ConversionFraction[#1]{\ListePoints[1,2]}$.\fi%
      \if@pfllngen Since $x_{\ListePoints[1,1]} = x_{\ListePoints[2,1]}$, the line $(\ListePoints[1,1]\ListePoints[2,1])$ is vertical, with equation $x=\ConversionFraction[#1]{\ListePoints[1,2]}$.\fi%
      \if@pfllngde Da $x_{\ListePoints[1,1]} = x_{\ListePoints[2,1]}$, ist die Gerade $(\ListePoints[1,1]\ListePoints[2,1])$ vertikal, mit Gleichung $x=\ConversionFraction[#1]{\ListePoints[1,2]}$.\fi%
      \if@pfllnges Dado que $x_{\ListePoints[1,1]} = x_{\ListePoints[2,1]}$, la recta $(\ListePoints[1,1]\ListePoints[2,1])$ es vertical, con ecuación $x=\ConversionFraction[#1]{\ListePoints[1,2]}$.\fi%
    }%
    {}%
  \xintifboolexpr{\ListePoints[2,2] != \ListePoints[1,2] 'and' \ListePoints[2,3] == \ListePoints[1,3] }%
    {%
      \if@pfllngfr Étant donné que $y_{\ListePoints[1,1]} = y_{\ListePoints[2,1]}$, la droite $(\ListePoints[1,1]\ListePoints[2,1])$ est horizontale, dont une équation est $y=\ConversionFraction[#1]{\ListePoints[1,3]}$.\fi%
      \if@pfllngen Since $y_{\ListePoints[1,1]} = y_{\ListePoints[2,1]}$, the line $(\ListePoints[1,1]\ListePoints[2,1])$ is horizontal, with equation $y=\ConversionFraction[#1]{\ListePoints[1,3]}$.\fi%
      \if@pfllngde Da $y_{\ListePoints[1,1]} = y_{\ListePoints[2,1]}$, ist die Gerade $(\ListePoints[1,1]\ListePoints[2,1])$ horizontal, mit Gleichung $y=\ConversionFraction[#1]{\ListePoints[1,3]}$.\fi%
      \if@pfllnges Dado que $y_{\ListePoints[1,1]} = y_{\ListePoints[2,1]}$, la recta $(\ListePoints[1,1]\ListePoints[2,1])$ es horizontal, con ecuación $y=\ConversionFraction[#1]{\ListePoints[1,3]}$.\fi%
    }%
    {}%
  \xintifboolexpr{\ListePoints[2,2] != \ListePoints[1,2] 'and' \ListePoints[2,3] != \ListePoints[1,3] }%
    {%
      \itemtomacro\ListePoints[1,1]\NomA%
      \itemtomacro\ListePoints[2,1]\NomB%
      \itemtomacro\ListePoints[1,2]\xA%
      \itemtomacro\ListePoints[1,3]\yA%
      \itemtomacro\ListePoints[2,2]\xB%
      \itemtomacro\ListePoints[2,3]\yB%
      \xdef\CoeffDirBrut{\xinteval{(\yB-(\yA))/(\xB-(\xA))}}%
      \xdef\OrdoOrigBrut{\xinteval{\yB-(\CoeffDirBrut*(\xB))}}%
      \xdef\CoeffDirConv{\ConversionFraction{(\yB-(\yA))/(\xB-(\xA))}}%
      \xdef\OrdoOrigConv{\ConversionFraction{\yB-(\CoeffDirBrut*(\xB))}}%
      \if@pfllngfr Afin de déterminer l'équation réduite d'une droite passant par les points $\NomA$ et $\NomB$, on doit d'abord déterminer le coefficient directeur $m$ :\fi%
      \if@pfllngen To determine the slope-intercept form of a line passing through points $\NomA$ and $\NomB$, we must first determine the slope $m$:\fi%
      \if@pfllngde Um die Gleichung einer Geraden durch die Punkte $\NomA$ und $\NomB$ zu bestimmen, müssen wir zuerst die Steigung $m$ bestimmen:\fi%
      \if@pfllnges Para determinar la ecuación reducida de una recta que pasa por los puntos $\NomA$ y $\NomB$, primero debemos determinar la pendiente $m$:\fi%
      \[m=\frac{y_\NomB-y_\NomA}{x_\NomB-x_\NomA}=
      \frac{\AffCoeffFloat[]{\yB}-\AffCoeffFloatPa[]{\yA}}{\AffCoeffFloat[]{\xB}-\AffCoeffFloatPa[]{\xA}}=
      \frac{\ConversionFraction{\xinteval{\yB-(\yA)}}}{\ConversionFraction{\xinteval{\xB-(\xA)}}}=
      \ConversionFraction{\CoeffDirBrut}\]%
      %
      \if@pfllngfr L'équation réduite de la droite est donc de la forme $(\NomA\NomB)$ : $y=\AffCoeffFAm[#1]{\CoeffDirBrut}+p$.\par\fi%
      \if@pfllngen The equation of the line is therefore of the form $(\NomA\NomB)$: $y=\AffCoeffFAm[#1]{\CoeffDirBrut}+p$.\par\fi%
      \if@pfllngde Die Gleichung der Geraden hat also die Form $(\NomA\NomB)$: $y=\AffCoeffFAm[#1]{\CoeffDirBrut}+p$.\par\fi%
      \if@pfllnges La ecuación de la recta es entonces de la forma $(\NomA\NomB)$: $y=\AffCoeffFAm[#1]{\CoeffDirBrut}+p$.\par\fi%
      %
      \if@pfllngfr Il faut enfin déterminer l'ordonnée à l'origine $p$.\par\fi%
      \if@pfllngen We must finally determine the y-intercept $p$.\par\fi%
      \if@pfllngde Schließlich müssen wir den y-Achsenabschnitt $p$ bestimmen.\par\fi%
      \if@pfllnges Finalmente debemos determinar la ordenada al origen $p$.\par\fi%
      %
      \if@pfllngfr On sait que la droite passe par le point $\NomA$, donc les coordonnées $\NomA\left(\AffCoeffFloat[]{\xA};\AffCoeffFloat[]{\yA}\right)$ vérifient l'équation. On a alors :\fi%
      \if@pfllngen We know that the line passes through point $\NomA$, so the coordinates $\NomA\left(\AffCoeffFloat[]{\xA};\AffCoeffFloat[]{\yA}\right)$ satisfy the equation. We then have:\fi%
      \if@pfllngde Wir wissen, dass die Gerade durch den Punkt $\NomA$ geht, also erfüllen die Koordinaten $\NomA\left(\AffCoeffFloat[]{\xA};\AffCoeffFloat[]{\yA}\right)$ die Gleichung. Wir haben dann:\fi%
      \if@pfllnges Sabemos que la recta pasa por el punto $\NomA$, por lo tanto las coordenadas $\NomA\left(\AffCoeffFloat[]{\xA};\AffCoeffFloat[]{\yA}\right)$ verifican la ecuación. Tenemos entonces:\fi%
      %
      \[y_\NomA=\ConversionFraction{\CoeffDirBrut} \times x_\NomA+p
      \implies 
      \AffCoeffFloat[#1]{\yA} = \ConversionFraction{\CoeffDirBrut} \times \AffCoeffFloatPa[#1]{\xA} + p \implies p = \AffCoeffFloat[#1]{\yA} - \left(\ConversionFraction{\CoeffDirBrut} \times \AffCoeffFloatPa{\xA}\right) \implies p = \OrdoOrigConv\]
      %
      \if@pfllngfr Donc l'équation réduite de $(\NomA\NomB)$ est $y=\AffCoeffFAm[#1]{\CoeffDirBrut} \AffCoeffFAp[#1]{\OrdoOrigBrut}$.\fi%
      \if@pfllngen Therefore the equation of $(\NomA\NomB)$ is $y=\AffCoeffFAm[#1]{\CoeffDirBrut} \AffCoeffFAp[#1]{\OrdoOrigBrut}$.\fi%
      \if@pfllngde Also lautet die Gleichung von $(\NomA\NomB)$ $y=\AffCoeffFAm[#1]{\CoeffDirBrut} \AffCoeffFAp[#1]{\OrdoOrigBrut}$.\fi%
      \if@pfllnges Por lo tanto la ecuación de $(\NomA\NomB)$ es $y=\AffCoeffFAm[#1]{\CoeffDirBrut} \AffCoeffFAp[#1]{\OrdoOrigBrut}$.\fi%
    }%
    {}%
}

\makeatother

\NewCommandCopy\pfleqreduite\EquationReduite
\NewCommandCopy\pflreducedequation\EquationReduite

%====FRACTION PÉRIODIQUE
\defKV[FracPeriod]{%
  Inconnue=\def\FracPerVar{#1},unknown=\def\FracPerVar{#1}
}
\setKVdefault[FracPeriod]{%
  Enonce=true,statement=true,%
  d=true,%
  Inconnue=x,unknown=x,%
  Solution=false,sol=false,%
  Brut=true,raw=true,%
  Simple=false,simple=false
}

\makeatletter

\NewDocumentCommand\FractionPeriode{ O{} m m }{%
  %clés
  \restoreKV[FracPeriod]% revenir au valeurs par défaut
  \setKV[FracPeriod]{#1}% lit les arguments optionnels
  %en/fr
  \setKVbooltruedefaultmulti[FracPeriod]{raw}{Brut}%
  \setKVbooltruedefaultmulti[FracPeriod]{statement}{Enonce}%
  \setKVboolfalsedefaultmulti[FracPeriod]{sol}{Solution}%
  \setKVboolfalsedefaultmulti[FracPeriod]{simple}{Simple}%
  %next
  %vmode ?
  \ifvmode\leavevmode\fi%
  %les variables utiles
  \pflifendwith{#2}{.}%
    {%
      \plfbeforechar{#2}{.}{\tmp@avt}%
      \xdef\tmp@apr{0}%
      \xdef\tmp@len@apr{0}%
    }%
    {%
      \pflcutandsplit{#2}{.}{\tmp@avt}{\tmp@apr}%
      \pfllenstr{\tmp@apr}[\tmp@len@apr]%
    }%
  \pfllenstr{#3}[\tmp@len@per]%
  %raccourcis
  \pflifendwith{#2}{.}%
    {%
      \xdef\tmp@enonce{\num{\tmp@avt}{\labelsepdec}\overline{#3}}%
    }%
    {%
      \xdef\tmp@enonce{\num{#2}\overline{#3}}%
    }%
  %calculs
  \xdef\tmp@num@brut{\xintieval{10**(\tmp@len@per+\tmp@len@apr)*\tmp@avt+10**(\tmp@len@per)*\tmp@apr-10**(\tmp@len@apr)*\tmp@avt+(#3)-\tmp@apr}}%
  \xdef\tmp@denom@brut{\xintieval{10**(\tmp@len@per+\tmp@len@apr)-10**(\tmp@len@apr)}}%
  \xdef\tmp@pgcd{\xinteval{gcd(\tmp@num@brut,\tmp@denom@brut)}}%
  %résolution OK
  \ifboolKV[FracPeriod]{Solution}%
    {%
      %phrase d'accroche
      \xintifboolexpr{\tmp@len@apr == 0}%
        {%
          \noindent 
          \if@pfllngfr On note $\FracPerVar=\tmp@enonce$.\par
          \noindent La première égalité est donc \[\boxed{\FracPerVar=\tmp@enonce} \quad (1)\]\fi%
          \if@pfllngen We set $\FracPerVar=\tmp@enonce$.\par
          \noindent The first equality is therefore \[\boxed{\FracPerVar=\tmp@enonce} \quad (1)\]\fi%
          \if@pfllngde Wir setzen $\FracPerVar=\tmp@enonce$.\par
          \noindent Die erste Gleichung lautet also \[\boxed{\FracPerVar=\tmp@enonce} \quad (1)\]\fi%
          \if@pfllnges Ponemos $\FracPerVar=\tmp@enonce$.\par
          \noindent La primera igualdad es entonces \[\boxed{\FracPerVar=\tmp@enonce} \quad (1)\]\fi%
        }%
        {%
          \noindent 
          \if@pfllngfr On note $\FracPerVar=\tmp@enonce$.\par\fi%
          \if@pfllngen We set $\FracPerVar=\tmp@enonce$.\par\fi%
          \if@pfllngde Wir setzen $\FracPerVar=\tmp@enonce$.\par\fi%
          \if@pfllnges Ponemos $\FracPerVar=\tmp@enonce$.\par\fi%
        }%
      \xintifboolexpr{\tmp@len@apr == 0}%
        {}%
        {%
          \noindent 
          \if@pfllngfr On \textit{ramène} la période près de la virgule en multipliant par $10^{\tmp@len@apr}$ :\fi%
          \if@pfllngen We \textit{shift} the period close to the decimal point by multiplying by $10^{\tmp@len@apr}$:\fi%
          \if@pfllngde Wir \textit{verschieben} die Periode nahe dem Komma, indem wir mit $10^{\tmp@len@apr}$ multiplizieren:\fi%
          \if@pfllnges \textit{Desplazamos} el período cerca de la coma multiplicando por $10^{\tmp@len@apr}$:\fi%
          \[\boxed{10^{\tmp@len@apr}\times\FracPerVar=\num{\xinteval{\tmp@avt*10**(\tmp@len@apr)+\tmp@apr}}{\labelsepdec}\overline{#3}} \quad (1)\]
        }%
      \noindent 
      \if@pfllngfr On \textit{décale} la période avant la virgule, en multipliant l'égalité (1) par $10^{\tmp@len@per}$ :\fi%
      \if@pfllngen We \textit{shift} the period before the decimal point by multiplying equality (1) by $10^{\tmp@len@per}$:\fi%
      \if@pfllngde Wir \textit{verschieben} die Periode vor das Komma, indem wir Gleichung (1) mit $10^{\tmp@len@per}$ multiplizieren:\fi%
      \if@pfllnges \textit{Desplazamos} el período antes de la coma multiplicando la igualdad (1) por $10^{\tmp@len@per}$:\fi%
      \[10^{\tmp@len@per}\xintifboolexpr{\tmp@len@apr == 0}{}{\times10^{\tmp@len@apr}}\times\FracPerVar=10^{\tmp@len@per}\times\num{\xinteval{\tmp@avt*10**(\tmp@len@apr)+\tmp@apr}}{\labelsepdec}\overline{#3} \Rightarrow \boxed{10^{\xinteval{\tmp@len@per+\tmp@len@apr}}\times\FracPerVar = \num{\xintieval{10**(\tmp@len@per)*(\tmp@avt*10**(\tmp@len@apr)+\tmp@apr)+#3}}{\labelsepdec}\overline{#3}} \quad (2)\]
      %soustraction
      \if@pfllngfr On soustrait les deux égalités, $(2)-(1)$, ce qui permet d'\textit{enlever} la partie décimale :\fi%
      \if@pfllngen We subtract the two equalities, $(2)-(1)$, which allows us to \textit{remove} the decimal part:\fi%
      \if@pfllngde Wir subtrahieren die beiden Gleichungen, $(2)-(1)$, wodurch wir den Dezimalteil \textit{entfernen} können:\fi%
      \if@pfllnges Restamos las dos igualdades, $(2)-(1)$, lo que nos permite \textit{eliminar} la parte decimal:\fi%
      \begin{align*}
        10^{\xinteval{\tmp@len@per+\tmp@len@apr}}\times\FracPerVar-\xintifboolexpr{\tmp@len@apr == 0}{}{10^{\tmp@len@apr}\times}\FracPerVar = \num{\xintieval{10**(\tmp@len@per)*(\tmp@avt*10**(\tmp@len@apr)+\tmp@apr)+#3}}{\labelsepdec}\overline{#3} -\num{\xinteval{\tmp@avt*10**(\tmp@len@apr)+\tmp@apr}}{\labelsepdec}\overline{#3} &\Rightarrow \big(10^{\xinteval{\tmp@len@per+\tmp@len@apr}}-\xintifboolexpr{\tmp@len@apr == 0}{1}{10^{\tmp@len@apr}}\big)\times\FracPerVar = \num{\xintieval{10**(\tmp@len@per)*(\tmp@avt*10**(\tmp@len@apr)+\tmp@apr)+#3}} - \num{\xintieval{\tmp@avt*10**(\tmp@len@apr)+\tmp@apr}} \\
        \phantom{10^{\xinteval{\tmp@len@per+\tmp@len@apr}}\times\FracPerVar-10^{\tmp@len@apr}\times\FracPerVar = \num{\xintieval{10**(\tmp@len@per)*(\tmp@avt*10**(\tmp@len@apr)+\tmp@apr)+#3}}{\labelsepdec}\overline{#3} -\num{\xinteval{\tmp@avt*10**(\tmp@len@apr)+\tmp@apr}}{\labelsepdec}\overline{#3}} &\Rightarrow \num{\xinteval{10**(\tmp@len@per+\tmp@len@apr)-10**(\tmp@len@apr)}}\times\FracPerVar=\num{\xintieval{10**(\tmp@len@per)*(\tmp@avt*10**(\tmp@len@apr)+\tmp@apr)+#3- (\tmp@avt*10**(\tmp@len@apr)+\tmp@apr)}} \\
        &\Rightarrow\FracPerVar = \ifboolKV[FracPeriod]{d}{\displaystyle}{}\frac{\num{\tmp@num@brut}}{\num{\tmp@denom@brut}}
      \end{align*}
      %affichage(s) OK
      \noindent 
      \if@pfllngfr Ainsi on a \fi%
      \if@pfllngen Thus we have \fi%
      \if@pfllngde Also haben wir \fi%
      \if@pfllnges Así tenemos \fi%
      \ensuremath{\tmp@enonce = \ifboolKV[FracPeriod]{d}{\displaystyle}{}\frac{\num{\tmp@num@brut}}{\num{\tmp@denom@brut}} \xintifboolexpr{\tmp@pgcd == 1}{}{=\ifboolKV[FracPeriod]{d}{\displaystyle}{}\frac{\num{\xintieval{\tmp@num@brut/\tmp@pgcd}}}{\num{\xintieval{\tmp@denom@brut/\tmp@pgcd}}}} \xintifboolexpr{\tmp@denom@brut/\tmp@pgcd == 1}{=\num{\xintieval{\tmp@num@brut/\tmp@pgcd}}}{}%
      }.\par%
    }%
    {}%
  \ifboolKV[FracPeriod]{Brut}%
    {%
      \xdef\FracPerNum{\tmp@num@brut}%
      \xdef\FracPerDenom{\tmp@denom@brut}%
      \xdef\FracPerNumSimpl{\xintieval{(\tmp@num@brut)/gcd(\tmp@num@brut,\tmp@denom@brut)}}%
      \xdef\FracPerDenomSimpl{\xintieval{(\tmp@denom@brut)/gcd(\tmp@num@brut,\tmp@denom@brut)}}%
    }%
    {}%
  \ifboolKV[FracPeriod]{Simple}%
    {%
      %affichage(s) OK
      \noindent\ensuremath{%
        \ifboolKV[FracPeriod]{Enonce}%
          {%
            \tmp@enonce = 
          }%
          {}%
        \ifboolKV[FracPeriod]{d}{\displaystyle}{}\frac{\num{\tmp@num@brut}}{\num{\tmp@denom@brut}} \xintifboolexpr{\tmp@pgcd == 1}{}{=\ifboolKV[FracPeriod]{d}{\displaystyle}{}\frac{\num{\xintieval{\tmp@num@brut/\tmp@pgcd}}}{\num{\xintieval{\tmp@denom@brut/\tmp@pgcd}}}}%
      }\par%
    }%
    {}%
}
\makeatletter

\NewCommandCopy\pflfracperiod\FractionPeriode
\NewCommandCopy\pflperiodfraction\FractionPeriode

%====tkz ligne convexité
\makeatletter
\NewDocumentCommand\tkzTabLineConvex{ s m m }{%
  %étoilé := mode texte
  %1 := ligne
  %2 := liste des cases ( ccv / cvx / t / d / i / i* )
  %multilng
  \if@pfllngfr
    \def\labelconvexinflex{point\\d'inflexion}
    \def\labelconvexccv{concave}
    \def\labelconvexcvx{convexe}
  \fi
  \if@pfllngen
    \def\labelconvexinflex{inflection\\point}
    \def\labelconvexccv{concave}
    \def\labelconvexcvx{convex}
  \fi
  \if@pfllngde
    \def\labelconvexinflex{Wende-\\punkt}
    \def\labelconvexccv{konkav}
    \def\labelconvexcvx{konvex}
  \fi
  \if@pfllnges
    \def\labelconvexinflex{punto de\\inflexión}
    \def\labelconvexccv{cóncava}
    \def\labelconvexcvx{convexa}
  \fi
  %calculs intermédiaires
  \xdef\j{#2}%
  \xdef\k{\inteval{#2+1}}%
  %récup hauteur ligne
  \pgfpointdiff{\pgfpointanchor{T0\j}{center}}{\pgfpointanchor{T0\k}{center}}%
  \pgf@xa=\pgf@x
  \pgf@ya=\pgf@y
  \pgfmathparse{veclen(\pgf@xa,\pgf@ya)/28.45274}%
  \global\let\tmphautligne\pgfmathresult%
  %suite
  \setsepchar{,}%
  \readlist*\lsttabconvex{#3}%
  \foreach \i in {1,...,\lsttabconvexlen}{%
    \itemtomacro\lsttabconvex[\i]{\paramcvxitem}%
    \IfStrEqCase{\paramcvxitem}{%
      {d}%double barre
      {%
        \xdef\nodedouble{\inteval{(\i+1)/2}}%
        \draw[double style] (N\nodedouble\j)--(N\nodedouble\k) ;%
      }%
      {i*}%inflexion
      {%
        \xdef\nodedouble{\inteval{(\i+1)/2}}%
        \draw[line width=\cmdTAB@tbs@lw] (N\nodedouble\j)--([xshift=-12pt]N\nodedouble\k) ;%
        \draw[line width=\cmdTAB@tbs@lw] (N\nodedouble\j)--([xshift=12pt]N\nodedouble\k) ;%
        \draw (N\nodedouble\k) node[font=\tiny,text width=1.5cm,align=center] {\labelconvexinflex} ;
      }%
      {i}%inflexion sans texte
      {%
        \xdef\nodedouble{\inteval{(\i+1)/2}}%
        \draw[line width=\cmdTAB@tbs@lw] (N\nodedouble\j)--([xshift=-12pt]N\nodedouble\k) ;%
        \draw[line width=\cmdTAB@tbs@lw] (N\nodedouble\j)--([xshift=12pt]N\nodedouble\k) ;%
      }%
      {t}%trait
      {%
        \xdef\nodedouble{\inteval{(\i+1)/2}}%
        \draw[line width=\cmdTAB@tbs@lw,t style] (N\nodedouble\j)--(N\nodedouble\k) ;
      }%
      {ccv}%concave
      {%
        \xdef\nodedouble{\inteval{(\i)/2}}%
        \IfBooleanTF{#1}%
        {%
          \draw ($(M\nodedouble\j)!0.5!(M\nodedouble\k)$) node {\labelconvexccv} ;%
        }%
        {%
          \draw[line width={1.5*\cmdTAB@tbs@lw}] ($(M\nodedouble\j)!0.5!(M\nodedouble\k)+({-0.275*\cmdTAB@tbs@espcl},{-0.25*\tmphautligne})$) parabola bend ++({0.275*\cmdTAB@tbs@espcl},{0.5*\tmphautligne})  ($(M\nodedouble\j)!0.5!(M\nodedouble\k)+({0.275*\cmdTAB@tbs@espcl},{-0.25*\tmphautligne})$) ;
        }%
      }%
      {cvx}%convexe
      {%
        \xdef\nodedouble{\inteval{(\i)/2}}%
        \IfBooleanTF{#1}%
        {%
          \draw ($(M\nodedouble\j)!0.5!(M\nodedouble\k)$) node {\labelconvexcvx} ;%
        }%
        {%
          \draw[line width={1.5*\cmdTAB@tbs@lw}] ($(M\nodedouble\j)!0.5!(M\nodedouble\k)+({-0.275*\cmdTAB@tbs@espcl},{0.25*\tmphautligne})$) parabola bend ++({0.275*\cmdTAB@tbs@espcl},{-0.5*\tmphautligne})  ($(M\nodedouble\j)!0.5!(M\nodedouble\k)+({0.275*\cmdTAB@tbs@espcl},{0.25*\tmphautligne})$) ;
        }%
      }%
    }%
  }%
}
\makeatother

\NewCommandCopy\pfltkztabcvx\tkzTabLineConvex

%===F.CANONIQUE & F.HOMOGRAPHIQUE
\NewDocumentCommand\FormeCanonique{ s O{d} m m m }{%
  \def\tmpcoeffalpha{-(#4)/(2*(#3))}%
  \def\tmpcoeffbeta{(#3)*(-(#4)/(2*(#3)))^2+(#4)*(-(#4)/(2*(#3)))+(#5)}%
  \def\coeffaconv{\ConversionFraction[#2]{#3}}%
  \def\coeffalpha{\ConversionFraction[#2]{-(#4)/(2*(#3))}}%
  \def\coeffalphamoins{\ConversionFraction[#2]{(#4)/(2*(#3))}}%
  \def\coeffbeta{\ConversionFraction[#2]{(#3)*(-(#4)/(2*(#3)))^2+(#4)*(-(#4)/(2*(#3)))+(#5)}}%
  \ensuremath{%
    %on affiche a, sauf s'il vaut 1 ou -1
    \xintifboolexpr{#3 == 1}{}{}%
    \xintifboolexpr{#3 == -1}{-}{}%
    \xintifboolexpr{#3 != -1 'and' #3 != 1}{\coeffaconv}{}%
    \xintifboolexpr{\tmpcoeffalpha == 0}%
    {%
      x^2%
    }%
    {%
      \IfBooleanTF{#1}%
      {%
        \xintifboolexpr{\tmpcoeffalpha < 0}%
          {%
            {\left(x\xintifboolexpr{\tmpcoeffalpha < 0}{-}{+}{\left(\coeffalpha\right)}\right)}^2%
          }%
          {%
            {\left(x\xintifboolexpr{\tmpcoeffalpha > 0}{}{+}\coeffalphamoins\right)}^2%
          }%
      }%
      {%
        {\left(x\xintifboolexpr{\tmpcoeffalpha > 0}{}{+}\coeffalphamoins\right)}^2%
      }%
    }%
    \xintifboolexpr{\tmpcoeffbeta == 0}%
    {}%
    {%
      \xintifboolexpr{\tmpcoeffbeta > 0}{+}{}\coeffbeta%
    }%
  }%
}
\NewCommandCopy\pflformcanoniq\FormeCanonique
\NewCommandCopy\pflcanonicform\FormeCanonique

\NewDocumentCommand\FonctionHomographique{ s O{t} m m m m }{%
  \xintifboolexpr{#3 != 0}%
  {%
    \def\tmpcoeffSeul{(#3)/(#5)}%
    \def\tmpcoeffNum{((#4)*(#5)-(#3)*(#6))/((#5)*(#5))}%
    \def\tmpcoeffDenom{(#6)/(#5)}%
    \ensuremath{%
      \ConversionFraction[d]{\tmpcoeffSeul}%
      +\dfrac%
      {\ConversionFraction[#2]{\tmpcoeffNum}}%
      {x%
        \xintifboolexpr{#6 == 0}{}{%
          \IfBooleanTF{#1}%
          {%
            \xintifboolexpr{\tmpcoeffDenom > 0}{-\left(\ConversionFraction[#2]{-(\tmpcoeffDenom)}\right)}{\ConversionFraction[#2]{\tmpcoeffDenom}}%
          }%
          {%
            \xintifboolexpr{\tmpcoeffDenom > 0}{+}{}\ConversionFraction[#2]{\tmpcoeffDenom}%
          }%
        }%
      }%
    }%
  }%
  {%
    \def\tmpcoeffNum{(#4)/(#5)}%
    \def\tmpcoeffDenom{(#6)/(#5)}%
    \ensuremath{%
      \dfrac%
      {\ConversionFraction[#2]{\tmpcoeffNum}}%
      {x%
        \xintifboolexpr{#6 == 0}{}{%
          \IfBooleanTF{#1}%
          {%
            \xintifboolexpr{\tmpcoeffDenom > 0}{-}{}\left(\ConversionFraction[#2]{-(\tmpcoeffDenom)}\right)%
          }%
          {%
            \xintifboolexpr{\tmpcoeffDenom > 0}{+}{}\ConversionFraction[#2]{\tmpcoeffDenom}%
          }%
        }%
      }%
    }%
  }%
}
\NewCommandCopy\pflfcthomogr\FonctionHomographique
\NewCommandCopy\pflhomogfct\FonctionHomographique

%----max/min
\NewDocumentCommand\DetermineMax{ O{0.01} m m m O{\tmpmax} O{\tmpmaxvalx} }{%
  \xdef#5{\xintfloateval{max(seq(#2,x=#3..[#1]..#4,#4))}}%
  \xdef#6{\xintfloateval{first(seq((#2 == #5)?{x}{},x=#3..[#1]..#4,#4))}}%
}
\NewCommandCopy\pfldetmax\DetermineMax
\NewCommandCopy\pflfindmax\DetermineMax

\NewDocumentCommand\DetermineMin{ O{0.01} m m m O{\tmpmin} O{\tmpminvalx} }{%
  \xdef#5{\xintfloateval{min(seq(#2,x=#3..[#1]..#4,#4))}}%
  \xdef#6{\xintfloateval{first(seq((#2 == #5)?{x}{},x=#3..[#1]..#4,#4))}}%
}
\NewCommandCopy\pfldetmin\DetermineMin
\NewCommandCopy\pflfindmin\DetermineMin

\endinput