% vim:ft=tex:
%
\documentclass[12pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage[francais]{babel}
\usepackage[T1]{fontenc}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}


\title{
    Snippets pour Opytex \\
    Suites
}
\author{
    Benjamin Bertrand
}

\begin{document}
\maketitle

\section{Calculs de termes}
\begin{enumerate}
    \item Calculer les termes $u_0$, $u_1$, $u_2$, $u_{10}$ et $u_{100}$ pour les suites suivantes
        \begin{enumerate}
            %-set u = Expression.random("{a}*n+{b}")
            \item $\forall n \in \mathbb{N} \qquad u_n = \Var{u}$

                Solution:
                \begin{align*}
                    u_0 &= \Var{u(0).explain() | join('=')} \\
                    u_1 &= \Var{u(1).explain() | join('=')} \\
                    u_2 &= \Var{u(2).explain() | join('=')} \\
                    u_{10} &= \Var{u(10).explain() | join('=')} \\
                    u_{100} &= \Var{u(100).explain() | join('=')} 
                \end{align*}

                %-set v = Expression.random("({a}*n+{b})/{c}", ["c>1"])
            \item $\forall n \in \mathbb{N} \qquad v_n = \Var{v|replace("frac","dfrac")}$

                Solution:
                \begin{align*}
                    v_0 &= \Var{v(0).explain() | join('=')} \\
                    v_1 &= \Var{v(1).explain() | join('=')} \\
                    v_2 &= \Var{v(2).explain() | join('=')} \\
                    v_{10} &= \Var{v(10).explain() | join('=')} \\
                    v_{100} &= \Var{v(100).explain() | join('=')} 
                \end{align*}

                %-set v = Expression.random("({a}*n+{b})/{c}", ["c>1"])
            \item $\forall n \in \mathbb{N} \qquad v_n = \Var{v}$

                Solution:
                \begin{align*}
                    %- for j in [0, 1, 2, 10, 100]
                    v_{\Var{j}} &= \Var{v(j).explain() | join('=')} \\
                    %- endfor
                \end{align*}

                %-set f = Expression.random("{a}*x")
                %-set v0 = randint(0, 10)
            \item $\forall n \in \mathbb{N} \qquad v_{n+1} = \Var{f("v_n")} \mbox{ et } v_0 = \Var{v0}$

                Solution:
                \begin{align*}
                    v_0 &= \Var{v0} \\
                    %-set v = f(v0)
                    v_1 &= \Var{v.explain() | join('=')} \\
                    %-set v = f(v)
                    v_2 &= \Var{v.explain() | join('=')} \\
                \end{align*}
                Pour le terme 10, il faut calculer tous les autres avant!
                \begin{align*}
                    %#- Trick to move around scoping rules
                    %#- https://stackoverflow.com/a/49699589
                    %- set v = namespace(val = v)
                    %- for i in range(8)
                    %- set v.val = f(v.val)
                    v_{\Var{i+3}} &= \Var{v.val.explain() | join('=')} \\
                    %- endfor
                \end{align*}
                
        \end{enumerate}

\end{enumerate}
\end{document}
