summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/proflycee/tex/ProfLycee.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/proflycee/tex/ProfLycee.sty')
-rw-r--r--macros/latex/contrib/proflycee/tex/ProfLycee.sty48
1 files changed, 46 insertions, 2 deletions
diff --git a/macros/latex/contrib/proflycee/tex/ProfLycee.sty b/macros/latex/contrib/proflycee/tex/ProfLycee.sty
index c16b078219..211b16dcb1 100644
--- a/macros/latex/contrib/proflycee/tex/ProfLycee.sty
+++ b/macros/latex/contrib/proflycee/tex/ProfLycee.sty
@@ -3,7 +3,8 @@
% or later, see http://www.latex-project.org/lppl.txtf
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{ProfLycee}[2022/12/30 2.1.3 Aide pour l'utilisation de LaTeX en lycee]
+\ProvidesPackage{ProfLycee}[2023/01/02 2.1.4 Aide pour l'utilisation de LaTeX en lycee]
+% 2.1.4 Ajout d'une commande pour résoudre de manière approchée une équation f(x)=k
% 2.1.3 Ajout de l'option auto-tabs-gobble sur piton (v1.0) + correction d'un bug sur CodePiton
% 2.1.2 Ajout d'une commande pour déterminer la mesure principale d'un angle + option <ElargirOx/y> pour les axes
% 2.1.1 Ajout d'une section pour les tracés de repère et courbe, en tikz
@@ -89,7 +90,8 @@
\RequirePackage{hvlogos}
\RequirePackage{fancyvrb}
\RequirePackage{siunitx} %test avec v3
-\sisetup{locale=FR,output-decimal-marker={,},%
+\sisetup{%
+ locale=FR,output-decimal-marker={,},%
mode = match, propagate-math-font = true,%
reset-math-version = false, reset-text-family = false,%
reset-text-series = false, reset-text-shape = false,%
@@ -3574,4 +3576,46 @@
}%
}
+%================DICHOTOMIE============== OK!
+\defKV[SolDichoto]{%
+ Precision=\xdef\DICHOTOstep{#1},%
+ Intervalle=\xdef\DICHOTOinterv{#1},%
+ Variable=\xdef\DICHOTOvar{#1}
+}
+
+\setKVdefault[SolDichoto]{%
+ Precision=2,%
+ Variable=x,%
+ Intervalle={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)}}%
+}
+
\endinput \ No newline at end of file