need to clean...
This commit is contained in:
parent
46417c2853
commit
70096cf075
117
example/1_2ndDeg.tex
Normal file
117
example/1_2ndDeg.tex
Normal file
@ -0,0 +1,117 @@
|
||||
\documentclass[a4paper,10pt]{article}
|
||||
\RequirePackage[utf8x]{inputenc}
|
||||
\RequirePackage[francais]{babel}
|
||||
\RequirePackage{amssymb}
|
||||
\RequirePackage{amsmath}
|
||||
\RequirePackage{amsfonts}
|
||||
\RequirePackage{subfig}
|
||||
\RequirePackage{graphicx}
|
||||
\RequirePackage{color}
|
||||
|
||||
|
||||
|
||||
% Title Page
|
||||
\title{Calcul littéral et statistiques}
|
||||
\date{\today}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
|
||||
\section{Polynômes}
|
||||
|
||||
|
||||
|
||||
|
||||
Résoudre l'équation suivante
|
||||
\begin{eqnarray*}
|
||||
3 x^{ 2 } + 6 x + 3 & = & 0
|
||||
\end{eqnarray*}
|
||||
|
||||
Solution:
|
||||
|
||||
|
||||
|
||||
On commence par calculer le discriminant de $P(x) = 3 x^{ 2 } + 6 x + 3$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & 6^{ 2 } - 4 \times 3 \times 3 \\
|
||||
\Delta & = & 36 - 4 \times 9 \\
|
||||
\Delta & = & 36 - 36 \\
|
||||
\Delta & = & 0
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
Comme $\Delta = 0$ donc $P$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \frac{-6}{2\times 3} = -1 \\
|
||||
\end{eqnarray*}
|
||||
|
||||
La solution de $3 x^{ 2 } + 6 x + 3 = 0$ est donc $\mathcal{S} = \left\{ -1\right\}$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\bigskip
|
||||
~\dotfill
|
||||
\bigskip
|
||||
|
||||
|
||||
|
||||
|
||||
Résoudre l'équation suivante
|
||||
\begin{eqnarray*}
|
||||
x^{ 2 } + 4 x + 2 & = & - 9 x^{ 2 } + 9 x + 5
|
||||
\end{eqnarray*}
|
||||
|
||||
Solution:
|
||||
|
||||
On commence par se ramener à une équation de la forme $ax^2+bx+c = 0$.
|
||||
|
||||
|
||||
|
||||
\begin{align*}
|
||||
& & x^{ 2 } + 4 x + 2 = - 9 x^{ 2 } + 9 x + 5 \\
|
||||
& \Leftrightarrow & x^{ 2 } + 4 x + 2 - ( - 9 x^{ 2 } + 9 x + 5 )= 0 \\
|
||||
& \Leftrightarrow & x^{ 2 } + 4 x + 2 + 9 x^{ 2 } - 9 x - 5= 0 \\
|
||||
& \Leftrightarrow & ( 1 + 9 ) x^{ 2 } + ( 4 - 9 ) x + 2 - 5= 0 \\
|
||||
& \Leftrightarrow & 10 x^{ 2 } - 5 x - 3= 0
|
||||
\end{align*}
|
||||
|
||||
On cherche maintenant à résoudre l'équation $10 x^{ 2 } - 5 x - 3 = 0$.
|
||||
|
||||
|
||||
|
||||
On commence par calculer le discriminant de $P(x) = 10 x^{ 2 } - 5 x - 3$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & -5^{ 2 } - 4 \times 10 \times ( -3 ) \\
|
||||
\Delta & = & 25 - 4 \times ( -30 ) \\
|
||||
\Delta & = & 25 - ( -120 ) \\
|
||||
\Delta & = & 145
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
comme $\Delta = 145 > 0$ donc $P$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{-5 - \sqrt{145}}{2 \times 10} = - \frac{\sqrt{145}}{20} + \frac{1}{4} \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{-5 + \sqrt{145}}{2 \times 10} = \frac{1}{4} + \frac{\sqrt{145}}{20}
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions de l'équation $10 x^{ 2 } - 5 x - 3 = 0$ sont donc $\mathcal{S} = \left\{ - \frac{\sqrt{145}}{20} + \frac{1}{4}; \frac{1}{4} + \frac{\sqrt{145}}{20} \right\}$
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
\end{document}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "master"
|
||||
%%% End:
|
||||
|
||||
|
308
example/1_corr_DM_0302.tex
Normal file
308
example/1_corr_DM_0302.tex
Normal file
@ -0,0 +1,308 @@
|
||||
\documentclass[a4paper,10pt, table]{/media/documents/Cours/Prof/Enseignements/tools/style/classDS}
|
||||
\usepackage{/media/documents/Cours/Prof/Enseignements/2014_2015}
|
||||
|
||||
% Title Page
|
||||
\titre{DM5}
|
||||
% \seconde \premiereS \PSTMG \TSTMG
|
||||
\classe{\premiereS}
|
||||
\date{02 mars 2015}
|
||||
%\duree{1 heure}
|
||||
\sujet{1}
|
||||
% DS DSCorr DM DMCorr Corr
|
||||
\typedoc{DM}
|
||||
|
||||
\printanswers
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
Le barème est donné à titre indicatif, il pourra être modifié. Vous rendrez le sujet avec la copie.
|
||||
|
||||
\begin{questions}
|
||||
|
||||
\question
|
||||
Résoudre les équations suivantes
|
||||
|
||||
|
||||
\begin{eqnarray*}
|
||||
8 x^{ 2 } + 5 x - 2 & > &0 \\
|
||||
\end{eqnarray*}
|
||||
|
||||
\begin{solution}
|
||||
On commence par calculer le discriminant de $P(x) = 8 x^{ 2 } + 5 x - 2$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & 5^{ 2 } - 4 \times 8 ( -2 ) \\
|
||||
\Delta & = & 25 - 4 ( -16 ) \\
|
||||
\Delta & = & 25 - ( -64 ) \\
|
||||
\Delta & = & 89
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
comme $\Delta = 89 > 0$ donc $P$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{5 - \sqrt{89}}{2 \times 8} = -0.9 \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{5 + \sqrt{89}}{2 \times 8} = 0.28
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
Comme $a = 8$, on en déduit le tableau de signe de $P$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, $P$/2}%
|
||||
{$-\infty$, -0.9 , 0.28 , $+\infty$}
|
||||
\tkzTabLine{, +, z, -, z , +,}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
On regarde maintenant où sont les $+$ dans le tableau de signe pour résoudre l'inéquation.
|
||||
\end{solution}
|
||||
|
||||
\begin{eqnarray*}
|
||||
- 3 x^{ 2 } + 2 x + 4 & \leq &0 \\
|
||||
\end{eqnarray*}
|
||||
\begin{solution}
|
||||
On commence par calculer le discriminant de $Q(x) = - 3 x^{ 2 } + 2 x + 4$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & 2^{ 2 } - 4 ( -3 ) \times 4 \\
|
||||
\Delta & = & 4 - 4 ( -12 ) \\
|
||||
\Delta & = & 4 - ( -48 ) \\
|
||||
\Delta & = & 52
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
comme $\Delta = 52 > 0$ donc $Q$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{2 - \sqrt{52}}{2 \times -3} = 1.54 \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{2 + \sqrt{52}}{2 \times -3} = -0.87
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
Comme $a = -3$, on en déduit le tableau de signe de $Q$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, $Q$/2}%
|
||||
{$-\infty$, -0.87 , 1.54 , $+\infty$}
|
||||
\tkzTabLine{, -, z, +, z , -,}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
On regarde maintenant où sont les $-$ dans le tableau de signe pour résoudre l'inéquation.
|
||||
\end{solution}
|
||||
|
||||
\begin{eqnarray*}
|
||||
8 x^{ 2 } + 5 x - 2 & \geq & - 3 x^{ 2 } + 2 x + 4
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
\begin{solution}
|
||||
On commence par se ramener à une équation de la forme $ax^2 + bx + c \geq 0$.
|
||||
\begin{eqnarray*}
|
||||
8 x^{ 2 } + 5 x - 2 \geq - 3 x^{ 2 } + 2 x + 4 & \Leftrightarrow & 8 x^{ 2 } + 5 x - 2 - (- 3 x^{ 2 } + 2 x + 4) \geq 0 \\
|
||||
& \Leftrightarrow & 8 x^{ 2 } + 5 x - 2 - ( - 3 x^{ 2 } + 2 x + 4 )\geq 0 \\
|
||||
& \Leftrightarrow & 8 x^{ 2 } + 5 x - 2 + 3 x^{ 2 } - 2 x - 4\geq 0 \\
|
||||
& \Leftrightarrow & ( 8 + 3 ) x^{ 2 } + ( 5 + ( -2 ) ) x + ( -2 ) + ( -4 )\geq 0 \\
|
||||
& \Leftrightarrow & 11 x^{ 2 } + 3 x - 6\geq 0
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
Ensuite on étudie le signe de $R(X) = 11 x^{ 2 } + 3 x - 6$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & 3^{ 2 } - 4 \times 11 ( -6 ) \\
|
||||
\Delta & = & 9 - 4 ( -66 ) \\
|
||||
\Delta & = & 9 - ( -264 ) \\
|
||||
\Delta & = & 273
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
comme $\Delta = 273 > 0$ donc $R$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{3 - \sqrt{273}}{2 \times 11} = -0.89 \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{3 + \sqrt{273}}{2 \times 11} = 0.61
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
Comme $a = 11$, on en déduit le tableau de signe de $R$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, $R$/2}%
|
||||
{$-\infty$, -0.89 , 0.61 , $+\infty$}
|
||||
\tkzTabLine{, +, z, -, z , +,}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
On regarde maintenant où sont les $+$ dans le tableau de signe pour résoudre l'inéquation.
|
||||
|
||||
|
||||
\end{solution}
|
||||
|
||||
|
||||
\question
|
||||
Tracer le tableau de variation des fonctions suivantes \textit{(Vous pouvez utiliser les nombres à virgules)}
|
||||
|
||||
|
||||
\begin{parts}
|
||||
\part $f:x\mapsto - 10 x^{ 3 } + x^{ 2 } - 7 x + 5$
|
||||
\begin{solution}
|
||||
Pour avoir les variations de $f$, il faut connaître le signe de sa dérivé. On dérive $P$
|
||||
|
||||
\begin{eqnarray*}
|
||||
f'(x) & = & 3 ( -10 ) x^{ 2 } + 2 \times 1 x + 1 ( -7 ) \\
|
||||
f'(x) & = & - 30 x^{ 2 } + 2 x - 7
|
||||
\end{eqnarray*}
|
||||
|
||||
On étudie le signe de $P'$
|
||||
|
||||
Ensuite on étudie le signe de $f'(x) = - 30 x^{ 2 } + 2 x - 7$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & 2^{ 2 } - 4 ( -30 ) ( -7 ) \\
|
||||
\Delta & = & 4 - 4 \times 210 \\
|
||||
\Delta & = & 4 - 840 \\
|
||||
\Delta & = & -836
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
Alors $\Delta = -836 < 0$ donc $f'$ n'a pas de racine.
|
||||
|
||||
|
||||
Comme $a = -30$, on en déduit le tableau de signe de $f'$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, Signe de $f' $/2}%
|
||||
{$-\infty$, $+\infty$}
|
||||
\tkzTabLine{, -,}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\end{solution}
|
||||
|
||||
|
||||
|
||||
\part $g:x\mapsto - 9 x^{ 3 } - 8 x^{ 2 } - 5 x - 2$
|
||||
|
||||
\begin{solution}
|
||||
Pour avoir les variations de $g$, il faut connaître le signe de sa dérivé. On dérive $P$
|
||||
|
||||
\begin{eqnarray*}
|
||||
g'(x) & = & 3 ( -9 ) x^{ 2 } + 2 ( -8 ) x + 1 ( -5 ) \\
|
||||
g'(x) & = & - 27 x^{ 2 } - 16 x - 5
|
||||
\end{eqnarray*}
|
||||
|
||||
On étudie le signe de $P'$
|
||||
|
||||
Ensuite on étudie le signe de $g'(x) = - 27 x^{ 2 } - 16 x - 5$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & ( -16 )^{ 2 } - 4 ( -27 ) ( -5 ) \\
|
||||
\Delta & = & 256 - 4 \times 135 \\
|
||||
\Delta & = & 256 - 540 \\
|
||||
\Delta & = & -284
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
Alors $\Delta = -284 < 0$ donc $g'$ n'a pas de racine.
|
||||
|
||||
|
||||
Comme $a = -27$, on en déduit le tableau de signe de $g'$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, Signe de $g' $/2}%
|
||||
{$-\infty$, $+\infty$}
|
||||
\tkzTabLine{, -,}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\end{solution}
|
||||
|
||||
|
||||
\part $h:x\mapsto - 7 x^{ 2 } - 9 x + 3 - f(x)$
|
||||
|
||||
|
||||
|
||||
|
||||
\begin{solution}
|
||||
On commence par simplifier l'expression de $h$
|
||||
\begin{eqnarray*}
|
||||
h(x) & = & - 7 x^{ 2 } - 9 x + 3 - f(x) \\
|
||||
h(x) & = & - 7 x^{ 2 } - 9 x + 3 - ( - 10 x^{ 3 } + x^{ 2 } - 7 x + 5 ) \\
|
||||
h(x) & = & - 7 x^{ 2 } - 9 x + 3 + 10 x^{ 3 } - x^{ 2 } + 7 x - 5 \\
|
||||
h(x) & = & 10 x^{ 3 } + ( ( -7 ) + ( -1 ) ) x^{ 2 } + ( ( -9 ) + 7 ) x + 3 + ( -5 ) \\
|
||||
h(x) & = & 10 x^{ 3 } - 8 x^{ 2 } - 2 x - 2
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
Pour avoir les variations de $h$, il faut connaître le signe de sa dérivé. On dérive $P$
|
||||
|
||||
\begin{eqnarray*}
|
||||
h'(x) & = & 3 \times 10 x^{ 2 } + 2 ( -8 ) x + 1 ( -2 ) \\
|
||||
h'(x) & = & 30 x^{ 2 } - 16 x - 2
|
||||
\end{eqnarray*}
|
||||
|
||||
On étudie le signe de $P'$
|
||||
|
||||
Ensuite on étudie le signe de $h'(x) = 30 x^{ 2 } - 16 x - 2$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & ( -16 )^{ 2 } - 4 \times 30 ( -2 ) \\
|
||||
\Delta & = & 256 - 4 ( -60 ) \\
|
||||
\Delta & = & 256 - ( -240 ) \\
|
||||
\Delta & = & 496
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
comme $\Delta = 496 > 0$ donc $h'$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{-16 - \sqrt{496}}{2 \times 30} = -0.1 \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{-16 + \sqrt{496}}{2 \times 30} = 0.64
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
Comme $a = 30$, on en déduit le tableau de signe de $h'$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, Signe de $h' $/2}%
|
||||
{$-\infty$, -0.1 , 0.64 , $+\infty$}
|
||||
\tkzTabLine{, +, z, -, z , +,}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\end{solution}
|
||||
\end{parts}
|
||||
|
||||
\question
|
||||
Appliquer l'algorithme de tri vu en cours à la suite suivante
|
||||
\begin{center}
|
||||
\begin{tabular}{|*{6}{c|}}
|
||||
\hline
|
||||
6914 & 6851 & 6532 & 6884 & 6164 & 6495 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
\end{center}
|
||||
|
||||
|
||||
\end{questions}
|
||||
|
||||
\end{document}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "master"
|
||||
%%% End:
|
0
example/1_play.tex
Normal file
0
example/1_play.tex
Normal file
BIN
example/all_2ndDeg.pdf
Normal file
BIN
example/all_2ndDeg.pdf
Normal file
Binary file not shown.
BIN
example/all_corr_DM_0302.pdf
Normal file
BIN
example/all_corr_DM_0302.pdf
Normal file
Binary file not shown.
23
example/poly.tex
Normal file
23
example/poly.tex
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
\Block{set A = Expression.random("{a} / 2 + 2")}
|
||||
\Block{set P = Polynom.random(["{b}","{a}"])}
|
||||
\Block{set Q = Polynom.random(["{b+2}","{a}"])}
|
||||
\Block{set R = P('x')*Q('x') }
|
||||
|
||||
\Block{set exps = [A, P, Q, R]}
|
||||
\Block{set names = ["A", "B", "C", "D"]}
|
||||
|
||||
Développer et réduire les expressions suivantes:
|
||||
\begin{eqnarray*}
|
||||
\Block{for i in range(4)}
|
||||
\Var{ names[i]} &=& \Var{exps[i]} \\
|
||||
\Block{endfor}
|
||||
\end{eqnarray*}
|
||||
|
||||
Solutions:
|
||||
\Var{A.simplify() | calculus}
|
||||
\Var{P(2).simplify() | calculus(name = "P(2)")}
|
||||
\Var{Q(2).simplify() | calculus(name = "Q(2)")}
|
||||
\Var{(P+Q) | calculus(name = "P(x) + Q(X)")}
|
||||
\Var{(P('x')+Q('x')).simplify() | calculus(name = "P(x) + Q(X)")}
|
||||
\Var{R.simplify() | calculus(name = "R(x)")}
|
@ -8,6 +8,8 @@
|
||||
\RequirePackage{graphicx}
|
||||
\RequirePackage{color}
|
||||
|
||||
\Block{from "macros/poly2Deg.tex" import solveEquation}
|
||||
|
||||
% Title Page
|
||||
\title{Calcul littéral et statistiques}
|
||||
\date{\today}
|
||||
@ -28,35 +30,7 @@
|
||||
|
||||
Solution:
|
||||
|
||||
On commence par calculer le discriminant de $P(x) = \Var{P}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{P.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if P.delta > 0}
|
||||
comme $\Delta = \Var{P.delta} > 0$ donc $P$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-P.b} - \sqrt{\Var{P.delta}}}{2 \times \Var{P.a}} = \Var{P.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P.b} + \sqrt{\Var{P.delta}}}{2 \times \Var{P.a}} = \Var{P.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions de l'équation $\Var{P} = 0$ sont donc $\mathcal{S} = \left\{ \Var{min(P.roots())}; \Var{max(P.roots())} \right\}$
|
||||
|
||||
\Block{elif P.delta == 0}
|
||||
Comme $\Delta = 0$ donc $P$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{P.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
La solution de $\Var{P} = 0$ est donc $\mathcal{S} = \left\{ \Var{P.roots()[0]}\right\}$
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{P.delta} < 0$ donc $P$ n'a pas de racine donc l'équation $\var{P} = 0$ n'a pas de solution.
|
||||
|
||||
\Block{endif}
|
||||
\Var{solveEquation(P)}
|
||||
|
||||
\bigskip
|
||||
~\dotfill
|
||||
@ -74,45 +48,16 @@
|
||||
|
||||
On commence par se ramener à une équation de la forme $ax^2+bx+c = 0$.
|
||||
|
||||
\Block{set R = Polynom_deg2((P-Q)._coef)}
|
||||
\Block{set R = P - Q}
|
||||
|
||||
\begin{eqnarray*}
|
||||
\Var{P} = \Var{Q} & \Leftrightarrow & \Var{P} - (\Var{Q}) = 0 \\
|
||||
\begin{align*}
|
||||
& & \Var{P} = \Var{Q} \\
|
||||
\Var{R.explain() | calculus(name = "", sep = "\\Leftrightarrow", end = "= 0")}
|
||||
\end{eqnarray*}
|
||||
\end{align*}
|
||||
|
||||
On cherche maintenant à résoudre l'équation $\Var{R} = 0$.
|
||||
|
||||
On commence par calculer le discriminant de $R(x) = \Var{R}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{R.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
\Block{set Delta = R.delta}
|
||||
|
||||
\Block{if R.delta > 0}
|
||||
comme $\Delta = \Var{R.delta} > 0$ donc $R$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-R.b} - \sqrt{\Var{Delta}}}{2 \times \Var{R.a}} = \Var{R.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-R.b} + \sqrt{\Var{Delta}}}{2 \times \Var{R.a}} = \Var{R.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions de l'équation $\Var{R} = 0$ sont donc $\mathcal{S} = \left\{ \Var{min(R.roots())}; \Var{max(R.roots())} \right\}$
|
||||
|
||||
\Block{elif R.delta == 0}
|
||||
Comme $\Delta = 0$ donc $R$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{R.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
La solution de $\Var{R} = 0$ est donc $\mathcal{S} = \left\{ \Var{R.roots()[0]}\right\}$
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{R.delta} < 0$ donc $R$ n'a pas de racine donc l'équation $\Var{R} = 0$ n'a pas de solution.
|
||||
|
||||
\Block{endif}
|
||||
\Var{solveEquation(R)}
|
||||
|
||||
\end{document}
|
||||
|
||||
|
359
example/tpl_corr_DM_0302.tex
Normal file
359
example/tpl_corr_DM_0302.tex
Normal file
@ -0,0 +1,359 @@
|
||||
\documentclass[a4paper,10pt, table]{/media/documents/Cours/Prof/Enseignements/tools/style/classDS}
|
||||
\usepackage{/media/documents/Cours/Prof/Enseignements/2014_2015}
|
||||
|
||||
% Title Page
|
||||
\titre{DM5}
|
||||
% \seconde \premiereS \PSTMG \TSTMG
|
||||
\classe{\premiereS}
|
||||
\date{02 mars 2015}
|
||||
%\duree{1 heure}
|
||||
\sujet{\Var{infos.num}}
|
||||
% DS DSCorr DM DMCorr Corr
|
||||
\typedoc{DM}
|
||||
|
||||
\printanswers
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
Le barème est donné à titre indicatif, il pourra être modifié. Vous rendrez le sujet avec la copie.
|
||||
|
||||
\begin{questions}
|
||||
|
||||
\question
|
||||
Résoudre les équations suivantes
|
||||
\Block{set P = Polynom_deg2.random(["{a}", "{b}", "{c}"], name = 'P')}
|
||||
\Block{set Q = Polynom_deg2.random(["{a}", "{b}", "{c}"], name = 'Q')}
|
||||
\begin{eqnarray*}
|
||||
\Var{P} & > &0 \\
|
||||
\end{eqnarray*}
|
||||
|
||||
\begin{solution}
|
||||
On commence par calculer le discriminant de $\Var{P.name}(x) = \Var{P}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{P.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if P.delta > 0}
|
||||
comme $\Delta = \Var{P.delta} > 0$ donc $\Var{P.name}$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-P.b} - \sqrt{\Var{P.delta}}}{2 \times \Var{P.a}} = \Var{P.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P.b} + \sqrt{\Var{P.delta}}}{2 \times \Var{P.a}} = \Var{P.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{elif P.delta == 0}
|
||||
Comme $\Delta = 0$ donc $\Var{P.name}$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{P.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{P.delta} < 0$ donc $\Var{P.name}$ n'a pas de racine.
|
||||
|
||||
\Block{endif}
|
||||
Comme $a = \Var{P.a}$, on en déduit le tableau de signe de $\Var{P.name}$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, $P$/2}%
|
||||
\Var{P.tbl_sgn_header()}
|
||||
\Var{P.tbl_sgn()}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
On regarde maintenant où sont les $+$ dans le tableau de signe pour résoudre l'inéquation.
|
||||
\end{solution}
|
||||
|
||||
\begin{eqnarray*}
|
||||
\Var{Q} & \leq &0 \\
|
||||
\end{eqnarray*}
|
||||
\begin{solution}
|
||||
On commence par calculer le discriminant de $Q(x) = \Var{Q}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{Q.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if Q.delta > 0}
|
||||
comme $\Delta = \Var{Q.delta} > 0$ donc $Q$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-Q.b} - \sqrt{\Var{Q.delta}}}{2 \times \Var{Q.a}} = \Var{Q.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-Q.b} + \sqrt{\Var{Q.delta}}}{2 \times \Var{Q.a}} = \Var{Q.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{elif Q.delta == 0}
|
||||
Comme $\Delta = 0$ donc $Q$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{Q.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{Q.delta} < 0$ donc $Q$ n'a pas de racine.
|
||||
|
||||
\Block{endif}
|
||||
Comme $a = \Var{Q.a}$, on en déduit le tableau de signe de $Q$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, $Q$/2}%
|
||||
\Var{Q.tbl_sgn_header()}
|
||||
\Var{Q.tbl_sgn()}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
On regarde maintenant où sont les $-$ dans le tableau de signe pour résoudre l'inéquation.
|
||||
\end{solution}
|
||||
|
||||
\begin{eqnarray*}
|
||||
\Var{P} & \geq & \Var{Q}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{set R = P-Q}
|
||||
|
||||
\begin{solution}
|
||||
On commence par se ramener à une équation de la forme $ax^2 + bx + c \geq 0$.
|
||||
\begin{eqnarray*}
|
||||
\Var{P} \geq \Var{Q} & \Leftrightarrow & \Var{P} - (\Var{Q}) \geq 0 \\
|
||||
\Var{R.explain() | calculus(name = "", sep = "\\Leftrightarrow", end = "\\geq 0")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{set R = Polynom_deg2(R._coef)}
|
||||
|
||||
Ensuite on étudie le signe de $R(X) = \Var{R}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{R.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if R.delta > 0}
|
||||
comme $\Delta = \Var{R.delta} > 0$ donc $R$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-R.b} - \sqrt{\Var{R.delta}}}{2 \times \Var{R.a}} = \Var{R.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-R.b} + \sqrt{\Var{R.delta}}}{2 \times \Var{R.a}} = \Var{R.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{elif R.delta == 0}
|
||||
Comme $\Delta = 0$ donc $R$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{R.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{R.delta} < 0$ donc $R$ n'a pas de racine.
|
||||
|
||||
\Block{endif}
|
||||
Comme $a = \Var{R.a}$, on en déduit le tableau de signe de $R$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, $R$/2}%
|
||||
\Var{R.tbl_sgn_header()}
|
||||
\Var{R.tbl_sgn()}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
On regarde maintenant où sont les $+$ dans le tableau de signe pour résoudre l'inéquation.
|
||||
|
||||
|
||||
\end{solution}
|
||||
|
||||
|
||||
\question
|
||||
Tracer le tableau de variation des fonctions suivantes \textit{(Vous pouvez utiliser les nombres à virgules)}
|
||||
\Block{set f = Polynom.random(["{a}", "{b}", "{c}", "{d}"], name = 'f')}
|
||||
\Block{set P = f}
|
||||
\begin{parts}
|
||||
\part $f:x\mapsto \Var{P}$
|
||||
\begin{solution}
|
||||
Pour avoir les variations de $\Var{P.name}$, il faut connaître le signe de sa dérivé. On dérive $P$
|
||||
\Block{set P1 = P.derivate()}
|
||||
\begin{eqnarray*}
|
||||
\Var{P1.explain() | calculus(name = P1.name + "(x)", sep = "=", end = "")}
|
||||
\end{eqnarray*}
|
||||
\Block{set P1 = Polynom_deg2(P1._coef, name = P1.name)}
|
||||
On étudie le signe de $P'$
|
||||
|
||||
Ensuite on étudie le signe de $\Var{P1.name}(x) = \Var{P1}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{P1.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if P1.delta > 0}
|
||||
comme $\Delta = \Var{P1.delta} > 0$ donc $\Var{P1.name}$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-P1.b} - \sqrt{\Var{P1.delta}}}{2 \times \Var{P1.a}} = \Var{P1.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P1.b} + \sqrt{\Var{P1.delta}}}{2 \times \Var{P1.a}} = \Var{P1.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{elif P1.delta == 0}
|
||||
Comme $\Delta = 0$ donc $\Var{P1.name}$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{P1.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{P1.delta} < 0$ donc $\Var{P1.name}$ n'a pas de racine.
|
||||
|
||||
\Block{endif}
|
||||
Comme $a = \Var{P1.a}$, on en déduit le tableau de signe de $\Var{P1.name}$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, Signe de $\Var{P1.name} $/2}%
|
||||
\Var{P1.tbl_sgn_header()}
|
||||
\Var{P1.tbl_sgn()}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\end{solution}
|
||||
|
||||
\Block{set g = Polynom.random(["{a}", "{b}", "{c}", "{d}"], name = 'g')}
|
||||
\Block{set P = g}
|
||||
\part $g:x\mapsto \Var{P}$
|
||||
|
||||
\begin{solution}
|
||||
Pour avoir les variations de $\Var{P.name}$, il faut connaître le signe de sa dérivé. On dérive $P$
|
||||
\Block{set P1 = P.derivate()}
|
||||
\begin{eqnarray*}
|
||||
\Var{P1.explain() | calculus(name = P1.name + "(x)", sep = "=", end = "")}
|
||||
\end{eqnarray*}
|
||||
\Block{set P1 = Polynom_deg2(P1._coef, name = P1.name)}
|
||||
On étudie le signe de $P'$
|
||||
|
||||
Ensuite on étudie le signe de $\Var{P1.name}(x) = \Var{P1}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{P1.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if P1.delta > 0}
|
||||
comme $\Delta = \Var{P1.delta} > 0$ donc $\Var{P1.name}$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-P1.b} - \sqrt{\Var{P1.delta}}}{2 \times \Var{P1.a}} = \Var{P1.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P1.b} + \sqrt{\Var{P1.delta}}}{2 \times \Var{P1.a}} = \Var{P1.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{elif P1.delta == 0}
|
||||
Comme $\Delta = 0$ donc $\Var{P1.name}$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{P1.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{P1.delta} < 0$ donc $\Var{P1.name}$ n'a pas de racine.
|
||||
|
||||
\Block{endif}
|
||||
Comme $a = \Var{P1.a}$, on en déduit le tableau de signe de $\Var{P1.name}$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, Signe de $\Var{P1.name} $/2}%
|
||||
\Var{P1.tbl_sgn_header()}
|
||||
\Var{P1.tbl_sgn()}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\end{solution}
|
||||
|
||||
\Block{set R = Polynom.random(["{a}", "{b}", "{c}"])}
|
||||
\part $h:x\mapsto \Var{R} - f(x)$
|
||||
|
||||
\Block{set h = R - f}
|
||||
\Block{do h.give_name('h')}
|
||||
|
||||
\begin{solution}
|
||||
On commence par simplifier l'expression de $h$
|
||||
\begin{eqnarray*}
|
||||
h(x) & = & \Var{R} - f(x) \\
|
||||
\Var{h.explain() | calculus(name = h.name + "(x)", sep = "=", end = "")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{set P = h}
|
||||
Pour avoir les variations de $\Var{P.name}$, il faut connaître le signe de sa dérivé. On dérive $P$
|
||||
\Block{set P1 = P.derivate()}
|
||||
\begin{eqnarray*}
|
||||
\Var{P1.explain() | calculus(name = P1.name + "(x)", sep = "=", end = "")}
|
||||
\end{eqnarray*}
|
||||
\Block{set P1 = Polynom_deg2(P1._coef, name = P1.name)}
|
||||
On étudie le signe de $P'$
|
||||
|
||||
Ensuite on étudie le signe de $\Var{P1.name}(x) = \Var{P1}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{P1.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{if P1.delta > 0}
|
||||
comme $\Delta = \Var{P1.delta} > 0$ donc $\Var{P1.name}$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{\Var{-P1.b} - \sqrt{\Var{P1.delta}}}{2 \times \Var{P1.a}} = \Var{P1.roots()[0] } \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P1.b} + \sqrt{\Var{P1.delta}}}{2 \times \Var{P1.a}} = \Var{P1.roots()[1] }
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{elif P1.delta == 0}
|
||||
Comme $\Delta = 0$ donc $\Var{P1.name}$ a une racine
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{P1.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{P1.delta} < 0$ donc $\Var{P1.name}$ n'a pas de racine.
|
||||
|
||||
\Block{endif}
|
||||
Comme $a = \Var{P1.a}$, on en déduit le tableau de signe de $\Var{P1.name}$
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
\tkzTabInit[espcl=2]%
|
||||
{$x$/1, Signe de $\Var{P1.name} $/2}%
|
||||
\Var{P1.tbl_sgn_header()}
|
||||
\Var{P1.tbl_sgn()}
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
\end{solution}
|
||||
\end{parts}
|
||||
|
||||
\question
|
||||
Appliquer l'algorithme de tri vu en cours à la suite suivante
|
||||
\begin{center}
|
||||
\begin{tabular}{|*{6}{c|}}
|
||||
\hline
|
||||
6914 & 6851 & 6532 & 6884 & 6164 & 6495 \\
|
||||
\hline
|
||||
\end{tabular}
|
||||
|
||||
\end{center}
|
||||
|
||||
|
||||
\end{questions}
|
||||
|
||||
\end{document}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "master"
|
||||
%%% End:
|
||||
|
BIN
example/tpl_example.pdf
Normal file
BIN
example/tpl_example.pdf
Normal file
Binary file not shown.
32
example/tpl_play.tex
Normal file
32
example/tpl_play.tex
Normal file
@ -0,0 +1,32 @@
|
||||
\documentclass[a4paper,10pt]{article}
|
||||
\RequirePackage[utf8x]{inputenc}
|
||||
\RequirePackage[francais]{babel}
|
||||
\RequirePackage{amssymb}
|
||||
\RequirePackage{amsmath}
|
||||
\RequirePackage{amsfonts}
|
||||
\RequirePackage{subfig}
|
||||
\RequirePackage{graphicx}
|
||||
\RequirePackage{color}
|
||||
|
||||
% Title Page
|
||||
\title{Calcul littéral et statistiques}
|
||||
\date{\today}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
\Block{set L = [1, 4, 5, 6]}
|
||||
|
||||
\Block{for i in L | shuffle}
|
||||
\Var{i}
|
||||
|
||||
\Block{endfor}
|
||||
|
||||
|
||||
|
||||
\end{document}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: latex
|
||||
%%% TeX-master: "master"
|
||||
%%% End:
|
131
lib/call_litt.py
131
lib/call_litt.py
@ -1,131 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from random import randint, uniform
|
||||
from math import sqrt
|
||||
from jinja2 import Template
|
||||
|
||||
"""
|
||||
Generate expression for litteral calculous
|
||||
|
||||
3 types of expression (a, b, c != 0, 1)
|
||||
1 -> ax + b and eval for x != -b / a
|
||||
2 -> ax(bx + c) and eval for x != 0 and x != -c / b
|
||||
3 -> ax^2 + b and eval for x != +-sqrt(b/a) (if a and b have same sign)
|
||||
"""
|
||||
|
||||
def gene_type1(min_ = -10, max_ = 10):
|
||||
"""@todo: Docstring for gene_type1
|
||||
|
||||
:param min_: @todo
|
||||
:param max_: @todo
|
||||
:returns: @todo
|
||||
|
||||
"""
|
||||
a, b = 0, 0
|
||||
while (b in [0]) or (a in [0, 1]):
|
||||
a = randint(min_, max_)
|
||||
b = randint(min_, max_)
|
||||
|
||||
return "{}x + {}".format(a,b), [-b/a]
|
||||
|
||||
def gene_type2(min_, max_):
|
||||
"""@todo: Docstring for gene_type2
|
||||
|
||||
:param min_: @todo
|
||||
:param max_: @todo
|
||||
:returns: @todo
|
||||
|
||||
"""
|
||||
a, b, c = 0, 0, 0
|
||||
while (a in [0, 1]) or (b in [0, 1]) or c in [0]:
|
||||
a = randint(min_, max_)
|
||||
b = randint(min_, max_)
|
||||
c = randint(min_, max_)
|
||||
|
||||
return "{}x({}x + {})".format(a,b,c), [0, -c/b]
|
||||
|
||||
def gene_type3(min_ = -10, max_ = 10):
|
||||
"""@todo: Docstring for gene_type3
|
||||
|
||||
:param min_: @todo
|
||||
:param max_: @todo
|
||||
:returns: @todo
|
||||
|
||||
"""
|
||||
a, b = 0, 0
|
||||
while (b in [0]) or (a in [0, 1]):
|
||||
a = randint(min_, max_)
|
||||
b = randint(min_, max_)
|
||||
|
||||
if a*(-b) > 0:
|
||||
VI = [-sqrt(-b/a), sqrt(-b/a)]
|
||||
else:
|
||||
VI = []
|
||||
|
||||
return "{}x^2 + {}".format(a,b), VI
|
||||
|
||||
def get_goodX(VI, approx = 0, min_ = -10, max_ = 10):
|
||||
"""@todo: Docstring for get_goodX
|
||||
|
||||
:param VI: @todo
|
||||
:returns: @todo
|
||||
|
||||
"""
|
||||
x = uniform(min_, max_)
|
||||
if approx == 0:
|
||||
x = int(x)
|
||||
else:
|
||||
x = round(x,approx)
|
||||
while x in VI:
|
||||
x = uniform(min_, max_)
|
||||
if approx == 0:
|
||||
x = int(x)
|
||||
else:
|
||||
x = round(x,approx)
|
||||
|
||||
return x
|
||||
|
||||
|
||||
|
||||
def fullExo(min_ = -10 , max_ = 10):
|
||||
"""Generate the whole exo
|
||||
|
||||
:param min_: @todo
|
||||
:param max_: @todo
|
||||
:returns: @todo
|
||||
|
||||
"""
|
||||
template = Template("""
|
||||
\\begin{equation*}
|
||||
$A = {{type1}}$ \\qquad $B = {{type2}}$ \\qquad $C = {{type3}}
|
||||
\\end{equation*}
|
||||
|
||||
Évaluer $A$, $B$ et $C$ pour $x = {{x1}}$ puis $x = {{x2}}$""")
|
||||
|
||||
type1, VI1 = gene_type1(min_, max_)
|
||||
type2, VI2 = gene_type2(min_, max_)
|
||||
type3, VI3 = gene_type3(min_, max_)
|
||||
|
||||
VI = VI1 + VI2 + VI3
|
||||
|
||||
x1, x2 = get_goodX(VI), get_goodX(VI, approx = 1)
|
||||
|
||||
info = {"type1": type1, "type2": type2, "type3": type3, "x1":x1, "x2":x2}
|
||||
|
||||
exo = template.render(**info)
|
||||
|
||||
return exo
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(fullExo())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
133
lib/rd_frac.py
133
lib/rd_frac.py
@ -1,133 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
from random import randint, random
|
||||
from random_expression import RdExpression
|
||||
from arithmetic import gcd
|
||||
from renders import tex_render
|
||||
|
||||
|
||||
|
||||
"""Classe which generate randomly fractions calculus
|
||||
|
||||
Types of sums
|
||||
|
||||
add1 -> b / a + c / a
|
||||
add2 -> b / a + c / ka
|
||||
add3 -> b / a + e / d
|
||||
add4 -> f + b / a
|
||||
add5 -> b / a + f
|
||||
|
||||
where:
|
||||
a integer > 2
|
||||
b integer different from 0 (could be coprime with a)
|
||||
c integer different from 0 (could be coprime with a or ka)
|
||||
e integer different from 0 (could be coprime with d)
|
||||
d integer > 2 ( a not divisible by d and d not divisible by a)
|
||||
k integer > 2
|
||||
f integer different from 0
|
||||
|
||||
|
||||
Types of multiplications
|
||||
|
||||
mult1 -> a x b / c
|
||||
mult2 -> a x b / c + d / c
|
||||
mult3 -> a x b / c + d / e
|
||||
mult4 -> e / f x g / h >>> TODO
|
||||
mult5 -> i / j x k / l
|
||||
|
||||
where:
|
||||
a integer different from -1, 0, 1
|
||||
b integer different from 0
|
||||
c integer different from 0 and 1 (could be coprime with b)
|
||||
d integer different from 0
|
||||
e, g integer different from 0
|
||||
f, g integer different from 0 and 1 such that e*g is coprime with f*h
|
||||
i, k integer different from 0
|
||||
j, l integer different from 0 and 1 such that i*k and j*l have divisor in common
|
||||
|
||||
|
||||
Types of divisions
|
||||
|
||||
div1 -> a / b : c / d
|
||||
|
||||
where:
|
||||
a integer different from 0
|
||||
b integer different from 0, 1
|
||||
c integer different from 0
|
||||
d integer different from 0
|
||||
|
||||
|
||||
|
||||
#Signs can be mod
|
||||
|
||||
|
||||
"""
|
||||
|
||||
add1 = RdExpression("{b} / {a} + {c} / {a}", \
|
||||
conditions = ["{a} > 2", "{b} != 0","{c} != 0"])
|
||||
|
||||
add2 = RdExpression("{b} / {a} + {c} / {k*a}", \
|
||||
conditions = ["{a} > 2","{k} > 2", "{b} != 0","{c} != 0"])
|
||||
|
||||
add3 = RdExpression("{b} / {a} + {e} / {d}", \
|
||||
conditions = ["{a} not in [0,1]", "{e} not in [0,1]", "{b} != 0","{d} not in [0,1]"])
|
||||
|
||||
add4 = RdExpression("{b} / {a} + {f}", \
|
||||
conditions = ["{a} > 2", "{b} != 0", "{f} != 0"])
|
||||
|
||||
add5 = RdExpression("{f} + {b} / {a}", \
|
||||
conditions = ["{a} > 2", "{b} != 0", "{f} != 0"])
|
||||
|
||||
|
||||
mult1 = RdExpression("{a} * {b} / {c}",\
|
||||
conditions = ["{a} not in [-1, 0, 1]", "{b} != 0", "{c} not in [0,1]"])
|
||||
|
||||
mult2 = RdExpression("{a} * {b} / {c} + {d} / {c}",\
|
||||
conditions = ["{a} not in [-1, 0, 1]", "{b} != 0", "{c} not in [0,1]", \
|
||||
"{d} != 0"])
|
||||
|
||||
mult3 = RdExpression("{a} * {b} / {c} + {d} / {e}",\
|
||||
conditions = ["{a} not in [-1, 0, 1]", "{b} != 0", "{c} not in [0,1]", \
|
||||
"{d} != 0", "{e} not in [0,1]", "{c} != {e}"])
|
||||
|
||||
#mult4 = RdExpression("{e} / {f} * {g} / {h}", \
|
||||
# conditions = ["{e} != 0", "{g} != 0", "{f} != 0", "{g} != 0", \
|
||||
# "gcd({e*g}, {f*h}) == 1"])
|
||||
|
||||
mult5 = RdExpression("{e} / {f} * {g} / {h}", \
|
||||
conditions = ["{e} != 0", "{g} != 0", "{f} not in [0, 1]", "{h} not in [0, 1]"])
|
||||
#"gcd({e*g}, {f*h}) != 1"])
|
||||
|
||||
div1 = RdExpression("{a} / {b} : {c} / {d}", \
|
||||
conditions = ["{a} not in [0]", "{b} not in [0,1]", "{c} != 0","{d} not in [0]"])
|
||||
|
||||
frac = {"add1": add1,\
|
||||
"add2": add2,\
|
||||
"add3": add3,\
|
||||
"add4": add4,\
|
||||
"add5": add5, \
|
||||
"mult1": mult1,\
|
||||
"mult2": mult2,\
|
||||
"mult3": mult2,\
|
||||
#"mult4": mult2,\
|
||||
"mult5": mult5, \
|
||||
"div1": div1 }
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(add1())
|
||||
print(add2())
|
||||
print(add3())
|
||||
print(add4())
|
||||
print(add5())
|
||||
|
||||
print(mult1())
|
||||
print(mult2())
|
||||
print(mult3())
|
||||
#print(mult4())
|
||||
print(mult5())
|
||||
|
||||
print(div1())
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
Loading…
Reference in New Issue
Block a user