summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/profsio/tex/ProfSio.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/profsio/tex/ProfSio.sty')
-rw-r--r--graphics/pgf/contrib/profsio/tex/ProfSio.sty252
1 files changed, 250 insertions, 2 deletions
diff --git a/graphics/pgf/contrib/profsio/tex/ProfSio.sty b/graphics/pgf/contrib/profsio/tex/ProfSio.sty
index 12d1804ec0..51e9325cfb 100644
--- a/graphics/pgf/contrib/profsio/tex/ProfSio.sty
+++ b/graphics/pgf/contrib/profsio/tex/ProfSio.sty
@@ -3,7 +3,8 @@
% : Luatruthtable from Chetan Shirore and Dr. Ajit Kumar https://ctan.org/pkg/luatruthtable
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ProfSio}[2023/12/13 0.1.9 Pour les enseignants de Maths en BTS SIO]
+\ProvidesPackage{ProfSio}[2023/02/07 0.2.0 Pour les enseignants de Maths en BTS SIO]
+%0.2.0 Travail sur les systèmes 3x3 par matrices et la présentation d'un produit matriciel
%0.1.9 Travail sur les chemins de longueur donnée + fermeture transitive
%0.1.8 Possibilité de représenter une table de Karnaugh via son expression + corrections mineures
%0.1.7 Ajout des simplifications booléennes d'expressions classiques
@@ -23,6 +24,10 @@
\RequirePackage{xstring}
\RequirePackage{listofitems}
\RequirePackage{xintexpr}
+\RequirePackage{systeme}
+\RequirePackage{ifthen}
+\RequirePackage{siunitx}
+\RequirePackage{nicematrix}
%------Librairies
\usetikzlibrary{positioning,decorations.pathreplacing,decorations.markings,arrows,arrows.meta,calc,babel,shapes,shapes.geometric}
%------Divers
@@ -991,7 +996,6 @@
\ifluatex
\RequirePackage{xkeyval}
\RequirePackage{luacode}
-\RequirePackage{nicematrix}
%patchs pour luatruthtable (échange 1ère ligne <-> dernière ligne), à voir si le package sera patché pour éviter de "piquer" le code !
%patchs from luatruthtable
@@ -1979,4 +1983,248 @@ end
}
\fi
+%===MATRICES ET SYSTÈMES 3x3
+%%------SimplFrac nouvelle version
+\NewDocumentCommand\IntConvFrac{ s O{} m }{%
+ %*=moins sur le numérateur
+ %2=argument optionnel[d/t/dec=...]
+ %3=argument mandataire {calcul ou fraction}
+ \def\calculargument{\xintPRaw{\xintIrr{\xinteval{#3}}}}%on calcule et on transforme en A/B
+ \IfSubStr{\calculargument}{/}%on teste si le symbole / apparaît
+ {%si oui := fraction
+ \StrBefore{\calculargument}{/}[\numerateur]%on extrait le numérateur
+ \StrBehind{\calculargument}{/}[\denominateur]%on extrait le dénominateur
+ \ifblank{#2}%
+ {%
+ \IfBooleanTF{#1}%
+ {\ensuremath{\frac{\num{\numerateur}}{\num{\denominateur}}}}%
+ {%
+ \ifthenelse{\numerateur < 0}%
+ {\ensuremath{-\frac{\num{\fpeval{abs(\numerateur)}}}{\num{\denominateur}}}}%
+ {\ensuremath{\frac{\num{\numerateur}}{\num{\denominateur}}}}%
+ }%
+ }%
+ {}%si l'argument optionnel est vide
+ \IfStrEq{#2}{d}%
+ {%
+ \IfBooleanTF{#1}%
+ {\ensuremath{\dfrac{\num{\numerateur}}{\num{\denominateur}}}}%
+ {%
+ \ifthenelse{\numerateur < 0}%
+ {\ensuremath{-\dfrac{\num{\fpeval{abs(\numerateur)}}}{\num{\denominateur}}}}%
+ {\ensuremath{\dfrac{\num{\numerateur}}{\num{\denominateur}}}}%
+ }%
+ }%
+ {}%si l'argument optionnel est vide
+ \IfStrEq{#2}{t}%
+ {%
+ \IfBooleanTF{#1}%
+ {\ensuremath{\tfrac{\num{\numerateur}}{\num{\denominateur}}}}%
+ {%
+ \ifthenelse{\numerateur < 0}%
+ {\ensuremath{-\tfrac{\num{\fpeval{abs(\numerateur)}}}{\num{\denominateur}}}}%
+ {\ensuremath{\tfrac{\num{\numerateur}}{\num{\denominateur}}}}%
+ }%
+ }%
+ {}%si l'argument optionnel est vide
+ \IfStrEq{#2}{n}%
+ {%
+ \ensuremath{\nicefrac{\num{\numerateur}}{\num{\denominateur}}}
+ }%
+ {}%si l'argument optionnel est vide
+ \IfSubStr{#2}{dec}%on veut la forme décimale
+ {%
+ \IfSubStr{#2}{=}%si on rajoute une précision
+ {%
+ \StrBehind{#2}{=}[\precdecimal]%
+ \ensuremath{\num{\xintfloateval{round(#3,\precdecimal)}}}%
+ }%
+ {%
+ \ensuremath{\num{\xintfloateval{#3}}}%
+ }%
+ }%
+ {}%si l'argument optionnel est vide
+ }{%si non := entier
+ \num{\calculargument}%on affiche l'entier, avec le package siunitx
+ }%
+}
+
+%type=3x3
+\defKV[resolsysmatrix]{%
+ NomsMatrices=\def\ResolSysMatNames{#1},%
+ Inconnues=\edef\ResolSysMatUnkn{#1},%
+ NomInverse=\def\ResolSysMatInv{#1},%
+ NomSysteme=\def\ResolSysMatNameSys{#1},%
+ OptionNiceMatrix=\def\ResolSysMatOpt{#1}
+}
+\setKVdefault[resolsysmatrix]{%
+ NomsMatrices={A,X,B},%
+ NomInverse={A^{-1}},%
+ NomSysteme={},%
+ Inconnues=xyz,%
+ Brut=false,%
+ OptionNiceMatrix={1pt}
+}
+
+\NewDocumentCommand\ResolSystemeMatrices{ O{} D<>{} m O{#3} O{xyz} }{%
+ %1=clés
+ %2=option formatage conversion
+ %3=système {eq1,eq2,eq3} en langage xint
+ %4=sytème pour la macro \systeme
+ %5=inconnues pour \systeme
+ \useKVdefault[resolsysmatrix]%
+ \setKV[resolsysmatrix]{#1}%
+ %lectures des inconnues
+ \StrChar{\ResolSysMatUnkn}{1}[\tmpinconnuex]%
+ \StrChar{\ResolSysMatUnkn}{2}[\tmpinconnuey]%
+ \StrChar{\ResolSysMatUnkn}{3}[\tmpinconnuez]%
+ %lectures des noms de matrices
+ \readlist*\TmpLstUnkb{\ResolSysMatNames}%
+ \itemtomacro\TmpLstUnkb[1]{\tmpnamematA}%
+ \itemtomacro\TmpLstUnkb[2]{\tmpnamematX}%
+ \itemtomacro\TmpLstUnkb[3]{\tmpnamematB}%
+ %lecture des équations
+ \readlist*\TmpLstEq{#3}%
+ \itemtomacro\TmpLstEq[1]\TmpEqA%
+ \itemtomacro\TmpLstEq[2]\TmpEqB%
+ \itemtomacro\TmpLstEq[3]\TmpEqC%
+ %extraction des coefficients
+ \StrCut{\TmpEqA}{=}{\tmpeqa}{\MatBA}%
+ \StrCut{\TmpEqB}{=}{\tmpeqb}{\MatBB}%
+ \StrCut{\TmpEqC}{=}{\tmpeqc}{\MatBC}%
+ %MatA (1,1)
+ \StrSubstitute{\tmpeqa}{\tmpinconnuex}{(1)}[\MatA]%
+ \StrSubstitute{\MatA}{\tmpinconnuey}{(0)}[\MatA]%
+ \StrSubstitute{\MatA}{\tmpinconnuez}{(0)}[\MatA]%
+ %MatB (1,2)
+ \StrSubstitute{\tmpeqa}{\tmpinconnuey}{(1)}[\MatB]%
+ \StrSubstitute{\MatB}{\tmpinconnuex}{(0)}[\MatB]%
+ \StrSubstitute{\MatB}{\tmpinconnuez}{(0)}[\MatB]%
+ %MatC (1,3)
+ \StrSubstitute{\tmpeqa}{\tmpinconnuez}{(1)}[\MatC]%
+ \StrSubstitute{\MatC}{\tmpinconnuex}{(0)}[\MatC]%
+ \StrSubstitute{\MatC}{\tmpinconnuey}{(0)}[\MatC]%
+ %MatD (2,1)
+ \StrSubstitute{\tmpeqb}{\tmpinconnuex}{(1)}[\MatD]%
+ \StrSubstitute{\MatD}{\tmpinconnuey}{(0)}[\MatD]%
+ \StrSubstitute{\MatD}{\tmpinconnuez}{(0)}[\MatD]%
+ %MatE (2,2)
+ \StrSubstitute{\tmpeqb}{\tmpinconnuey}{(1)}[\MatE]%
+ \StrSubstitute{\MatE}{\tmpinconnuex}{(0)}[\MatE]%
+ \StrSubstitute{\MatE}{\tmpinconnuez}{(0)}[\MatE]%
+ %MatF (2,3)
+ \StrSubstitute{\tmpeqb}{\tmpinconnuez}{(1)}[\MatF]%
+ \StrSubstitute{\MatF}{\tmpinconnuex}{(0)}[\MatF]%
+ \StrSubstitute{\MatF}{\tmpinconnuey}{(0)}[\MatF]%
+ %MatG (3,1)
+ \StrSubstitute{\tmpeqc}{\tmpinconnuex}{(1)}[\MatG]%
+ \StrSubstitute{\MatG}{\tmpinconnuey}{(0)}[\MatG]%
+ \StrSubstitute{\MatG}{\tmpinconnuez}{(0)}[\MatG]%
+ %MatH (3,2)
+ \StrSubstitute{\tmpeqc}{\tmpinconnuey}{(1)}[\MatH]%
+ \StrSubstitute{\MatH}{\tmpinconnuex}{(0)}[\MatH]%
+ \StrSubstitute{\MatH}{\tmpinconnuez}{(0)}[\MatH]%
+ %MatI (3,3)
+ \StrSubstitute{\tmpeqc}{\tmpinconnuez}{(1)}[\MatI]%
+ \StrSubstitute{\MatI}{\tmpinconnuex}{(0)}[\MatI]%
+ \StrSubstitute{\MatI}{\tmpinconnuey}{(0)}[\MatI]%
+ %déterminant
+ \def\DETMATRICE{\xinteval{(\MatA)*(\MatE)*(\MatI)+(\MatD)*(\MatH)*(\MatC)+(\MatB)*(\MatF)*(\MatG)-(\MatG)*(\MatE)*(\MatC)-(\MatD)*(\MatB)*(\MatI)-(\MatA)*(\MatH)*(\MatF)}}%
+ %inverse, à voir après pour le cas non inversible...
+ \xintifboolexpr{\DETMATRICE == 0}%
+ {}%
+ {%
+ \def\MatInvA{((\MatE)*(\MatI)-(\MatH)*(\MatF))/(\DETMATRICE)}%
+ \def\MatInvB{(-(\MatB)*(\MatI)+(\MatC)*(\MatH))/(\DETMATRICE)}%
+ \def\MatInvC{((\MatB)*(\MatF)-(\MatC)*(\MatE))/(\DETMATRICE)}%
+ \def\MatInvD{(-(\MatD)*(\MatI)+(\MatF)*(\MatG))/(\DETMATRICE)}%
+ \def\MatInvE{((\MatA)*(\MatI)-(\MatC)*(\MatG))/(\DETMATRICE)}%
+ \def\MatInvF{(-(\MatA)*(\MatF)+(\MatD)*(\MatC))/(\DETMATRICE)}%
+ \def\MatInvG{((\MatD)*(\MatH)-(\MatE)*(\MatG))/(\DETMATRICE)}%
+ \def\MatInvH{(-(\MatA)*(\MatH)+(\MatB)*(\MatG))/(\DETMATRICE)}%
+ \def\MatInvI{((\MatA)*(\MatE)-(\MatB)*(\MatD))/(\DETMATRICE)}%
+ %résultat
+ \def\MatResA{\IntConvFrac[#2]{(\MatInvA)*(\MatBA)+(\MatInvB)*(\MatBB)+(\MatInvC)*(\MatBC)}}%
+ \def\MatResB{\IntConvFrac[#2]{(\MatInvD)*(\MatBA)+(\MatInvE)*(\MatBB)+(\MatInvF)*(\MatBC)}}%
+ \def\MatResC{\IntConvFrac[#2]{(\MatInvG)*(\MatBA)+(\MatInvH)*(\MatBB)+(\MatInvI)*(\MatBC)}}%
+ \def\MatAffInvA{\IntConvFrac[#2]{\MatInvA}}%
+ \def\MatAffInvB{\IntConvFrac[#2]{\MatInvB}}%
+ \def\MatAffInvC{\IntConvFrac[#2]{\MatInvC}}%
+ \def\MatAffInvD{\IntConvFrac[#2]{\MatInvD}}%
+ \def\MatAffInvE{\IntConvFrac[#2]{\MatInvE}}%
+ \def\MatAffInvF{\IntConvFrac[#2]{\MatInvF}}%
+ \def\MatAffInvG{\IntConvFrac[#2]{\MatInvG}}%
+ \def\MatAffInvH{\IntConvFrac[#2]{\MatInvH}}%
+ \def\MatAffInvI{\IntConvFrac[#2]{\MatInvI}}%
+ }%
+ %affichage pour test
+ \def\MatAffA{\IntConvFrac[#2]{\MatA}}%
+ \def\MatAffB{\IntConvFrac[#2]{\MatB}}%
+ \def\MatAffC{\IntConvFrac[#2]{\MatC}}%
+ \def\MatAffD{\IntConvFrac[#2]{\MatD}}%
+ \def\MatAffE{\IntConvFrac[#2]{\MatE}}%
+ \def\MatAffF{\IntConvFrac[#2]{\MatF}}%
+ \def\MatAffG{\IntConvFrac[#2]{\MatG}}%
+ \def\MatAffH{\IntConvFrac[#2]{\MatH}}%
+ \def\MatAffI{\IntConvFrac[#2]{\MatI}}%
+ \def\MatAffBA{\IntConvFrac[#2]{\MatBA}}%
+ \def\MatAffBB{\IntConvFrac[#2]{\MatBB}}%
+ \def\MatAffBC{\IntConvFrac[#2]{\MatBC}}%
+ \ifboolKV[resolsysmatrix]{Brut}%
+ {%
+ \def\ResolDet{\IntConvFrac[#2]{(\MatA)*(\MatE)*(\MatI)+(\MatD)*(\MatH)*(\MatC)+(\MatB)*(\MatF)*(\MatG)-(\MatG)*(\MatE)*(\MatC)-(\MatD)*(\MatB)*(\MatI)-(\MatA)*(\MatH)*(\MatF)}}%
+ \def\ResolMatA{\begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] {\MatAffA}&{\MatAffB}&{\MatAffC} \\ {\MatAffD}&{\MatAffE}&{\MatAffF} \\ {\MatAffG}&{\MatAffH}&{\MatAffI} \end{pNiceMatrix}}%
+ \def\ResolMatX{\begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] \tmpinconnuex \\ \tmpinconnuey \\ \tmpinconnuez \end{pNiceMatrix}}%
+ \def\ResolMatB{\begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] {\MatAffBA} \\ {\MatAffBB} \\ {\MatAffBC} \end{pNiceMatrix}}%
+ \xintifboolexpr{\DETMATRICE == 0}%
+ {%
+ \def\ResolInvMatA{\text{La matrice n'est pas inversible.}}%
+ }%
+ {%
+ \def\ResolSolX{\IntConvFrac[#2]{(\MatInvA)*(\MatBA)+(\MatInvB)*(\MatBB)+(\MatInvC)*(\MatBC)}}%
+ \def\ResolSolY{\IntConvFrac[#2]{(\MatInvD)*(\MatBA)+(\MatInvE)*(\MatBB)+(\MatInvF)*(\MatBC)}}%
+ \def\ResolSolZ{\IntConvFrac[#2]{(\MatInvG)*(\MatBA)+(\MatInvH)*(\MatBB)+(\MatInvI)*(\MatBC)}}%
+ \def\ResolInvMatA{\begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] {\MatAffInvA}&{\MatAffInvB}&{\MatAffInvC} \\ {\MatAffInvD}&{\MatAffInvE}&{\MatAffInvF} \\ {\MatAffInvG}&{\MatAffInvH}&{\MatAffInvI} \end{pNiceMatrix}}%
+ }%
+ }%
+ {%
+ On considère le système $\IfEq{\ResolSysMatNameSys}{}{}{\ResolSysMatNameSys \text{ : }} \systeme[#5]{#4}$.\\
+ Matriciellement, le système s'écrit sous la forme $\tmpnamematA\times \tmpnamematX = \tmpnamematB$ avec :%
+ \[%
+ \tmpnamematA = \begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] {\MatAffA}&{\MatAffB}&{\MatAffC} \\ {\MatAffD}&{\MatAffE}&{\MatAffF} \\ {\MatAffG}&{\MatAffH}&{\MatAffI} \end{pNiceMatrix}
+ \text{ ; }
+ \tmpnamematX = \begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] \tmpinconnuex \\ \tmpinconnuey \\ \tmpinconnuez \end{pNiceMatrix}
+ \text{ et }
+ \tmpnamematB = \begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] {\MatAffBA} \\ {\MatAffBB} \\ {\MatAffBC} \end{pNiceMatrix}
+ \]%
+ \xintifboolexpr{\DETMATRICE == 0}%
+ {%
+ La matrice $\tmpnamematA$ n'est pas inversible, donc le système n'admet pas de solution (ou admet une unifinité de solutions).%
+ }%
+ {%
+ La matrice $\tmpnamematA$ est inversible, et :%
+ \[\tmpnamematA\times \tmpnamematX = \tmpnamematB \implies \underbrace{\ResolSysMatInv \times \tmpnamematA}_{{=}I_3} \times \tmpnamematX = \ResolSysMatInv \times \tmpnamematB \implies I_3 \times \tmpnamematX = \ResolSysMatInv\times \tmpnamematB \implies \tmpnamematX=\ResolSysMatInv\times \tmpnamematB.\]
+ %
+ La calculatrice nous donne $\tmpnamematX = \begin{pNiceMatrix}[cell-space-limits=\ResolSysMatOpt] {\MatResA} \\ {\MatResB} \\ {\MatResC} \end{pNiceMatrix}$. Ainsi on obtient $\tmpinconnuex=\MatResA$ et $\tmpinconnuey=\MatResB$ et $\tmpinconnuez=\MatResC$.%
+ }%
+ }%
+}
+
+%===PRESENTATION PRODUIT MATRICES
+\NewDocumentCommand\PresentProdMat{ s D<>{} m m m D<>{} }{%
+ \begin{tikzpicture}[inner sep=0pt,outer sep=0pt,#2]
+ \IfBooleanTF{#1}%
+ {%
+ \node (MatriceA) at (0,0) {{$\begin{pNiceMatrix}[#6] #3 \end{pNiceMatrix}$}} ;
+ \node[right=0pt of MatriceA,anchor=west] (MatriceAB) {{$\begin{pNiceMatrix}[#6] #5 \end{pNiceMatrix}$}} ;
+ \node[above=0pt of MatriceAB,anchor=south] (MatriceB) {{$\begin{pNiceMatrix}[#6] #4 \end{pNiceMatrix}$}} ;
+ }%
+ {%
+ \node (MatriceA) at (0,0) {{$\begin{pmatrix} #3 \end{pmatrix}$}} ;
+ \node[right=0pt of MatriceA,anchor=west] (MatriceAB) {{$\begin{pmatrix} #5 \end{pmatrix}$}} ;
+ \node[above=0pt of MatriceAB,anchor=south] (MatriceB) {{$\begin{pmatrix} #4 \end{pmatrix}$}} ;
+ }%
+ \end{tikzpicture}%
+}
+
\endinput \ No newline at end of file