예제 #1
0
def vecteursParall2(fileExercices, fileCorrections):
    """Exo vecteur (prouver qu'il ne s'agit pas d'un parallèlogramme)"""

    xA = random.randint(-5, -1)
    yA = random.randint(-5, -1)
    xB = random.randint(-5, -1)
    yB = random.randint(1, 5)
    xC = random.randint(1, 5)
    yC = random.randint(1, 5)
    xD = xA + xC - xB
    yD = yA + yC - yB

    perturbation = [-2, -1, 1, 2]
    xD += np.random.choice(perturbation)
    yD += np.random.choice(perturbation)

    xBA = xA - xB
    yBA = yA - yB
    xCD = xD - xC
    yCD = yD - yC

    main = r'''\exo{Vecteurs et parallèlogrammes.}%
Dans le plan muni d'un repère $\left( {{\mathrm{O}};\vec{\imath},
\vec{\jmath}} \right)$, on considère les points $A\left(\{xA}; \{yA}\right)$, $B\left(\{xB}; \{yB}
\right)$, $C\left(\{xC}; \{yC}\right)$ et $D\left(\{xD}; \{yD}\right)$.\\%
Le quadrilatère ABCD est-il un parallèlogramme ?%
'''
    mainC = r'''\cor{Vecteurs et parallèlogrammes.}%
'''
    mainC = fonctionsSimplifiantes.repereDebut(mainC, -6, -8, 9, 6)
    mainC += r'''\path[draw, red] (\{xA}, \{yA})  coordinate [label= left:$A$] (A) --
(\{xB}, \{yB})  coordinate [label=above:$B$] (B) -- (\{xC}, \{yC})  coordinate [label=right:$C$] (C) --
(\{xD}, \{yD})  coordinate [label=right:$D$] (D) -- cycle;%
'''
    mainC = fonctionsSimplifiantes.repereFin(mainC)
    mainC += r'''$\coordv{BA}{x_A - x_B}{y_A - y_B}$. Donc, $\coordv{BA}{\{xA} - (\{xB})}{\{yA} - \{yB}}$.
Ainsi, $\coordv{BA}{\{xBA}}{\{yBA}}$\\%

$\coordv{CD}{x_D - x_C}{y_D - y_C}$. Donc, $\coordv{CD}{\{xD} - \{xC}}{\{yD} - \{yC}}$.
Ainsi, $\coordv{CD}{\{xCD}}{\{yCD}}$\\%

$\vv{BA} \neq \vv{CD}$, donc, ABCD n'est pas un parallèlogramme.%
'''
    return fonctionsSimplifiantes.endExercice(main, mainC, fileExercices,
                                              fileCorrections, locals())
예제 #2
0
def fonctionsHomographiqueTrace(fileExercices, fileCorrections):
    """Tracé d'une fonction homographique."""

    a, b, c, d = 0, 0, 0, 0

    while a * d - b * c == 0 or round(d / c, 3) != d / c or round(a / c,
                                                                  3) != a / c:
        a1 = random.randint(2, 6)
        a2 = random.randint(-6, -2)
        a = np.random.choice([a1, a2])
        b1 = random.randint(1, 6)
        b2 = random.randint(-6, -1)
        b = np.random.choice([b1, b2])
        c1 = random.randint(2, 6)
        c2 = random.randint(-6, -2)
        c = np.random.choice([c1, c2])
        d1 = random.randint(1, 6)
        d2 = random.randint(-6, -1)
        d = np.random.choice([d1, d2])

    main = r'''\exo{Tracé d'une fonction homographique}%
Soit $f$ la fonction définie sur $\R$ par $f(x) = \dfrac{\{a}x \{signE(b)}}{\{c}x \{signE(d)}}$.
\medskip%
\begin{enumerate}%
\item Justifier que $f$ est une fonction homographique.%
\item Quel est l'ensemble de définition de $f$ ?%
\item Tracer la courbe représentative de $f$ dans le plan muni d'un repère.%
\end{enumerate}%
'''
    mainC = r'''\cor{Tracé d'une fonction homographique}
\medskip%
\begin{enumerate}%
\item $f(x) = \dfrac{\{a}x \{signE(b)}}{\{c}x \{signE(d)}}$.
La fonction $f$ est une fonction du type $f(x) = \dfrac{a x + b}{c x + d}$ avec a = \{a}, b = \{b}, c = \{c} et
d = \{d} et $ad - bc = \{a*d - b*c} \neq 0$ donc $f$ est bien une fonction homographique.%
\item La fonction n'est pas définie lorsque le dénominateur s'annule car il est interdit de diviser par 0.\\
Or, $\{c} x \{signE(d)} = 0 => x = \{-d/c}$. $f$ est donc définie sur $\R \setminus \lbrace{\{-d/c}}\rbrace$.
\item $f$ est donc définie sur $\R \setminus \lbrace{\{-d/c}}\rbrace$, on sait donc que la fonction aura pour
tangente verticale la droite d'équation $x = \{-d/c}$.\\
Pour des valeurs "très grandes" ou "très petites" de $x$, les coefficients "b" et "d" n'auront pas d'impact
sur la valeur de la fonction et celle-ci tendra vers une valeur constante, $\dfrac{a}{c} = \dfrac{\{a}}{\{c}} = \{a/c}$.\\
La fonction aura donc pour tangente horizontale la droite d'équation $y = \{a/c}$.\\
'''
    if a * d - b * c > 0:
        mainC += r'''Comme $ad - bc = \{a*d - b*c} > 0$, la fonction est croissante.\\
'''
    else:
        mainC += r'''Comme $ad - bc = \{a*d - b*c} < 0$, la fonction est décroissante.\\
'''
    mainC += r'''La fonction $f$ peut donc être représentée par la courbe suivante :
\end{enumerate}
'''
    ymin = int(a / c) - 6
    ymax = int(a / c) + 6
    xmin = int(-d / c) - 6
    xmax = int(-d / c) + 6
    mainC = fonctionsSimplifiantes.repereDebut(mainC, xmin, ymin, xmax, ymax)
    mainC += r'''\addplot[color=red,domain=\{-10}:\{10}, samples=300]{(\{a}*x \{signE(b)})/(\{c}*x \{signE(d)})};
\addplot[dashed, color=blue,domain=\{-10}:\{10}] coordinates {(\{-d/c}, \{ymin})(\{-d/c}, \{ymax})};
\addplot[dashed, color=blue,domain=\{-10}:\{10}, samples=300]{\{a/c}};
'''
    mainC = fonctionsSimplifiantes.repereFin(mainC)
    return fonctionsSimplifiantes.endExercice(main, mainC, fileExercices,
                                              fileCorrections, locals())
예제 #3
0
def fonctionsSecondDegreTrace(fileExercices, fileCorrections):
    """Tracé d'une fonction du second degré en utilisant les formes canoniques, factorisées et développées."""

    a, al, beSa = 0, 0, 0

    while -2 * a * al == 0 or a * beSa + a * al**2 == 0 or abs(a * beSa) > 30:
        a1 = random.randint(2, 6)
        a2 = random.randint(-6, -2)
        a = np.random.choice([a1, a2])
        b1 = random.randint(1, 6)
        b2 = random.randint(-6, -1)
        al = np.random.choice([b1, b2])
        beSa = np.random.choice([-1, -4, -9, -16, -25, -36])

    sBeSa = int(sqrt(-beSa))
    be = int(a * beSa)
    b = int(-2 * a * al)
    c = int(be + a * al**2)
    de = int(al + sqrt(-beSa))
    ga = int(al - sqrt(-beSa))

    xmin = -10
    ymin = -10
    xmax = 10
    ymax = 10

    signB, signC = ' + ', ' + '
    absB, absC = b, c
    if b < 0:
        signB = r' - '
        absB = abs(b)
    if c < 0:
        signC = r' - '
        absC = abs(c)
    signBe = ' + '
    signMAl, signAl = ' - ', ' + ',
    signMDe, signDe = ' - ', ' + ',
    signMGa, signGa = ' - ', ' + ',
    absAl, absBe, absDe, absGa = al, be, de, ga
    if al < 0:
        signAl = r' - '
        signMAl = r' + '
        absAl = abs(al)
    if de < 0:
        signDe = r' - '
        signMDe = r' + '
        absDe = abs(de)
    if ga < 0:
        signGa = r' - '
        signMGa = r' + '
        absGa = abs(ga)
    if be < 0:
        signBe = r' - '
        absBe = abs(be)

    main = r'''\exo{Tracé d'une fonction de degré 2}%
Soit $f$ la fonction définie sur $\R$ par $f(x) = \{a}x^2 \{signB} \{absB}x \{signC} \{absC}$.
\medskip%
\begin{enumerate}%
\item Tracer la courbe représentative de $f$ dans le plan muni d'un repère.%
\end{enumerate}%
'''
    mainC = r'''\cor{Tracé d'une fonction de degré 2}
\medskip%
\begin{enumerate}%
\item $f(x) = \{a}x^2 \{signE(b)}x \{signE(c)}$.\\
On factorise par \{a} : $f(x) = \{a}[x^2 \{signE(b/a)} x \{signE(c/a)}]$\\
'''
    if b / a > 0:
        mainC += r'''On remarque que $\{int(b/a)} = 2 \times \{int(b/(2*a))}$.
'''
    else:
        mainC += r'''On remarque que $\{int(b/a)} = 2 \times (\{int(b/(2*a))})$.
'''
    mainC += r'''Donc $x^2 \{signE(b/a)} x \{signE(c/a)}$ est une expression proche de $(x \{signOpE(al)})^2$.\\
En développant, on remarque que $(x \{signOpE(al)})^2 = x^2 \{signOpE(2*al)}x \{signE(al**2)}$.\\
Donc $(x \{signOpE(al)})^2 \{signE(c/a - al**2)} = x^2 \{signE(b/a)} x \{signE(c/a)}$.\\
Ainsi, $f(x) = \{a}[(x \{signOpE(al)})^2 \{signE(c/a - al**2)}] = \{a}(x \{signMAl} \{absAl})^2 \{signBe} \{absBe}$.\\
'''
    if al > 0:
        mainC += r'''La forme canonique de $f(x)$ est donc $f(x) = \{a}(x \{signMAl} \textcolor{red}{\{absAl}})^2
\textcolor{red}{\{signBe} \{absBe}}$.\\'''
    else:
        mainC += r'''La forme canonique de $f(x)$ est donc $f(x) = \{a}(x \{signMAl} \{absAl})^2 \{signBe} \{absBe} =
\{a}(x - (\textcolor{red}{- \{absAl}}))^2 \textcolor{red}{\{signBe} \{absBe}}$.\\
'''
    mainC += r'''Le sommet de la parabole est donc le point S(\textcolor{red}{\{al}}; \textcolor{red}{\{be}}).\\

On remarque que $\{-beSa} = \{sBeSa}^2$, on peut donc utiliser l'identité remarquable $a^2 - b^2 = (a-b)(a+b)$.\\
Soit, $f(x) = \{a}[(x \{signOpE(al)})^2 \{signE(beSa)}] = \{a}[(x \{signOpE(al)})^2 - \{sBeSa}^2] =
\{a}(x \{signOpE(al)} \{signOpE(sBeSa)})(x \{signOpE(al)} \{signE(sBeSa)}) =
\{a}(x \{signOpE(al+sBeSa)})(x \{signOpE(al-sBeSa)})$.\\
La forme factorisée de f(x) est donc $f(x) = \{a}(x \{signMDe} \{absDe})(x \{signMGa} \{absGa})$.\\
La fonction f \textcolor{red}{s'annule} donc en $x = \textcolor{blue}{\{de}}$ et en $x = \textcolor{blue}{\{ga}}$.\\
La parabole passe donc par les points A(\textcolor{blue}{\{de}}; \textcolor{red}{0})
 et B(\textcolor{blue}{\{ga}}; \textcolor{red}{0}).\\
'''
    if a > 0:
        mainC += r'''Comme $\{a}>0$, la parabole est "contente", elle sera décroissante puis croissante.\\
'''
    else:
        mainC += r'''Comme $\{a}<0$, la parabole est "triste", elle sera croissante puis décroissante.\\
'''
    mainC += r'''La fonction f peut donc être représentée par la courbe suivante :
\end{enumerate}
'''
    mi = min(de, ga)
    ma = max(de, ga)
    if a < 0:
        mainC = fonctionsSimplifiantes.repereDebut(mainC, min(mi - 2, -10),
                                                   -10, max(ma + 2, 10),
                                                   max(be + 2, 10))
    else:
        mainC = fonctionsSimplifiantes.repereDebut(mainC, min(mi - 2, -10),
                                                   min(be - 2, -10),
                                                   max(ma + 2, 10), 10)
    # mainC = fonctionsSimplifiantes.repereDebut(mainC, xmin, ymin, xmax, ymax)
    mainC += r'''\addplot[color=red,domain=\{mi - 2}:\{ma + 2}, samples=300]{\{a}*x*x \{signE(b)}*x \{signE(c)}};
\node[blue, cross=3pt] at (\{de}, 0) {};\\
\node[blue, cross=3pt] at (\{ga}, 0) {};\\
\node[blue, cross=3pt] at (\{al}, \{be}) {};\\
\node[text=blue, right] at (\{de}, 0) {A};\\
\node[text=blue, right] at (\{ga}, 0) {B};\\
\node[text=blue, right] at (\{al}, \{be}) {S};\\
'''
    mainC = fonctionsSimplifiantes.repereFin(mainC)
    return fonctionsSimplifiantes.endExercice(main, mainC, fileExercices,
                                              fileCorrections, locals())
예제 #4
0
def fonctionsAffineIntersection(fileExercices, fileCorrections):
    """Calcul du point d'intersection de deux fonctions affines."""
    
    a, b, c, d = 0, 0, 0, 0
    while b == d or a == c:
        a1 = random.randint(2, 6)
        a2 = random.randint(-6, -2)
        a = np.random.choice([a1, a2])
        b1 = random.randint(1, 6)
        b2 = random.randint(-6, -1)
        b = np.random.choice([b1, b2])
        c1 = random.randint(1, 6)
        c2 = random.randint(-6, -2)
        c = np.random.choice([c1, c2])
        d1 = random.randint(2, 6)
        d2 = random.randint(-6, -1)
        d = np.random.choice([d1, d2])
    difBD = d - b
    difCA = a - c
    signB, signD = ' + ', ' + '
    absB, absD = b, d
    if b < 0:
        signB = r' - '
        absB = abs(b)
    if d < 0:
        signD = r' - '
        absD = abs(d)
    
    xmin = -10
    ymin = -10
    xmax = 10
    ymax = 10
    xA = (d - b) / (a - c)
    yA = a * xA + b
    egOrAprX = '\simeq'
    egOrAprY = '\simeq'
    if xA == int(xA):
        xA = int(xA)
        egOrAprX = '='
    elif xA != round(xA, 2):
        xA = round(xA, 2)
    else:
        egOrAprX = '='
    
    if yA == int(yA):
        yA = int(yA)
        egOrAprY = '='
    elif yA != round(yA, 2):
        yA = round(yA, 2)
    else:
        egOrAprY = '='
    
    main = r'''\exo{Intersection de fonctions affines}%
Soit $f$ et $g$ les fonctions définies sur $\R$ par $f(x) = \{a} x \{signB} \{absB}$ et
$g(x) = \{c} x \{signD} \{absD}$.
\medskip%
\begin{enumerate}%
\item Tracer les courbes représentatives des fonctions $f$ et $g$ dans le plan muni d'un repère.%
\item Calculer les coordonnées du point d'intersection des deux courbes.%
\end{enumerate}%
'''
    mainC = r'''\cor{Intersection de fonctions affines}
\medskip%
\begin{enumerate}%
\item Les courbes représentantes des fonctions $f$ et $g$ sont sur le graphique ci-après :
\end{enumerate}
'''
    mainC = fonctionsSimplifiantes.repereDebut(mainC, xmin, ymin, xmax, ymax)
    mainC += r'''\addplot[color=red,domain=-10:10, samples=300]{\{a}*x + \{b}};
\addplot[color=blue,domain=-10:10, samples=300]{\{c}*x + \{d}};\\
\node[text=red] at (7, 9) {$f(x)$};\\
\node[text=blue] at (7, 7) {$g(x)$};\\
\node[text=black, cross=3pt] at (\{xA}, \{yA}) {};\\
\node[text=black, right] at (\{xA}, \{yA}) {A};\\
'''
    mainC = fonctionsSimplifiantes.repereFin(mainC)
    mainC += r'''\begin{enumerate}[resume]
\item À l'intersection des deux droites, on a $f(x)=g(x)$. Soit, $\{a} x \{signB} \{absB} =
\{c} x \{signD} \{absD}$\\
C'est à dire $x=\dfrac{\{difBD}}{\{difCA}} \{egOrAprX} \{xA}$\\
Et donc $y=f(\{xA}) \{egOrAprY} \{yA}$ ou $y = g(\{xA}) \{egOrAprY} \{yA}$\\
Le point d'intersection est donc le point A(\{xA}, \{yA}).
\end{enumerate}
'''
    return fonctionsSimplifiantes.endExercice(main, mainC, fileExercices, fileCorrections, locals())
예제 #5
0
def vecteursDroitesColineaires(fileExercices, fileCorrections):
    """Exercice sur les vecteurs, le but est de vérifier que les deux droites sont colinéaires."""

    xA, yA, xB, yB, xC, yC, xAB, yAB = 0, 0, 0, 0, 100, 100, 0, 0
    while xC > 8 or yC > 8:
        xA = random.randint(-5, -1)
        yA = random.randint(-5, -1)
        xB = random.randint(xA + 1, 1)
        yB = random.randint(yA + 1, 1)
        xAB = xB - xA
        yAB = yB - yA
        coeff = random.randint(2, 3)
        xC = xB + coeff * xAB
        yC = yB + coeff * yAB
    xCB = xB - xC
    yCB = yB - yC
    if xA < 0:
        xAtext = "(" + str(xA) + ")"
    else:
        xAtext = str(xA)
    if yA < 0:
        yAtext = "(" + str(yA) + ")"
    else:
        yAtext = str(yA)
    if xC < 0:
        xCtext = "(" + str(xC) + ")"
    else:
        xCtext = str(xC)
    if yC < 0:
        yCtext = "(" + str(yC) + ")"
    else:
        yCtext = str(yC)

    if yCB < 0:
        yCBtext = "(" + str(yCB) + ")"
    else:
        yCBtext = str(yCB)
    if xCB < 0:
        xCBtext = "(" + str(xCB) + ")"
    else:
        xCBtext = str(xCB)
    if yAB < 0:
        yABtext = "(" + str(yAB) + ")"
    else:
        yABtext = str(yAB)
    det = xAB * yCB - yAB * xCB

    main = r'''\exo{Vecteurs et colinéarité.}%
Dans le plan muni d'un repère $\left( {{\mathrm{O}}; \vec{\imath},\vec{\jmath}} \right)$,
on considère les points $A\left(\{xA}; \{yA}\right)$, $B\left(\{xB}; \{yB}\right)$
et $C\left(\{xC}; \{yC}\right)$.\\
Les points A, B et C sont-ils alignés ?%
'''
    mainC = r'''\cor{Vecteurs et colinéarité.}%
'''
    mainC = fonctionsSimplifiantes.repereDebut(mainC, xA - 1, yA - 1,
                                               max(xC + 1, 1), max(yC + 1, 1))
    mainC += r'''\node[text=red, cross=3pt, label=right:\textcolor{red}{A}] at (\{xA}, \{yA}) {};\\
\node[text=red, cross=3pt, label=right:\textcolor{red}{B}] at (\{xB}, \{yB}) {};\\
\node[text=red, cross=3pt, label=right:\textcolor{red}{C}] at (\{xC}, \{yC}) {};\\
'''
    mainC = fonctionsSimplifiantes.repereFin(mainC)
    mainC += r'''\begin{enumerate}%
\item On calcule les coordonnées des vecteurs $\vv{AB}$ et $\vv{CB}$\\%
$\coordv{AB}{x_B - x_A}{y_B - y_A}$.
Donc, $\coordv{AB}{\{xB} - \{xAtext}}{\{yB} - \{yAtext}}$. Ainsi, $\coordv{AB}{\{xAB}}{\{yAB}}$\\%
$\coordv{CB}{x_B - x_C}{y_B - y_C}$.
Donc, $\coordv{CB}{\{xB} - \{xCtext}}{\{yB} - \{yCtext}}$. Ainsi, $\coordv{CB}{\{xCB}}{\{yCB}}$\\%
\item On calcule maintenant le déterminant de ces vecteurs.\\%
det($\vv{AB}$, $\vv{CB}$)=$x_{AB} \times y_{CB} - y_{AB} \times x_{CB}$=\{xAB} $\times$ \{yCBtext} -
\{yABtext} $\times$ \{xCBtext} = \{det}\\%
Le déterminant de ces deux vecteurs étant nul, ils sont colinéaires.%
\end{enumerate}
'''
    return fonctionsSimplifiantes.endExercice(main, mainC, fileExercices,
                                              fileCorrections, locals())