summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pas-cours/latex/macro-calculs.tex
blob: ae6f27cc5d9238747950ddcc7279bd186a767d89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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}
}