don't know
This commit is contained in:
parent
33625b36f5
commit
7738923a8e
@ -10,15 +10,19 @@ from path import path
|
||||
from texenv import texenv
|
||||
|
||||
import math as m
|
||||
import random as rd
|
||||
from pymath.expression import Expression
|
||||
from pymath.polynom import Polynom
|
||||
from pymath.polynomDeg2 import Polynom_deg2
|
||||
from pymath.fraction import Fraction
|
||||
|
||||
export_dict = {}
|
||||
export_dict.update(m.__dict__)
|
||||
#export_dict.update(__builtin__.__dict__)
|
||||
export_dict.update(rd.__dict__)
|
||||
export_dict.update(__builtins__.__dict__)
|
||||
export_dict.update({"Expression":Expression,\
|
||||
"Polynom":Polynom,\
|
||||
"Polynom_deg2":Polynom_deg2,\
|
||||
"Fraction":Fraction,\
|
||||
})
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
Résoudre l'équation suivante
|
||||
\begin{eqnarray*}
|
||||
- 4 x^{ 2 } + 4 x - 1 & = & 0
|
||||
- 3 x^{ 2 } + 6 x - 3 & = & 0
|
||||
\end{eqnarray*}
|
||||
|
||||
Solution:
|
||||
@ -31,9 +31,9 @@
|
||||
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & 4^{ 2 } - 4 \times ( -4 ) \times ( -1 ) \\
|
||||
\Delta & = & 16 - ( -16 ) \times ( -1 ) \\
|
||||
\Delta & = & 16 - 16 \\
|
||||
\Delta & = & 6^{ 2 } - 4 \times ( -3 ) \times ( -3 ) \\
|
||||
\Delta & = & 36 - ( -12 ) \times ( -3 ) \\
|
||||
\Delta & = & 36 - 36 \\
|
||||
\Delta & = & 0
|
||||
\end{eqnarray*}
|
||||
|
||||
@ -44,10 +44,10 @@
|
||||
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \frac{ -4 }{ 2 \times ( -4 ) } = \frac{ -4 }{ -8 } = \frac{ 4 }{ 8 } = \frac{ 1 \times 4 }{ 2 \times 4 } = \frac{ 1 }{ 2 } = \frac{ -4 }{ -8 }
|
||||
x_1 = \frac{-b}{2a} = \frac{ -6 }{ 2 \times ( -3 ) } = \frac{ -6 }{ -6 } = \frac{ 6 }{ 6 } = 1 = \frac{ -6 }{ -6 }
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions sont donc $\mathcal{S} = \left\{ \frac{ -4 }{ -8 }\right\}$
|
||||
Les solutions sont donc $\mathcal{S} = \left\{ \frac{ -6 }{ -6 }\right\}$
|
||||
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
|
||||
Résoudre l'équation suivante
|
||||
\begin{eqnarray*}
|
||||
- 10 x^{ 2 } - 5 x - 5 & = & x^{ 2 } + 5 x - 9
|
||||
- 7 x^{ 2 } - 7 x + 9 & = & - 2 x^{ 2 } + x - 9
|
||||
\end{eqnarray*}
|
||||
|
||||
Solution:
|
||||
@ -68,38 +68,38 @@
|
||||
On commence par se ramener à une équation de la forme $ax^2+bx+c = 0$.
|
||||
|
||||
\begin{eqnarray*}
|
||||
- 10 x^{ 2 } - 5 x - 5 = x^{ 2 } + 5 x - 9 & \Leftrightarrow & - 10 x^{ 2 } - 5 x - 5 - (x^{ 2 } + 5 x - 9) = 0 \\
|
||||
& \Leftrightarrow & - 10 x^{ 2 } - x^{ 2 } - 5 x - 5 x - 5 + 9= 0 \\
|
||||
& \Leftrightarrow & ( ( -10 ) + ( -1 ) ) x^{ 2 } + ( ( -5 ) + ( -5 ) ) x + ( -5 ) + 9= 0 \\
|
||||
& \Leftrightarrow & - 11 x^{ 2 } - 10 x + 4= 0
|
||||
- 7 x^{ 2 } - 7 x + 9 = - 2 x^{ 2 } + x - 9 & \Leftrightarrow & - 7 x^{ 2 } - 7 x + 9 - (- 2 x^{ 2 } + x - 9) = 0 \\
|
||||
& \Leftrightarrow & - 7 x^{ 2 } + 2 x^{ 2 } - 7 x - x + 9 + 9= 0 \\
|
||||
& \Leftrightarrow & ( ( -7 ) + 2 ) x^{ 2 } + ( ( -7 ) + ( -1 ) ) x + 9 + 9= 0 \\
|
||||
& \Leftrightarrow & - 5 x^{ 2 } - 8 x + 18= 0
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
On cherche maintenant à résoudre l'équation $- 11 x^{ 2 } - 10 x + 4 = 0$.
|
||||
On cherche maintenant à résoudre l'équation $- 5 x^{ 2 } - 8 x + 18 = 0$.
|
||||
|
||||
On commence par calculer le discriminant
|
||||
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Delta & = & ( -10 )^{ 2 } - 4 \times ( -11 ) \times 4 \\
|
||||
\Delta & = & 100 - ( -44 ) \times 4 \\
|
||||
\Delta & = & 100 - ( -176 ) \\
|
||||
\Delta & = & 276
|
||||
\Delta & = & ( -8 )^{ 2 } - 4 \times ( -5 ) \times 18 \\
|
||||
\Delta & = & 64 - ( -20 ) \times 18 \\
|
||||
\Delta & = & 64 - ( -360 ) \\
|
||||
\Delta & = & 424
|
||||
\end{eqnarray*}
|
||||
|
||||
|
||||
|
||||
Alors $\Delta = 276 > 0$ donc il y a deux solutions
|
||||
Alors $\Delta = 424 > 0$ donc il y a deux solutions
|
||||
|
||||
|
||||
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{-10 - \sqrt{276}}{2 \times -11} = 0.3 \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{-10 + \sqrt{276}}{2 \times -11} = -1.21
|
||||
x_1 & = & \frac{-b - \sqrt{\Delta}}{2a} = \frac{-8 - \sqrt{424}}{2 \times -5} = 1.26 \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{-8 + \sqrt{424}}{2 \times -5} = -2.86
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions sont donc $\mathcal{S} = \left\{ 0.3; -1.21 \right\}$
|
||||
Les solutions sont donc $\mathcal{S} = \left\{ 1.26; -2.86 \right\}$
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -19,7 +19,8 @@
|
||||
\section{Polynômes}
|
||||
|
||||
|
||||
\Block{set P = Polynom.random(["{a}", "{b}", "{c}"], ["{b}**2 - 4*{a}*{c} == 0"])}
|
||||
|
||||
\Block{set P = Polynom_deg2.random(["{a}", "{b}", "{c}"], ["{b}**2 - 4*{a}*{c} == 0"])}
|
||||
Résoudre l'équation suivante
|
||||
\begin{eqnarray*}
|
||||
\Var{P} & = & 0
|
||||
@ -27,40 +28,33 @@
|
||||
|
||||
Solution:
|
||||
|
||||
On commence par calculer le discriminant
|
||||
\Block{set Delta = Expression("{b}^2 - 4*{a}*{c}".format(a = P._coef[2], b = P._coef[1], c = P._coef[0]))}
|
||||
On commence par calculer le discriminant de $P(x) = \Var{P}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{Delta.simplify()|calculus(name="\\Delta")}
|
||||
\Var{P.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
\Block{set Delta = Delta.simplified()}
|
||||
|
||||
\Block{if Delta > 0}
|
||||
Alors $\Delta = \Var{Delta} > 0$ donc il y a deux solutions
|
||||
|
||||
\Block{set x1 = (-P._coef[1] - sqrt(Delta))/(2*P._coef[2])}
|
||||
\Block{set x2 = (-P._coef[1] + sqrt(Delta))/(2*P._coef[2])}
|
||||
\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._coef[1]} - \sqrt{\Var{Delta}}}{2 \times \Var{P._coef[2]}} = \Var{x1 | round(2)} \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-P._coef[1]} + \sqrt{\Var{Delta}}}{2 \times \Var{P._coef[2]}} = \Var{x2 | round(2)}
|
||||
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 sont donc $\mathcal{S} = \left\{ \Var{x1|round(2)}; \Var{x2|round(2)} \right\}$
|
||||
Les solutions de l'équation $\Var{P} = 0$ sont donc $\mathcal{S} = \left\{ \Var{min(P.roots())}; \Var{max(P.roots())} \right\}$
|
||||
|
||||
\Block{elif Delta == 0}
|
||||
Alors $\Delta = \Var{Delta} = 0$ donc il y a une solution
|
||||
|
||||
\Block{set x1 = Expression("-{b}/(2*{a})".format(b = P._coef[1], a = P._coef[2]))}
|
||||
\Block{elif P.delta == 0}
|
||||
Comme $\Delta = 0$ donc $P$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{" = ".join(x1.simplify())}
|
||||
x_1 = \frac{-b}{2a} = \Var{P.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions sont donc $\mathcal{S} = \left\{ \Var{x1.simplified()}\right\}$
|
||||
La solution de $\Var{P} = 0$ est donc $\mathcal{S} = \left\{ \Var{P.roots()[0]}\right\}$
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{Delta} < 0$ donc il n'y a pas de solution.
|
||||
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}
|
||||
|
||||
@ -69,8 +63,8 @@
|
||||
\bigskip
|
||||
|
||||
|
||||
\Block{set P = Polynom.random(["{a}", "{b}", "{c}"])}
|
||||
\Block{set Q = Polynom.random(["{a}", "{b}", "{c}"])}
|
||||
\Block{set P = Polynom_deg2.random(["{a}", "{b}", "{c}"])}
|
||||
\Block{set Q = Polynom_deg2.random(["{a}", "{b}", "{c}"])}
|
||||
Résoudre l'équation suivante
|
||||
\begin{eqnarray*}
|
||||
\Var{P} & = & \Var{Q}
|
||||
@ -80,52 +74,46 @@
|
||||
|
||||
On commence par se ramener à une équation de la forme $ax^2+bx+c = 0$.
|
||||
|
||||
\Block{set R = Polynom_deg2((P-Q)._coef)}
|
||||
|
||||
\begin{eqnarray*}
|
||||
\Var{P} = \Var{Q} & \Leftrightarrow & \Var{P} - (\Var{Q}) = 0 \\
|
||||
\Var{(P - Q)|calculus(name = "", sep = "\\Leftrightarrow", end = "= 0")}
|
||||
\Var{R.explain() | calculus(name = "", sep = "\\Leftrightarrow", end = "= 0")}
|
||||
\end{eqnarray*}
|
||||
|
||||
\Block{set R = (P-Q)[-1]}
|
||||
On cherche maintenant à résoudre l'équation $\Var{R} = 0$.
|
||||
|
||||
On commence par calculer le discriminant
|
||||
\Block{set Delta = Expression("{b}^2 - 4*{a}*{c}".format(a = R._coef[2], b = R._coef[1], c = R._coef[0]))}
|
||||
On commence par calculer le discriminant de $R(x) = \Var{R}$.
|
||||
\begin{eqnarray*}
|
||||
\Delta & = & b^2-4ac \\
|
||||
\Var{Delta.simplify()|calculus(name="\\Delta")}
|
||||
\Var{R.delta.explain()|calculus(name="\\Delta")}
|
||||
\end{eqnarray*}
|
||||
\Block{set Delta = Delta.simplified()}
|
||||
\Block{set Delta = R.delta}
|
||||
|
||||
\Block{if Delta > 0}
|
||||
Alors $\Delta = \Var{Delta} > 0$ donc il y a deux solutions
|
||||
|
||||
\Block{set x1 = (-R._coef[1] - sqrt(Delta))/(2*R._coef[2])}
|
||||
\Block{set x2 = (-R._coef[1] + sqrt(Delta))/(2*R._coef[2])}
|
||||
\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._coef[1]} - \sqrt{\Var{Delta}}}{2 \times \Var{R._coef[2]}} = \Var{x1 | round(2)} \\
|
||||
x_2 & = & \frac{-b + \sqrt{\Delta}}{2a} = \frac{\Var{-R._coef[1]} + \sqrt{\Var{Delta}}}{2 \times \Var{R._coef[2]}} = \Var{x2 | round(2)}
|
||||
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 sont donc $\mathcal{S} = \left\{ \Var{x1|round(2)}; \Var{x2|round(2)} \right\}$
|
||||
Les solutions de l'équation $\Var{R} = 0$ sont donc $\mathcal{S} = \left\{ \Var{min(R.roots())}; \Var{max(R.roots())} \right\}$
|
||||
|
||||
\Block{elif Delta == 0}
|
||||
Alors $\Delta = \Var{Delta} = 0$ donc il y a une solution
|
||||
|
||||
\Block{set x1 = Expression("-{b}/(2*{a})".format(b = R._coef[1], a = R._coef[2]))}
|
||||
\Block{elif R.delta == 0}
|
||||
Comme $\Delta = 0$ donc $R$ a deux racines
|
||||
|
||||
\begin{eqnarray*}
|
||||
x_1 = \frac{-b}{2a} = \Var{" = ".join(x1.simplify())}
|
||||
x_1 = \frac{-b}{2a} = \Var{R.roots()[0]} \\
|
||||
\end{eqnarray*}
|
||||
|
||||
Les solutions sont donc $\mathcal{S} = \left\{ \Var{x1.simplified()}\right\}$
|
||||
La solution de $\Var{R} = 0$ est donc $\mathcal{S} = \left\{ \Var{R.roots()[0]}\right\}$
|
||||
|
||||
\Block{else}
|
||||
Alors $\Delta = \Var{Delta} < 0$ donc il n'y a pas de solution.
|
||||
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}
|
||||
|
||||
|
||||
\end{document}
|
||||
|
||||
%%% Local Variables:
|
||||
|
@ -32,10 +32,12 @@ def do_calculus(steps, name = "A", sep = "=", end = "", joining = " \\\\ \n"):
|
||||
#ans += "\n\\end{eqnarray*}\n"
|
||||
return ans
|
||||
|
||||
|
||||
|
||||
texenv.filters['calculus'] = do_calculus
|
||||
|
||||
from random import shuffle
|
||||
texenv.filters['shuffle'] = shuffle
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pymath.expression import Expression
|
||||
|
Loading…
Reference in New Issue
Block a user