Page 1 of 1

Correction algo exo 1 BAC S 2017 (Métropole - juin 2017)

Unread postPosted: 21 Jun 2017, 11:05
by critor
Correction algo exercice n°1 du sujet de Maths du BAC S 2017 de Métropole :
https://toutmonexam.fr/epreuve.php?id=2032

Question B)3)a) :
Pour obtenir le résultat ainsi que sa justification avec la trace par itération, rajoutons une instruction d'affichage en fin de boucle et programmons l'algorithme sur notre calculatrice graphique.


Algorithme
Programme
Code: Select all
Variables :
   λ réel
   S réel
   fonction h(x)=1-(x+1)/e^x
Initialisation :
   Saisir S
   λ prend la valeur 0
Traitement :
   Tant que h(λ)<S faire
      λ prend la valeur λ+1
      Afficher λ, h(λ) et h(λ)<S
   Fin tant que
Sortie :
   Afficher λ
Code: Select all
Prompt S
0→L
"1-(X+1)/e^(X)"→Y₁
While Y₁(L)<S
   L+1→L
   Disp {L,Y₁(L),Y₁(L)<S}
End
L

Code: Select all
Define me2017s(s)=
Func
   Local l,h
   0→l
   Define h(x)=1-(x+1)/e^x
   While h(l)<s
      l+1→l
      Disp l,h(l),h(l)<s
   EndWhile
   Return l
EndFunc
Code: Select all
?→S
0→L
"1-(X+1)^(X)"→Y1
While Y1(L)<S
   L+1→L
   {L,Y1(L),Y1(L)<S}◢
End
L

Code: Select all
Paramètres : s
SetDecimal
0⇒l
Define h(x)=1-(x+1)/e^x
While h(l)<s
   l+1⇒l
   Print {l,h(l),judge(h(l)<s)}
End
Return l
Code: Select all
EXPORT me2017s(s)
BEGIN
   L:=0;
   F1:="1-(X+1)/e^(X)";
   WHILE F1(L)<s DO
      L:=L+1;
      PRINT({L,F1(L),F1(L)<s});
   END;
   PRINT(L);
END;


Voici la trace par itération de l'algorithme :
λ
$mathjax$1-\frac{λ+1}{e^λ}$mathjax$
$mathjax$1-\frac{λ+1}{e^λ}<S$mathjax$
00Vrai
10,3Vrai
20,6Vrai
30,8Faux

L'algorithme affiche donc 3.