Source Latex
du cours de mathématiques
\documentclass[12pt]{article}
\usepackage{amsfonts}\usepackage{amssymb}
\usepackage[french]{babel}
\usepackage{amsmath}
\usepackage[utf8]{inputenc}
\usepackage{calc}
\usepackage{enumerate}
\usepackage{array}
\usepackage{pst-all}
\usepackage{pstricks-add}
\usepackage{hyperref}
\hypersetup{
pdfauthor={Yoann Morel},
pdfsubject={Algorithmique et programmation},
pdftitle={Algorithmique et programmation},
pdfkeywords={Mathématiques, algorithmique, programmation,
lycée, 2nde, seconde, 1S,
première, S, 1èreS, 1ère S, terminale, terminale S,
TI, python}
}
\hypersetup{
colorlinks = true,
linkcolor = red,
anchorcolor = red,
citecolor = blue,
filecolor = red,
urlcolor = red
}
\voffset=-1.cm
% Raccourcis diverses:
\newcommand{\nwc}{\newcommand}
\nwc{\dsp}{\displaystyle}
\nwc{\ct}{\centerline}
\nwc{\bge}{\begin{equation}}\nwc{\ene}{\end{equation}}
\nwc{\bgar}{\begin{array}}\nwc{\enar}{\end{array}}
\nwc{\bgit}{\begin{itemize}}\nwc{\enit}{\end{itemize}}
\nwc{\bgen}{\begin{enumerate}}\nwc{\enen}{\end{enumerate}}
\nwc{\la}{\left\{}\nwc{\ra}{\right\}}
\nwc{\lp}{\left(}\nwc{\rp}{\right)}
\nwc{\lb}{\left[}\nwc{\rb}{\right]}
\nwc{\bgsk}{\bigskip}
\nwc{\vsp}{\vspace{0.1cm}}
\nwc{\vspd}{\vspace{0.2cm}}
\nwc{\vspt}{\vspace{0.3cm}}
\nwc{\vspq}{\vspace{0.4cm}}
\def\N{{\rm I\kern-.1567em N}}
\def\D{{\rm I\kern-.1567em D}}
\def\No{\N_0}
\def\R{{\rm I\kern-.1567em R}}
\def\C{{\rm C\kern-4.7pt
\vrule height 7.7pt width 0.4pt depth -0.5pt \phantom {.}}}
\def\Q{\mathbb{Q}}
\def\Z{{\sf Z\kern-4.5pt Z}}
\nwc{\tm}{\times}
\nwc{\V}[1]{\overrightarrow{#1}}
\nwc{\zb}{\mbox{$0\hspace{-0.67em}\mid$}}
\nwc{\db}{\mbox{$\hspace{0.1em}|\hspace{-0.67em}\mid$}}
\nwc{\ul}[1]{\underline{#1}}
\newcounter{nex}%[section]
\setcounter{nex}{0}
\newenvironment{EX}{%
\stepcounter{nex}
\bgsk{\noindent {\bf Exercice }\arabic{nex}}\hspace{0.2cm}
}{}
\nwc{\bgex}{\begin{EX}}\nwc{\enex}{\end{EX}}
\nwc{\bgmp}{\begin{minipage}}\nwc{\enmp}{\end{minipage}}
\headheight=0cm
\textheight=26.2cm
\topmargin=-1.8cm
\footskip=0.8cm
\textwidth=18.6cm
\oddsidemargin=-1.3cm
\parindent=0.2cm
% Concernant la mise en page des algo:
\definecolor{grayp}{gray}{0.8}
\definecolor{graypc}{gray}{0.65}
\newlength{\ProgIndent}
\setlength{\ProgIndent}{0.6cm}
\nwc{\PI}{\hspace*{\ProgIndent}}
\nwc{\DPI}{\hspace*{2\ProgIndent}}
\nwc{\TPI}{\hspace*{3\ProgIndent}}
\nwc{\QPI}{\hspace*{4\ProgIndent}}
\newlength{\lgcoin}\setlength{\lgcoin}{3ex}
\newlength{\lgshadow}\setlength{\lgshadow}{0.5ex}
\newlength{\phgn}\newlength{\phgnp}
\newlength{\phgng}
\newlength{\plgn}\newlength{\plgng}
\newlength{\phgtq}\newlength{\phgtqg}
\newlength{\plgtq}\newlength{\plgtqg}
\newlength{\plgcoin}\setlength{\plgcoin}{3ex}
\newlength{\plgshadow}\setlength{\plgshadow}{0.5ex}
\nwc{\Prog}[3]{%
%\par\vspd%
\bgmp[t]{#2+0.5cm}%\linewidth}
\hspace*{-0.3pt}\hspace*{-\parindent}\hspace*{-1ex}%
\psframebox[fillstyle=solid,fillcolor=graypc]{
\emph{\textcolor{white}{\!\!#1}}} \\
\vspace*{-0.5ex}\\
\bgmp{#2}
%\setlength{\fboxrule}{0.1pt}
\settototalheight{\phgn}{\phantom{\bgmp{#2}#3\enmp}}
\setlength{\phgn}{\phgn-2ex}
\setlength{\plgn}{\linewidth}
\setlength{\phgtq}{-\phgn}%\addtolength{\hgtq}{-3ex}
\setlength{\phgtqg}{\phgtq}\addtolength{\phgtqg}{-\lgshadow}
\setlength{\plgng}{\plgn}\addtolength{\plgng}{\lgshadow}
\setlength{\plgtq}{\plgn}\addtolength{\plgtq}{-\lgcoin}
\setlength{\plgtqg}{\plgtq}\addtolength{\plgtqg}{\lgshadow}
\setlength{\phgnp}{\phgn}\addtolength{\phgnp}{\lgcoin}
\setlength{\phgng}{\phgnp}\addtolength{\phgng}{\lgshadow}
\pspolygon[linecolor=white,fillstyle=solid,fillcolor=grayp]%
(-1ex,-\phgnp)(-1ex,1ex)(\plgn,1ex)(\plgng,0)%
(\plgng,\phgtqg)(\plgtqg,-\phgng)(-0.5ex,-\phgng)
\pspolygon[linewidth=0.6pt,linecolor=graypc,fillstyle=solid,fillcolor=graypc]%
(\plgn,\phgtq)(\plgtq,\phgtq)(\plgtq,-\phgnp)
\pspolygon[fillstyle=solid,fillcolor=white]%
(-1ex,-\phgnp)(-1ex,1ex)(\plgn,1ex)%
(\plgn,\phgtq)(\plgtq,\phgtq)(\plgtq,-\phgnp)
\par
\bgmp{\linewidth}#3\enmp
\enmp\enmp%
}
% et pour les progs casio:
\nwc{\return}{
\psset{unit=1cm,arrowsize=4pt}
\psline{<-}(0,0.1)(0.3,0.1)(0.3,0.25)}
\nwc{\disp}{\pspolygon[fillstyle=solid,fillcolor=black](0,0)(0.2,0)(0.2,0.15)}
% Bandeau en bas de page
\newcommand{\TITLE}{Algorithmique et programmation}
\author{Y. Morel}
\date{}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\setlength{\headheight}{0cm}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.1pt}
\lhead{}\chead{}\rhead{}
\lfoot{Y. Morel - \href{https://xymaths.fr/Lycee/2nde/Mathematiques-2nde.php}{xymaths.fr - 2nde}}
\rfoot{\TITLE\ - Graphiques et courbes - \thepage/\pageref{LastPage}}
\cfoot{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\vspace*{-0.4cm}
\ct{\LARGE \bf \TITLE}
\medskip
\ct{\Large \bf Graphiques, dessins, courbes}
\vspace{0.2cm}
\paragraph{\Large Un premier dessin}
Dans un premier temps, on s'intéresse à l'algorithme:\\
\bgmp{7.5cm}
\fbox{
\bgmp{7.5cm}
\texttt{Pour i allant de 2 à 18\\
\hspace*{0.5cm}Afficher le point (i;2)\\
\hspace*{0.5cm}Afficher le point (i;10)\\
Fin Pour}
\vspd
\texttt{Pour j allant de 3 à 9\\
\hspace*{0.5cm}Afficher le point (2;j)\\
\hspace*{0.5cm}Afficher le point (18;j)\\
Fin Pour}
\vspd
\texttt{Pour i allant de 3 à 10\\
\hspace*{0.5cm}Afficher le point (i;9+i/2)\\
\hspace*{0.5cm}Afficher le point (i+8;15-i/2)\\
Fin Pour
}
\enmp}\enmp
\hspace{1cm}
\bgmp{8cm}
\psset{xunit=0.5cm,yunit=0.5cm,arrowsize=7pt}
\begin{pspicture}(0,0)(20,15.2)
\pspolygon[linewidth=0.5pt,linestyle=dashed](0,0)(20,0)(20,15)(0,15)
\psline[linewidth=1.5pt]{->}(0,0)(1,0)
\psline[linewidth=1.5pt]{->}(0,0)(0,1)
\rput(0.5,-0.7){$\vec{i}$}
\rput(-0.6,0.4){$\vec{j}$}
\rput(-0.4,-0.5){$O$}
\multido{\i=0+1}{21}{\multido{\ii=0+1}{16}{\rput(\i,\ii){\scriptsize+}}}
\end{pspicture}
\enmp
\medskip
\paragraph{Les calculatrices graphiques et programmables TI}
disposent d'un menu \texttt{dessin} dans lequel on peut trouver, entre autre,
l'instruction \texttt{Pt-Aff} qui permet d'afficher le point de coordonnées
$(x,y)$.
Bien s\^ur, afin de pouvoir visualiser ce point à l'écran, il faut
que la fen\^etre graphique soit convenablement configurée.
Ceci peut \^etre fait en affectant les valeurs souhaitées
aux variables \texttt{Xmin}, \texttt{Xmax}, \texttt{Ymin} et \texttt{Ymax}
accessibles dans le menu \text{var}, sous-menus \texttt{Variables} puis \texttt{Fen\^etre}. \\
Par exemple ici, \texttt{0$\to$ Xmin}, \texttt{20$\to$ Xmax},\dots
\paragraph{Avec python,}
il est nécessaire d'avoir une bibliothèque d'outils graphiques
pour compléter le langage python.
La bibliothèque la plus répandue est \texttt{matplotlib},
mais n'est pour l'instant pas très facile d'accès
(à installer et/ou utiliser). \\
Une autre bibliothèque, \texttt{Libxy}, bien pus simple,
se trouve à l'adresse \url{https://xymaths.fr/Libxy}.
Les instructions et explications nécessaires se trouvent aussi à cette adresse.
\\
Une fois le fichier \texttt{Libxy.py} copié dans le répertoire courant,
la fonction \texttt{Point(x,y)} permet d'afficher le point de coordonnées
$(x,y)$.
\medskip
\paragraph{\Large Courbe représentative d'une fonction}
La courbe représentative d'une fonction est l'ensemble des points
de coordonnées $(x,y)$ tels que l'ordonnée est l'image par
la fonction $f$ de l'abscisse: $y=f(x)$.
On peut ainsi donner une représentation graphique d'une fonction
en placant un certain nombre de points.
\medskip
\bgmp{10cm}
On considère par exemple la fonction $f$ définie par l'expression
$f(x)=x^3+3x^2-1$.
\medskip
L'algorithme ci-contre permet d'afficher certains points de la courbe de $f$,
sur l'intervalle $[-5;5]$:
\enmp
\hfill\fbox{
\bgmp{7.5cm}
\texttt{Pour i allant de 0 à 10\\
\hspace*{0.5cm}Affecter -5+i à x\\
\hspace*{0.5cm}Affecter f(x) à y\\
\hspace*{0.5cm}Afficher le point (x;y)\\
Fin Pour}
\enmp}
\bgen
\item \'Ecrire le programme correspondant,
en adaptant éventuellement la fen\^etre graphique
(\texttt{Xmin}, \texttt{Xmax},\dots).
\item Cet algorithme affiche en tout 11 points;
Le modifier pour qu'il affiche 100 points entre
$-5$ et $5$.
\item Modifier l'algorithme pour qu'il affiche 1000 points.
\enen
\label{LastPage}
\end{document}
Télécharger le fichier source