summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pas-cours/latex/macro-calculs.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/pas-cours/latex/macro-calculs.tex')
-rw-r--r--macros/latex/contrib/pas-cours/latex/macro-calculs.tex45
1 files changed, 45 insertions, 0 deletions
diff --git a/macros/latex/contrib/pas-cours/latex/macro-calculs.tex b/macros/latex/contrib/pas-cours/latex/macro-calculs.tex
new file mode 100644
index 0000000000..ae6f27cc5d
--- /dev/null
+++ b/macros/latex/contrib/pas-cours/latex/macro-calculs.tex
@@ -0,0 +1,45 @@
+% environnement "ifactors" : decomposition en produit de facteurs premiers
+
+\begin{VerbatimOut}{decomp.cxx}
+maple_mode(0);
+n:=read("n.val");
+F:=ifactors(n);
+l:=size(F);
+T:="";
+c:=0;
+for (k:=0;k<l;k:=k+2) { if c!=0 then T:=T+"\\times"; end_if T:=T+F[k]+"^{"+F[k+1]+"}"; c++; };
+Sortie:=fopen("decomp.tex");
+fprint(Sortie,Unquoted,T);
+fclose(Sortie);
+\end{VerbatimOut}
+
+\newenvironment*{ifactors}
+{\VerbatimEnvironment\begin{VerbatimOut}{n.val}}
+{\end{VerbatimOut}
+\immediate\write18{giac <decomp.cxx}
+\ensuremath{\input{decomp.tex}}
+}
+
+% environnement "ifactors_table"
+
+\begin{VerbatimOut}{decomp_table.cxx}
+maple_mode(0);
+n:=read("n.val");
+F:=ifactors(n);
+l:=size(F);
+for (k:=0;k<l;k:=k+2){ L[k/2]:=F[k]; };
+T:="\\begin{tabular}{r|l}";
+k:=0;
+while (n!=1) { T:=T+n+"&"; if (irem(n,L[k])==0) { T:=T+L[k]+"\\\\"; n:=n/L[k]; } else { k:=k+1; T:=T+L[k]+"\\\\"; n:=n/L[k]; }; };
+T:=T+"1 & \\\\\\end{tabular}";
+Sortie:=fopen("decomp_table.tex");
+fprint(Sortie,Unquoted,T);
+fclose(Sortie);
+\end{VerbatimOut}
+
+\newenvironment*{ifactorstable}
+{\VerbatimEnvironment\begin{VerbatimOut}{n.val}}
+{\end{VerbatimOut}
+\immediate\write18{giac <decomp_table.cxx}
+\input{decomp_table.tex}
+} \ No newline at end of file