\setKVdefault[CalculsFractions]{Couleurs=false,Negatif=false}%
\defKV[CalculsFractions]{Couleur=\setKV[CalculsFractions]{Couleurs}}%

\NewDocumentCommand\tofrac{m}{%
  \IfDecimal{#1}{#1}{%
    \StrBefore{#1}{/}[\PfCnum]%
    \StrBehind{#1}{/}[\PfCden]%
    \frac{\PfCnum}{\PfCden}%
  }%
}%

\NewDocumentCommand\AddFraction{soommo}{%
  \useKVdefault[CalculsFractions]%
  \setKV[CalculsFractions]{#2}%
  \ifboolKV[CalculsFractions]{Couleurs}{\colorlet{CouleurDenoCom}{\useKV[CalculsFractions]{Couleur}}}{\colorlet{CouleurDenoCom}{black}}%
  \IfBooleanTF{#1}{%
    \xdef\PfCFractionOp{-}%
  }{%
    \xdef\PfCFractionOp{+}%
  }%
  \IfDecimal{#4}{%
    \xdef\PfCNumA{#4}%
    \xdef\PfCNumB{1}%
  }{%
    \StrCut{#4}{/}\PfCNumA\PfCNumB%
  }%
  \IfDecimal{#5}{%
    \xdef\PfCNumC{#5}%
    \xdef\PfCNumD{1}%
  }{%
    \StrCut{#5}{/}\PfCNumC\PfCNumD%
  }
  \xdef\PfCAddFoo{\PfCNumA/\PfCNumB,\PfCNumC/\PfCNumD}%
  \setsepchar[*]{,*/}\ignoreemptyitems%
  \readlist*\ListeFractions{\PfCAddFoo}%
  \reademptyitems%
  \setsepchar{,}%
  % Partie calculs
  \PGCD{\ListeFractions[1,2]}{\ListeFractions[2,2]}%
  \xdef\PfCPremierMul{\fpeval{\ListeFractions[2,2]/\the\pgcd}}%
  \xdef\PfCDeuxiemeMul{\fpeval{\ListeFractions[1,2]/\the\pgcd}}%
  \xdef\PfCAddNumFin{\fpeval{(\ListeFractions[1,1])*(\PfCPremierMul)\PfCFractionOp(\ListeFractions[2,1])*(\PfCDeuxiemeMul)}}%
  \xdef\PfCAddDenoFin{\fpeval{(\ListeFractions[1,2])*(\PfCPremierMul)}}%
  \PGCD{\fpeval{abs(\PfCAddNumFin)}}{\fpeval{abs(\PfCAddDenoFin)}}\xdef\PfCAddPgcd{\the\pgcd}%
  \xdef\PfCAddNumSimp{\fpeval{\PfCAddNumFin/\PfCAddPgcd}}%
  \xdef\PfCAddDenoSimp{\fpeval{\PfCAddDenoFin/\PfCAddPgcd}}%
  \xdef\PfCAddSumSimp{\PfCAddNumSimp/\PfCAddDenoSimp}%
  \IfValueT{#6}{\xdef#6{\PfCAddSumSimp}}%
  % Partie affichage
  \ensuremath{%
    \IfValueTF{#3}{%
      \ifnum#3=4\relax%
      %test
      \ifboolKV[CalculsFractions]{Negatif}{%
      \xintifboolexpr{\fpeval{\PfCAddNumSimp/\PfCAddDenoSimp}<0}{-\tofrac{\fpeval{abs(\PfCAddNumSimp)}/\fpeval{abs(\PfCAddDenoSimp)}}}{\tofrac{\PfCAddSumSimp}}%
      }{\tofrac{\PfCAddSumSimp}}%
      \else%
      \ifnum#3=3\relax%
      \SSimpliTest{\fpeval{abs(\PfCAddNumFin)}}{\fpeval{abs(\PfCAddDenoFin)}}\ifthenelse{\boolean{Simplification}}{\tofrac{\PfCAddNumFin/\PfCAddDenoFin}}{\tofrac{\PfCAddSumSimp}}%
      \else%
      \ifnum#3=1\relax%
      \ifnum\PfCPremierMul>1\relax%
      \frac{\ListeFractions[1,1]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCPremierMul}}}}{\ListeFractions[1,2]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCPremierMul}}}}
      \else%
      \tofrac{#4}%
      \fi%
      \PfCFractionOp%
      \ifnum\PfCDeuxiemeMul>1\relax%
      \frac{\ListeFractions[2,1]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCDeuxiemeMul}}}}{\ListeFractions[2,2]_{\mathcolor{CouleurDenoCom}{\times\num{\PfCDeuxiemeMul}}}}%
      \else%
      \tofrac{#5}%
      \fi%
      \else%
      \ifnum#3=2\relax%
      \frac{\num{\fpeval{\ListeFractions[1,1]*\PfCPremierMul}}}{\num{\fpeval{\ListeFractions[1,2]*\PfCPremierMul}}}\PfCFractionOp\frac{\num{\fpeval{\ListeFractions[2,1]*\PfCDeuxiemeMul}}}{\num{\fpeval{\ListeFractions[2,2]*\PfCDeuxiemeMul}}}%
      \fi%
      \fi%
      \fi%
      \fi%
    }{\tofrac{#4}\PfCFractionOp\tofrac{#5}
    }%
  }%
}%

\NewDocumentCommand\SousFraction{oommo}{%
  \AddFraction*[#1][#2]{#3}{#4}[#5]%
}%

\NewDocumentCommand\MulFraction{oommo}{%
  \useKVdefault[CalculsFractions]%
  \setKV[CalculsFractions]{#1}%
  \IfDecimal{#3}{%
    \xdef\PfCNumA{#3}%
    \xdef\PfCNumB{1}%
  }{%
    \StrCut{#3}{/}{\PfCNumA}{\PfCNumB}%
  }%
  \IfDecimal{#4}{%
    \xdef\PfCNumC{#4}%
    \xdef\PfCNumD{1}%
  }{%
    \StrCut{#4}{/}{\PfCNumC}{\PfCNumD}%
  }%
  \xdef\PfCMulFoo{\PfCNumA/\PfCNumB,\PfCNumC/\PfCNumD}%
  \setsepchar[*]{,*/}\ignoreemptyitems%
  \readlist*\ListeFractions{\PfCMulFoo}%
  \reademptyitems
  \setsepchar{,}%
  % Calculs
  \xdef\PfCMulNumFin{\fpeval{(\ListeFractions[1,1])*(\ListeFractions[2,1])}}
  \xdef\PfCMulDenoFin{\fpeval{\ListeFractions[1,2]*\ListeFractions[2,2]}}
  \PGCD{\fpeval{abs(\PfCMulNumFin)}}{\fpeval{abs(\PfCMulDenoFin)}}\xdef\PfCMulPgcd{\pgcd}%
  \xdef\PfCMulNumSimp{\fpeval{\PfCMulNumFin/\PfCMulPgcd}}%
  \xdef\PfCMulDenoSimp{\fpeval{\PfCMulDenoFin/\PfCMulPgcd}}%
  \xdef\PfCMulPdtSimp{\PfCMulNumSimp/\PfCMulDenoSimp}%
  \IfValueT{#5}{\xdef#5{\PfCMulPdtSimp}}%
  \ensuremath{%
    \IfValueTF{#2}{%
      \ifnum#2=3\relax
        \ifboolKV[CalculsFractions]{Negatif}{%
           \xintifboolexpr{\fpeval{\PfCMulNumSimp/\PfCMulDenoSimp}<0}{-\tofrac{\fpeval{abs(\PfCMulNumSimp)}/\fpeval{abs(\PfCMulDenoSimp)}}}{\tofrac{\PfCMulPdtSimp}}%
           }{\tofrac{\PfCMulPdtSimp}}%
      \else
      \ifnum#2=2\relax%
      \SSimpliTest{\PfCMulNumFin}{\PfCMulDenoFin}\ifthenelse{\boolean{Simplification}}{\frac{\ifnum\PfCMulNumFin<0\relax-\fi\Decomposition[Longue]{\fpeval{abs(\PfCMulNumFin)}}}{\ifnum\PfCMulDenoFin<0\relax-\fi\Decomposition[Longue]{\fpeval{abs(\PfCMulDenoFin)}}}}{\tofrac{\PfCMulPdtSimp}}%
      \else%
      \ifnum#2=1\relax%
       \frac{\ListeFractions[1,1]\times\ifnum\ListeFractions[2,1]<0\relax(\fi\ListeFractions[2,1]\ifnum\ListeFractions[2,1]<0\relax)\fi}{\ListeFractions[1,2]\times\ifnum\ListeFractions[2,2]<0\relax(\fi\ListeFractions[2,2]\ifnum\ListeFractions[2,2]<0\relax)\fi}
      \fi
      \fi
      \fi
    }{\tofrac{#3}\times\tofrac{#4}
    }
  }%
}%

\NewDocumentCommand\DivFraction{oommo}{%
  \useKVdefault[CalculsFractions]%
  \setKV[CalculsFractions]{#1}%
  \IfDecimal{#3}{%
    \xdef\PfCNumA{#3}%
    \xdef\PfCNumB{1}%
  }{%
    \StrCut{#3}{/}{\PfCNumA}{\PfCNumB}%
  }%
  \IfDecimal{#4}{%
    \xdef\PfCNumC{#4}%
    \xdef\PfCNumD{1}%
  }{%
    \StrCut{#4}{/}{\PfCNumC}{\PfCNumD}%
  }%
  \xdef\PfCDivFoo{\PfCNumA/\PfCNumB,\PfCNumC/\PfCNumD}%
  \setsepchar[*]{,*/}\ignoreemptyitems%
  \readlist*\ListeFractions{\PfCDivFoo}%
  \reademptyitems%
  \setsepchar{,}%
  % Calculs
  \xdef\PfCDivNumFin{\fpeval{(\ListeFractions[1,1])*(\ListeFractions[2,2])}}%
  \xdef\PfCDivDenoFin{\fpeval{\ListeFractions[1,2]*\ListeFractions[2,1]}}%
  \PGCD{\fpeval{abs(\PfCDivNumFin)}}{\fpeval{abs(\PfCDivDenoFin)}}\xdef\PfCDivPgcd{\pgcd}%
  \xdef\PfCDivNumSimp{\fpeval{\PfCDivNumFin/\PfCDivPgcd}}%
  \xdef\PfCDivDenoSimp{\fpeval{\PfCDivDenoFin/\PfCDivPgcd}}%
  \xdef\PfCDivPdtSimp{\PfCDivNumSimp/\PfCDivDenoSimp}%
  \IfValueT{#5}{\xdef#5{\PfCDivPdtSimp}}%
  \ensuremath{%
    \IfValueTF{#2}{%
      \ifnum#2=4\relax
      \ifboolKV[CalculsFractions]{Negatif}{%
           \xintifboolexpr{\fpeval{\PfCDivNumSimp/\PfCDivDenoSimp}<0}{-\tofrac{\fpeval{abs(\PfCDivNumSimp)}/\fpeval{abs(\PfCDivDenoSimp)}}}{\tofrac{\PfCDivPdtSimp}}%
           }{\tofrac{\PfCDivPdtSimp}}%
      \else\ifnum#2=3\relax
      \MulFraction[][\fpeval{#2-1}]{\ListeFractions[1,1]/\ListeFractions[1,2]}{\ListeFractions[2,2]/\ListeFractions[2,1]}%
      \else
      \ifnum#2=2\relax%
      \MulFraction[][\fpeval{#2-1}]{\ListeFractions[1,1]/\ListeFractions[1,2]}{\ListeFractions[2,2]/\ListeFractions[2,1]}%
      \else%
      \ifnum#2=1\relax%
      \tofrac{\ListeFractions[1,1]/\ListeFractions[1,2]}\times\tofrac{\ListeFractions[2,2]/\ListeFractions[2,1]}
      \fi
      \fi
      \fi
      \fi
    }{\tofrac{#3}\div\tofrac{#4}
    }
  }%
}%