Discussion Utilisateur:Dévilès/Graphiques Calcul intégral

Un article de Wikipédia, l'encyclopédie libre.

À propos, j’ai un programme de TI 86 pour calculer approximativement des intégrales, la partie intéressante est celle sur la méthode de Gauss où les intervalles d’interpolation ne sont plus centrés (mais c’est peut-être balaise pour des mathématiques élémentaires) :

# programme servant à calculer l'intégrale d'une fonction sur un intervalle par des méthodes approchées

# tente-t-on de lancer le programme en tant que programme autonome ?

If AccesSP=/=1
Then
        Disp "Ça est sous programme"
        Stop
End

Lbl PP
        Menu(1,"Exit",SP1,2,"Méthd",SP2,3,"P/N",SP3,4,"Intg",SP4,5,"Vrbl",SP5,6,"Graph",SP6)

# retour au programme d'appel

Lbl SP1
        1E-5->tol
        Return

Lbl SP2
        Menu(1,"Exit",PP,2,"Intpl",SP2S1,3,"Gauss",SP2S2,4,"Calc",SP2S3)
# méthode par interpolation de polynôme de degré n passant par n+1 points également répartis
        Lbl SP2S1
                "I"->M
                Goto SP2S4
# méthode par interpolation de polynôme de degré n passant par n+1 points -dite de Gauss- et minimisant une distance intégrale
        Lbl SP2S2
                "G"->M
                Goto SP2S5
# méthode de la calculette
        Lbl SP2S3
                "CAL"->M
                Goto PP
        Lbl SP2S4
                Menu(1,"Rec A",SP2S6,2,"Rec B",SP2S7,3,"Trpz",SP2S8,4,"Smpsn",SP2S9)
        Lbl SP2S5
                Menu(1,"Rec",SP2S6,2,"Trpz",SP2S8,3,4,"Prbol",SP2S9)
# par des rectangles débutant à gauche
        Lbl SP2S6
                M+"RA"->M:Goto PP
# par des rectangles débutant à droite (sauf pour la méthode de Gauss)
        Lbl SP2S7
                M+"RB"->M:Goto PP
# par des trapèzes
        Lbl SP2S8
                M+"TR"->M:Goto PP
# par des paraboles
        Lbl SP2S9
                M+"SI"->M:Goto PP
        Goto PP

Lbl SP3
        Menu(1,"Exit",PP,2,"Préc",SP3S1,3,"N",SP3S2)
        Lbl SP3S1
                Input "Précision ",P
# on entre la précision et on en déduit le nombre d'itérations selon la méthode
                If ((M=="IRA")+(M=="IRB"))==1
                Then
                        Input "Sup|f'| ",F
                        int (F*C^2/(2P))->N
                Else
                If M=="ITR"
                Then
                        Input "Sup|f''| ",F
                        int sqrt(F*C^3/(12P))->N
                Else
                If M=="ISI"
                Then
                        Input "Sup|f''''| ",F
                        int sqr4t(F*C^5/(2880P))->N
                Else
                If M=="GRA"
                Then
                        Input "Sup|f''| ",F
                        int sqrt(F*C^3/(24P))->N
                Else
                If M=="GTR"
                Then
                        Input "Sup|f''''| ",F
                        int sqr4t(F*C^5/(4320P))->N
                Else
# j'ai galéré pour trouver celui-là
                If M=="GSI"
                Then
                        Input "Sup|fxxx| ",F
                        int sqr6t(F*C^7/(2016E3P))->N
                Else
                        P->tol
                End
                End
                End
                End
                End
                End
                Goto PP
        Lbl SP3S2
                Input "N ",N
# on entre le nombre d'itérations et on déduit la précision
                If ((M=="IRA)+(M=="IRB))==1
                Then
                        Input "Sup|f'| ",F
                        F*C^2/(2N)->P
                Else
                If M=="ITR"
                Then
                        Input "Sup|f''| ",F
                        F*C^3/(12N^2)->P
                Else
                If M=="ISI"
                Then
                        Input "Sup|f''''| ",F
                        F*C^5/(2880N^4)->P
                Else
                If M=="GRA"
                Then
                        Input "Sup|f''| ",F
                        F*C^3/(24N^2)->P
                Else
                If M=="GTR"
                Then
                        Input "Sup|f''''| ",F
                        F*C^5/(4320N^4)->P
                Else
                If M=="GSI"
                Then
                        Input "Sup|fxxx| ",F
                        F*C^7/(2016E3N^7)->P
                Else
                        P->tol
                End
                End
                End
                End
                End
                End
                Goto PP

Lbl SP4
        0->I
        If M=="Cal"
        Then
                fnInt(y1,x,A,B)->I
        Else
        If M=="IRA"
        Then
                For(J,0,N-1)
                        I+C*y1(A+J*C/N)->I
                End
# pour simplifier les calculs et minimiser les erreurs
                C*I/N->I
        Else
        If M=="IRB"
        Then
                For(J,1,N)
                        I+y1(A+J*C/N)->I
                End
                C*I/N->I
        Else
        If M=="ITR"
        Then
                For(J,1,N)
                        I+y1(A+J*C/N)+y1(A+(J-1)C/N->I
                End
                C*I/2/N->I
        Else
        If M=="ISI"
        Then
                For(J,1,N-1)
                        I+y1(A+J*C/N)->I
                End
                For(J,0,N-1)
                        I+2*y1(A+C(2J+1)/2/N)->I
                End
                2I->I
                I+y1(A)+y1(B)->I
                C*I/6/N->I
        Else
        If M=="GRA"
        Then
                For(J,0,N-1)
                        I+y1(A+C(J+.5)/N)->I
                End
                C*I/N->I
        Else
        If M=="GTR"
        Then
                For(J,0,N-1)
                        A+C*(J+.5)/N->AJ:I+y1(AJ+C/sqrt12/N)+y1(AJ-C/sqrt12/N)->I
                End
                DelVar(AJ):C*I/N/2->I
        Else
                For(J,0,N-1)
                        A+C*(J+.5)/N->AJ:I+5(y1(AJ+Csqrt(3/20)/N)+y1(AJ-Csqrt(3/20)/N))+8y1(AJ)->I
                End
                DelVar(AJ):C*I/N/18->I
        End
        End
        End
        End
        End
        End
        End
        DelVar(J)
        Goto PP

Lbl SP5
        Disp "f(x)=",Y
        Disp "A=",A
        Disp "B=",B
        Pause
        Disp "Mthd=",M
        Disp "Préc=",P
        Disp "N=",N
        Pause
        Disp "Sup|F~|",F
        Disp "Sf(x)=",I
        Goto PP

Lbl SP6
# cf. programme Fonction
        A-C/5->xMin
        B+C/5->xMax
        y1(fMin(y1,x,xMin,xMax))->yMin
        y1(fMax(y1,x,xMin,xMax))->yMax
        yMax-yMin->D
        (yMin<(D/5))yMin-D/5->yMin
        (yMax>(-D/5))yMax+D/5->yMax
        (xMax-xMin)/10->xScl
        (yMax-yMin)/10->yScl
        DelVar(D)
# selon la méthode on hachure et on graisse le trait de différentes façons
        If M=="CAL"
        Then
                1->H
        Else
        If sub(M,1,1)=="I"
        Then
                4->H
        Else
                3->H
        End
        End
        sub (M,2,2)->MM
        If MM="SI"
        Then
                4->HH
        Else
        If MM=="TR"
        Then
                3->HH
        Else
        If MM=="RA"
        Then
                2->HH
        Else
                1->HH
        End
        End
        End
        FnOff
        FnOn 1
# on trace
        Shade(y1,0,A,B,HH,H)
        Shade(0,y1,A,B,HH,H)
        DelVar(H):DelVar(HH)
        DelVar(MM)
        Goto PP

[modifier] Graphiques

Tu m'avais demandé d'y jeter un œil. Je n'ai pas regardé dans les détails (pas trop le temps !), mais ça m'a l'air d'être une base tout à fait intéressante pour illustrer les articles de méthodes de calcul d'intégrales. Bonne continuation !

--Ąļḋøø 6 déc 2004 à 17:35 (CET)

[modifier] A ton tour

Comme tu peux le voir, j'ai bossé sur Calcul numérique d'une intégrale que j'ai créée et j'ai aussi fait Méthode des trapèzes en utilisant tes graphiques (tu aurais pû trouver une fonction plus simple !). Maintenant, je te laisse faire la Méthode de Simpson.

--Pierrelm 22 avr 2005 à 23:18 (CEST)

[modifier] Compression

C'est sympa de faire des graphiques, mais quel gâchis de les enregistrer en JPEG ! SVG ou PNG étaient par exemple appropriés. — Florian, le 3 avril 2007 à 16:00 (CEST)