\documentclass[a4paper,10pt]{article}
\usepackage{myXsim}
\usepackage{pgfplots}
% \pgfplotsset{compat = newest}
% \usepgfplotslibrary{external} 
% \tikzexternalize

% Title Page
\title{DM 3 \hfill \Var{Nom}}
\tribe{2nd6}
\date{À rendre pour mardi 25 janvier 2022}

\xsimsetup{
    solution/print = false
}

\begin{document}
\maketitle

\begin{exercise}[subtitle={Calculs de fractions}, points=2]
    Détailler les calculs suivants et donner le résultat sous la forme d'une fraction irréductible.
    \begin{multicols}{3}
        \begin{enumerate}[label={\Alph*=}]
            %- set A = rdm.expression("{a} / {b} + {c}", ["a!=b", "b > 1"], global_config={"min_max":(1, 10)})
            \item $\Var{A}$

            %- set B = rdm.expression("{a} / {b} + {c} / {d}", ["a!=b", "b > 1"], global_config={"min_max":(-10, 10), "rejected":[-1, 0, 1]})
            \item $\Var{B}$

            %- set C = rdm.expression("{a} / {b} * {c} / {k*b}", ["a!=b", "c!=b", "b > 1"], global_config={"min_max":(1, 10)})
            \item $\Var{C}$
        \end{enumerate}
    \end{multicols}
\end{exercise}


\begin{solution}
        \begin{enumerate}[label={\Alph*=}]
            \item $\Var{A.simplify().explain() | join('=')} = \Var{A.simplify().simplified}$
            \item $\Var{B.simplify().explain() | join('=')} = \Var{B.simplify().simplified}$
            \item $\Var{C.simplify().explain() | join('=')} = \Var{C.simplify().simplified}$
        \end{enumerate}
\end{solution}

\begin{exercise}[subtitle={Développer}, points=2]
    Développer puis réduire les expressions suivantes
    \begin{multicols}{3}
        \begin{enumerate}[label={\Alph*=}]
            %- set A = rdm.expression("{a}x({c}x+{d}) - {b}x", [], global_config={"min_max":(1, 10)})
            \item $\Var{A}$

            %- set B = rdm.expression("({a}x+{b})({c}x+{d})", [], )
            \item $\Var{B}$

            %- set C = rdm.expression("({a}x+{b})^2", [], )
            \item $\Var{C}$
        \end{enumerate}
    \end{multicols}
\end{exercise}

\begin{solution}
        \begin{enumerate}
            \item 
                \begin{align*}
                    A &= \Var{A.simplify().explain() | join('\\\\&=')}
                \end{align*}
            \item 
                \begin{align*}
                    B &= \Var{B.simplify().explain() | join('\\\\&=')}
                \end{align*}
            \item 
                \begin{align*}
                    C &= \Var{C.simplify().explain() | join('\\\\&=')}
                \end{align*}
        \end{enumerate}
\end{solution}


\begin{exercise}[subtitle={Inéquation et tableaux}, points=3]
    Tracer le tableau de signe des fonctions suivantes en le démontrant à l'aide de la résolution d'une inéquation.
    \begin{multicols}{2}
        \begin{enumerate}
            %- set f = rdm.expression("{a}x + {b}", global_config={"min_max":(1, 20)})
            \item $f(x) = \Var{f}$
            %- set g = rdm.expression("{a}x + {b}", global_config={"min_max":(1, 20)})
            \item $g(x) = \Var{g}$
        \end{enumerate}
    \end{multicols}
\end{exercise}

\begin{solution}
    \begin{enumerate}
        \item 
            Pour déterminer les valeurs de $x$ pour lesquelles $f(x)$ est positive, il faut résoudre l'inéquation

            %- set cst = -f[0]
            %- set coef = f[1]
            %- set racine = cst / coef
            \begin{align*}
                f(x) & \geq 0 \\
                \Var{f} & \geq 0 \\
                \Var{f + cst} &\geq \Var{0 + cst} \\
                \frac{\Var{f + cst}}{\Var{coef}} &\geq \frac{\Var{cst}}{\Var{coef}} \\
                x &\geq \Var{racine.simplify()} \\
            \end{align*}

            Donc $f(x)$ est positif quand $x$ est supérieur à $\Var{racine}$. On en déduit le tableau de signe
            \begin{center}
                \begin{tikzpicture}
                    \tkzTabInit[lgt=2,espcl=1]{$ t $/1,$ f(t) $/1}{, $\Var{racine}$ ,}
                    \tkzTabLine{, -, z, +,  }
                \end{tikzpicture}
            \end{center}
        \item 
            Pour déterminer les valeurs de $x$ pour lesquelles $g(x)$ est positive, il faut résoudre l'inéquation

            %- set cst = -g[0]
            %- set coef = g[1]
            %- set racine = cst / coef
            \begin{align*}
                g(x) & \geq 0 \\
                \Var{g} & \geq 0 \\
                \Var{g + cst} &\geq \Var{0 + cst} \\
                \frac{\Var{g + cst}}{\Var{coef}} &\geq \frac{\Var{cst}}{\Var{coef}} \\
                x &\geq \Var{racine.simplify()} \\
            \end{align*}

            Donc $f(x)$ est positif quand $x$ est supérieur à $\Var{racine}$. On en déduit le tableau de signe
            \begin{center}
                \begin{tikzpicture}
                    \tkzTabInit[lgt=2,espcl=1]{$ t $/1,$ g(t) $/1}{, $\Var{racine}$ ,}
                    \tkzTabLine{, -, z, +,  }
                \end{tikzpicture}
            \end{center}
    \end{enumerate}
\end{solution}

\begin{exercise}[subtitle={Vecteurs}, points=2]
    \begin{enumerate}
        \item Tracer les vecteurs $\vect{z} = \vect{u} + \vect{v}$ et $\vect{y} = 2\vect{u} - \vect{v}$ (le vecteur peur sortir du cadre)
            %- set xa1, ya1 = rdm.list(["x", "y"], global_config={"min_max": (-5, 5), "rejected":[-2, -1, 0, 1, 2]})
            %- set xa2, ya2 = -xa1, ya1

            %- set aminx = min(0, xa1, xa2, xa1+xa2, 2*xa1-xa2)
            %- set amaxx = max(0, xa1, xa2, xa1+xa2, 2*xa1-xa2)
            %- set aminy = min(0, ya1, ya2, ya1+ya2, 2*ya1-ya2)
            %- set amaxy = max(0, ya1, ya2, ya1+ya2, 2*ya1-ya2)

            \begin{center}
                \begin{tikzpicture}[scale=0.4]
                    \draw (\Var{aminx-1}, \Var{aminy-1}) rectangle (\Var{amaxx+1}, \Var{amaxy+1});
                    \draw[very thick, ->] (0, 0) -- node [midway, sloped, above] {$\vect{u}$} (\Var{xa1}, \Var{ya1});
                    \draw[very thick, -> ] (0, 0) -- node [midway, sloped, above] {$\vect{v}$} (\Var{xa2}, \Var{ya2});
                \end{tikzpicture}
            \end{center}
        \item Tracer la force résultat de la somme des 3 forces exercées sur le point $0$ représenté ci-dessous.
            %- set x1, y1 = rdm.list(["x", "y"], global_config={"min_max": (-5, 5), "rejected":[-2, -1, 0, 1, 2]})
            %- set x2, y2 = -x1, y1
            %- set x3, y3 = x2, 0

            %- set minx = min(0, x1, x2, x3, x1+x2, x2+x3, x1+x3, x1+x2+x3 )
            %- set maxx = max(0, x1, x2, x3, x1+x2, x2+x3, x1+x3, x1+x2+x3 )
            %- set miny = min(0, y1, y2, y3, y1+y2, y2+y3, y1+y3, y1+y2+y3 )
            %- set maxy = max(0, y1, y2, y3, y1+y2, y2+y3, y1+y3, y1+y2+y3 )

            \begin{center}
                \begin{tikzpicture}[scale=0.4]
                    \draw (\Var{minx-1}, \Var{miny-1}) rectangle (\Var{maxx+1}, \Var{maxy+1});
                    \draw[very thick, ->] (0, 0) -- node [midway, sloped, above] {$\vect{F_1}$} (\Var{x1}, \Var{y1});
                    \draw[very thick, -> ] (0, 0) -- node [midway, sloped, above] {$\vect{F_2}$} (\Var{x2}, \Var{y2});
                    \draw[very thick, -> ] (0, 0) -- node [midway, sloped, above] {$\vect{F_3}$} (\Var{x3}, \Var{y3});
                \end{tikzpicture}
            \end{center}
    \end{enumerate}
\end{exercise}

\begin{solution}
    \begin{enumerate}
        \item 
            \begin{center}
                \begin{tikzpicture}[scale=0.4]
                    \draw (\Var{aminx-1}, \Var{aminy-1}) rectangle (\Var{amaxx+1}, \Var{amaxy+1});
                    \draw[very thick, ->] (0, 0) -- node [midway, sloped, above] {$\vect{u}$} (\Var{xa1}, \Var{ya1});
                    \draw[very thick, -> ] (0, 0) -- node [midway, sloped, above] {$\vect{v}$} (\Var{xa2}, \Var{ya2});


                    \draw[very thick, ->, color=blue] (0, 0)
                    -- ++ (\Var{xa1}, \Var{ya1}) node [midway, sloped, above] {$\vect{u}$} 
                    -- ++ (\Var{xa2}, \Var{ya2}) node [midway, sloped, above] {$\vect{v}$} ;
                    \draw[very thick, ->, color=blue] (0, 0) -- node [midway, sloped, left] {$\vect{z}$} (\Var{xa2+xa1}, \Var{ya2+ya1});
                    \draw[very thick, ->, color=green] (0, 0)
                    -- ++ (\Var{xa1}, \Var{ya1}) node [midway, sloped, above] {$\vect{u}$} 
                    -- ++ (\Var{xa1}, \Var{ya1}) node [midway, sloped, above] {$\vect{u}$} 
                    -- ++ (-\Var{xa2}, -\Var{ya2}) node [midway, sloped, above] {$-\vect{v}$} ;
                    \draw[very thick, ->, color=green] (0, 0) -- node [midway, sloped, above] {$\vect{y}$} (\Var{2*xa1 - xa2}, \Var{2*ya1 - ya2});
                \end{tikzpicture}
            \end{center}

        \item 
            \begin{center}
                \begin{tikzpicture}[scale=0.4]
                    \draw (\Var{minx-1}, \Var{miny-1}) rectangle (\Var{maxx+1}, \Var{maxy+1});
                    \draw[very thick, ->] (0, 0) -- node [midway, sloped, above] {$\vect{F_1}$} (\Var{x1}, \Var{y1});
                    \draw[very thick, -> ] (0, 0) -- node [midway, sloped, above] {$\vect{F_2}$} (\Var{x2}, \Var{y2});
                    \draw[very thick, -> ] (0, 0) -- node [midway, sloped, above] {$\vect{F_3}$} (\Var{x3}, \Var{y3});

                    \draw[very thick, ->, color=blue] (0, 0) 
                    --++  (\Var{x1}, \Var{y1}) node [midway, sloped, above] {$\vect{F_1}$}
                    --++  (\Var{x2}, \Var{y2}) node [midway, sloped, above] {$\vect{F_2}$}
                    --++  (\Var{x3}, \Var{y3}) node [midway, sloped, above] {$\vect{F_3}$}
                    ;
                    \draw[very thick, ->, color=blue] (0, 0) -- (\Var{x1+x2+x3}, \Var{y1+y2+y3}) node [midway, sloped, above] {$\vect{F_1}+\vect{F_2}+\vect{F_3}$};
                \end{tikzpicture}
            \end{center}
    \end{enumerate}
\end{solution}

\end{document}