I.U.T. DE CAEN - DÉPARTEMENT INFORMATIQUE
Transcription
I.U.T. DE CAEN - DÉPARTEMENT INFORMATIQUE
I.U.T. DE CAEN - DÉPARTEMENT INFORMATIQUE - 1ère année ANALYSE RÉSOLUTION NUMÉRIQUE D'ÉQUATIONS DICHOTOMIE. CASIO "X DEB="? → A "X FIN="? → B "P="? → P Lbl 1 Abs(B – A) < P ⇒ Goto 3 A→X Prog 0 : Ans → Y ou f1 → Y (A + B)/2 → X Prog 0 : Ans → Z ou f1 → Z YZ > 0 ⇒ Goto 2 X→B Goto 1 Lbl 2 X→A Goto 1 Lbl 3 A B Commentaires [A,B] est l'intervalle sur lequel on résoud f(x) =0. P est la précision souhaitée Tant que la précision P n'est pas atteinte, on calcule f(A), A+B ). 2 A+B Si f(A)f( ) > 0, 2 puis f( on remplace A par A+B , 2 sinon on remplace B par A+B . 2 On affiche les deux valeurs encadrant la solution à la précision P Pour utiliser ce programme, il faut auparavant enregistrer f(x) dans le programme P0 (modèles fx - 6800G, fx - 7000G, fx - 7500G, fx - 8500G) ou dans f1 (modèles fx - 7800G, fx - 8800G). P0 • MODE 2 • Sélectionner P0 • EXE • X2 – 5 • MODE 1 f1 • F MEM • X2 – 5 • STO 1 • AC 1 TI-81 PrgmA:DICHO : Lbl 1 : ClrHome : Disp "A" : Input A :A→X : Y1 → D : If Ans=0 : Goto 9 : Disp "B" : Input B :B→X : Y1 → E : If Ans=0 : Goto 9 : If DE>0 : Goto 1 : Disp "NB DEC" : Input N : Lbl 2 : ClrHome : Round((A+B)/2,N) → X : Y1 → Y : If Y = 0 : Goto 9 : If DY<0 : Goto 3 :X→A : Goto 4 : Lbl 3 :X→B : Disp A : Disp B : If abs(B – A)> 10^(-)N : Goto 2 : End : Lbl 9 : Disp X TI-82 PROGRAM : DICHO : Repeat DE≤0 : ClrHome : Prompt A,B : A → X : Y1 → D : Disp Ans : If Ans = 0 : Goto 9 : B → X : Y1 → E : Disp Ans : If Ans = 0 : Goto 9 : End : Input "NB DEC", N : Repeat abs (B – A)≤10^(-)N : ClrHome : Round((A+B)/2,N) → X : Y1 → Y : If Y = 0 : Goto 9 : If DY<0 : Then :X→B : Else :X→A : End : Disp A,B : End : Stop : Lbl 9 : Disp X TI-85 PROGRAM : DICHO : Repeat D*E≤0 : CILCD : Prompt A,B : A → x : y1 → D : Disp Ans : If Ans == 0 : Goto A : B → x : y1 → E : Disp Ans : If Ans == 0 : Goto A : End : Input "NB DEC", N : Repeat abs (B – A)≤10^(-)N : CILCD : Round((A+B)/2,N) → x : y1 → Y : If Y == 0 : Goto A : If D*Y<0 : Then :x→B : Else :x→A : End : Disp A,B : End : Stop : Lbl A : Disp x Ces programmes utilisent la fonction définie dans Y1 (TI 81 - TI 82) ou y1 (TI 85). 2 TI 89 / TI 92 dicho( ) Prgm setMode("Exact/Approx","Approximate") Local a,b,c,p,k Dialog Title "Résolution numérique de f(x)=0" Text " Dichotomie" Request "f(x)",exf Request "borne inf",ea Request "borne sup",eb Request "précision 10^(-p)",ep EndDlog expr(exf) → f(x) expr(ea) → a expr(eb) → b expr(ep) → p 0→k While abs(b-a)>10^(-p) (a+b)/2 → c k+1 → k If f(a)*f(c)>0 Then c→a Else c→b EndIf EndWhile Disp x=c Disp "Nb d'itérations:",k setMode("Exact/Approx","Auto") EndPrgm Commentaires Met la machine en mode de calcul approché Boîte de dialogue Les chaînes de caractères saisies dans la boîte de dialogue sont analysées par la fonction expr qui les convertit en expressions (fonction pour exf, valeurs numériques pour a, b et p). 3 MÉTHODE DE LAGRANGE. CASIO "X DEB="? → A "X FIN="? → B "P="? → P Lbl 1 A→Z A→X Prog 0 : Ans → C ou f1 → C B→X Prog 0 : Ans → D ou f1 → D A – C(A – B)/(D – C) → A Abs (A – Z) ≥ P ⇒ Goto 1 A TI lagrange() Prgm Local a,b,c,p,k Dialog Title "Résolution numérique de f(x)=0" Text " Méthode de Lagrange " Request "f(x)",exf Request "borne inf",ea Request "borne sup",eb Request "précision 10^(-p) p",ep EndDlog expr(exf) → f(x) expr(ea) → a expr(eb) → b expr(ep) → p 1→k (a*f(b)-b*f(a))/(f(b)-f(a)) → c Disp c While abs(c-a)>10^(-p) c→a (c*f(b)-b*f(c))/(f(b)-f(c)) → c Disp c k+1 → k EndWhile Disp x=approx(c) Disp "Nb d'itérations:",k EndPrgm MÉTHODE DE NEWTON TI 81 : PrgmA : NEWTON :(Xmax – Xmin)/100 → D : Lbl 1 : X – Y1/NDeriv(Y1,D) →R : If abs (X – R) ≤ abs (X/1E10) : Goto 2 :R→X : Goto 1 : Lbl 2 : Disp R Ce programme utilise la fonction définie dans Y1 et recherche une solution dans l'intervalle Xmin, Xmax correspondant à la fenêtre graphique. 4