This commit is contained in:
Bertrand Benjamin 2019-03-19 08:18:55 +01:00
parent 41f58f1a81
commit 149d6b67d5

View File

@ -13124,18 +13124,18 @@ div#notebook {
</div><div class="inner_cell"> </div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html"> <div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Graphique-de-fonctions">Graphique de fonctions<a class="anchor-link" href="#Graphique-de-fonctions">&#182;</a></h2><p>Nous allons tracer la représentation graphique de</p> <h2 id="Graphique-de-fonctions">Graphique de fonctions<a class="anchor-link" href="#Graphique-de-fonctions">&#182;</a></h2><p>Nous allons tracer la représentation graphique de</p>
$$ f : x \mapsto \frac{x^2}{10} - 5 $$<p><strong>Recopier</strong> le programme suivant, <strong>compléter</strong> les pointillés et calculer les images jusqu'à 8.</p> $$ f : x \mapsto x^2 - 10x + 20 $$<p><strong>Recopier</strong> le programme suivant, <strong>compléter</strong> les pointillés et calculer les images jusqu'à 8.</p>
</div> </div>
</div> </div>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[3]:</div> <div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">):</span> <div class=" highlight hl-ipython3"><pre><span></span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="k">return</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span><span class="o">/</span><span class="mi">10</span> <span class="o">-</span> <span class="mi">5</span> <span class="k">return</span> <span class="n">x</span><span class="o">**</span><span class="mi">2</span> <span class="o">-</span> <span class="mi">10</span><span class="o">*</span><span class="n">x</span> <span class="o">+</span> <span class="mi">20</span>
<span class="c1"># image de 0</span> <span class="c1"># image de 0</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">)</span>
@ -13179,7 +13179,7 @@ L&#39;image de ... est ...
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[4]:</div> <div class="prompt input_prompt">In&nbsp;[2]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">):</span> <div class=" highlight hl-ipython3"><pre><span></span><span class="k">def</span> <span class="nf">f</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
@ -13193,7 +13193,7 @@ L&#39;image de ... est ...
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span> <span class="s2">&quot;On l&#39;ajoute à la liste&quot;</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span> <span class="s2">&quot;On l&#39;ajoute à la liste&quot;</span><span class="p">)</span>
<span class="n">antecedents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># On ajoute (append) 0 à la liste des antecedents</span> <span class="n">antecedents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># On ajoute (append) 0 à la liste des antecedents</span>
<span class="c1"># image de 1</span> <span class="c1"># image de 1</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span> <span class="s2">&quot;On l&#39;ajoute à la liste&quot;</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">)</span>
</pre></div> </pre></div>
</div> </div>
@ -13268,10 +13268,10 @@ L&#39;image de ... est ... On l&#39;ajoute à la liste
</div><div class="inner_cell"> </div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html"> <div class="text_cell_render border-box-sizing rendered_html">
<p>Vous avez tracer la courbe représentative de de la fonction $f$.</p> <p>Vous avez tracer la courbe représentative de de la fonction $f$.</p>
<p><img src="./fig/cos_pas1.png" alt="Représentation graphique de f"></p> <p><img src="./fig/plt_f.png" alt="Représentation graphique de f"></p>
<p>Dans un nouveau fichier, <strong>tracer</strong> la courbe représentative pour x allant de 0 à 50 de la fonction $g$ tel que <p>Dans un nouveau fichier, <strong>tracer</strong> la courbe représentative pour x allant de 0 à 15 de la fonction $g$ tel que
$$ g : x \mapsto x^2 - 4$$</p> $$ g : x \mapsto -(x - 5)^2 + 5$$</p>
<p><img src="./fig/g_pas1.png" alt="Représentation graphique de f"></p> <p><img src="./fig/plt_g.png" alt="Représentation graphique de f"></p>
</div> </div>
</div> </div>
@ -13279,7 +13279,8 @@ $$ g : x \mapsto x^2 - 4$$</p>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt"> <div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell"> </div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html"> <div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Pr&#233;cision-et-controle-du-trac&#233;">Pr&#233;cision et controle du trac&#233;<a class="anchor-link" href="#Pr&#233;cision-et-controle-du-trac&#233;">&#182;</a></h2><p>Pour le moment, on sait donner un maximum à l'antécédent $x$ mais on ne peut pas contrôler le minimum ni le pas (l'écart en 2 valeurs de $x$). Or pour tracer précisément la représentation graphique d'une fonction, nous avons besoin de contrôler la fenêtre (minimum et maximum) et le pas.</p> <h2 id="Pr&#233;cision-et-controle-du-trac&#233;">Pr&#233;cision et controle du trac&#233;<a class="anchor-link" href="#Pr&#233;cision-et-controle-du-trac&#233;">&#182;</a></h2><p>Pour le moment, on sait donner un maximum à l'antécédent $x$ mais on ne peut pas contrôler le minimum ni le pas (l'écart en 2 valeurs de $x$).</p>
<p>Or pour tracer précisément la représentation graphique d'une fonction, nous avons besoin de contrôler la <strong>fenêtre</strong> (minimum et maximum) et le <strong>pas</strong>.</p>
</div> </div>
</div> </div>
@ -13287,7 +13288,7 @@ $$ g : x \mapsto x^2 - 4$$</p>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt"> <div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell"> </div><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html"> <div class="text_cell_render border-box-sizing rendered_html">
<h2 id="Boucle-while-(tant-que-)">Boucle <code>while</code> (tant que )<a class="anchor-link" href="#Boucle-while-(tant-que-)">&#182;</a></h2><p>Ce type de boucle donne plus de contrôle sur $x$ et nous évite d'utiliser <code>range</code> qui est une commande qui n'existe que en Python.</p> <h2 id="Boucle-while-(tant-que-)">Boucle <code>while</code> (tant que )<a class="anchor-link" href="#Boucle-while-(tant-que-)">&#182;</a></h2><p>Une boucle <code>while</code> permet de répeter une ou plusieurs actions <strong>tant qu'</strong> une condition est vérifiée.</p>
<p>Les 2 programmes ci-dessous font la même chose.</p> <p>Les 2 programmes ci-dessous font la même chose.</p>
</div> </div>
@ -13295,21 +13296,77 @@ $$ g : x \mapsto x^2 - 4$$</p>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[&nbsp;]:</div> <div class="prompt input_prompt">In&nbsp;[3]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">):</span> <div class=" highlight hl-ipython3"><pre><span></span><span class="n">x</span> <span class="o">=</span> <span class="mi">0</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="n">x</span> <span class="o">=</span> <span class="n">x</span><span class="o">+</span><span class="mi">1</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
</div> </div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>0
1
2
3
4
5
6
7
8
9
</pre>
</div>
</div>
</div>
</div>
</div> </div>
<div class="cell border-box-sizing code_cell rendered"> <div class="cell border-box-sizing code_cell rendered">
<div class="input"> <div class="input">
<div class="prompt input_prompt">In&nbsp;[&nbsp;]:</div> <div class="prompt input_prompt">In&nbsp;[4]:</div>
<div class="inner_cell"> <div class="inner_cell">
<div class="input_area"> <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">x</span> <span class="o">=</span> <span class="mi">0</span> <div class=" highlight hl-ipython3"><pre><span></span><span class="n">x</span> <span class="o">=</span> <span class="mi">0</span>
@ -13322,6 +13379,33 @@ $$ g : x \mapsto x^2 - 4$$</p>
</div> </div>
</div> </div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_subarea output_stream output_stdout output_text">
<pre>0
1
2
3
4
5
6
7
8
9
</pre>
</div>
</div>
</div>
</div>
</div> </div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt"> <div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div><div class="inner_cell"> </div><div class="inner_cell">
@ -13346,9 +13430,22 @@ $$ g : x \mapsto x^2 - 4$$</p>
<span class="n">images</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">images</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">antecedants</span> <span class="o">=</span> <span class="p">[]</span> <span class="n">antecedants</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">20</span><span class="p">):</span> <span class="c1"># image de 0</span>
<span class="n">images</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">h</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span> <span class="s2">&quot;On les ajoute à la liste&quot;</span><span class="p">)</span>
<span class="n">antecedants</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="n">antecedents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="n">images</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">h</span><span class="p">(</span><span class="mi">0</span><span class="p">))</span>
<span class="c1"># image de 1</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span> <span class="s2">&quot;On les ajoute à la liste&quot;</span><span class="p">)</span>
<span class="n">antecedents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="n">images</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">h</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
<span class="c1"># ....</span>
<span class="c1"># image de 20</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;L&#39;image de&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span><span class="s2">&quot; est&quot;</span><span class="p">,</span> <span class="s2">&quot;...&quot;</span><span class="p">,</span> <span class="s2">&quot;On les ajoute à la liste&quot;</span><span class="p">)</span>
<span class="n">antecedents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">20</span><span class="p">)</span>
<span class="n">images</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">h</span><span class="p">(</span><span class="mi">20</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Les images sont &quot;</span><span class="p">,</span> <span class="n">images</span><span class="p">)</span> <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Les images sont &quot;</span><span class="p">,</span> <span class="n">images</span><span class="p">)</span>
</pre></div> </pre></div>