Voici la présentation française (celle du site du concours)
Calcul exact par étapes Auteur : sandro Langage / Catégorie : TI-Basic Type : Programme
Compatible : TI 82 STATS, TI 83, TI 83 Plus, TI 84 Plus.
Voci un programme de calcul exact. Il s'effectue par étapes, chacune étant affichée (pratique pour les devoirs
de maths quand le prof demande les étapes intermédiaires).
Pour l'insant, ce programme ne gère que des résultats rationnels.
Les oppérations admises pour l'instant sont : l'addition, la soustraction, la multiplication, la division,
le carré, le cube, et l'inverse. Le programme gère également les parrenthèses et les fractions (sous
la forme {entier relatif:entier positif} ). Les constantes et autres oppérations ne sont pas accèptées pour l'instant.
A la fin, le programme affiche le résultat arrondit.
Pour afficher l'étape suivante, appuyez sur [entrer] ( [enter] ); si rien ne s'affiche de plus, c'est que la TI n'a
pas encore trouvée l'étape suivante.
Sandro
Voci les liens :
Fichier joint : CALCAUTO.83p
Fichier joint : _theta__theta_ADD.83p
Fichier joint : _theta__theta_ADDF.83p
Fichier joint : _theta__theta_CARCU.83p
Fichier joint : _theta__theta_CARCUF.83p
Fichier joint : _theta__theta_DETBC.83p
Fichier joint : _theta__theta_DIV.83p
Fichier joint : _theta__theta_DIVFPN.83p
Fichier joint : _theta__theta_DIVPF.83p
Fichier joint : _theta__theta_INV.83p
Fichier joint : _theta__theta_MULT.83p
Fichier joint : _theta__theta_MULTF.83p
Fichier joint : _theta__theta_SIGNE.83p
Fichier joint : _theta_DELPAR.83p
Fichier joint : _theta_MONONIV.83p
Fichier joint : _theta_NIVPAR.83p
Voici les codes :
programmeCALCAUTO (programme à lancer, veille à alterner entre le programme de calcul, et celui de supression de parrenthèses (pour l'instant très court, mais qui ce compliquera quand je rajouterrais les racines).
0 -> K
" " -> Str8
"{E,E -> L6
"{1,2 -> L5
Input "CALCUL:",Str0
Str0 -> Str6
" "+Str0+" " -> Str0
" " -> Str7
ClrHome
While Str7=/=Str0
Str0 -> Str7
prgm[théta]MONONIV
prgm[théta]DELPAR
End
sub(Str0,3,length(Str0)-4 -> Str9
1 -> A
While A
inString(Str9,"{",A -> A
If A:Then
"("+sub(Str9,A+1,length(Str9)-A -> Str2
If A=/=1
sub(Str9,1,A-1)+Str2 -> Str2
Str2 -> Str9
End
End
1 -> A
While A
inString(Str9,":",A+1 -> A
If A
sub(Str9,1,A-1)+"/"+sub(Str9,A+1,length(Str9)-A -> Str9
End
1 -> A
While A
inString(Str9,"}",A+1 -> A
If A
Then
sub(Str9,1,A-1)+")" -> Str2
If A=/=length(Str9
Str2+sub(Str9,A+1,length(Str9)-A -> Str2
Str2 -> Str9
End
Pause expr(Str9
programme[théta]NIVPAR (trouve quels sont les "niveaux de parrenthèses" (combien siont ouverte à tel endroit)
{0 -> L1
length(Str0 -> L
L -> dim(L1
For(A,1,L
sub(Str0,A,1 -> Str2
If Str2=")
-1 -> L1(A+1
If inString("(sin(cos(tan(sin-1(cos-1(tan-1([e^(][10^(][racine carré)[racine cube]Ýð(",Str2 //les crochets servent juste pour signaler qu'il s'agit d'un seul et même symbol
1 -> L1(A+1
End
cumSum(L1 -> L2
programme[théta]MONONIV (gère les sous-programmes propre à chaque oppération) 3 -> A While A+3[inférieur ou égal]length(Str0 If Str8=/=Str0 Then If K Pause 1 -> K Disp sub(Str0,3,length(Str0)-4 Str0 -> Str8 End A -> B A+1 -> A A+1 -> C 1 -> [théta] sub(Str0,A,1 -> Str9 prgm[théta][théta]SIGNE If Str9="+ prgm[théta][théta]ADD If Str9="* prgm[théta][théta]MULT If Str9="[carré] DelVar [théta]prgm[théta][théta]CARCU If Str9="/ prgm[théta][théta]DIV If Str9="[^-1] prgm[théta][théta]INV If Str9="[cube] prgm[théta][théta]CARCU End
programme[théta]DELPAR
If inString(Str0,"("
Then
1üB
While B
inString(Str0,"(",B+1 -> B
If B:B -> A
End
A -> B
1 -> C
B+1 -> A
While C
A+1 -> A
sub(Str0,A,1 -> Str2
If Str2=")
C-1 -> C
If inString("(sin(cos(tan(sin-1(cos-1(tan-1([10^(][e^(][racine carré][racine cube]",Str2
C+1 -> C
End
A -> C
sub(Str0,B+1,C-B-1 -> Str4
1 -> D
For(A,1,length(Str4
If not(inString("[moins des relatifs]0.123456789{:}",sub(Str4,A,1
0 -> D
If D
Then
sub(Str0,1,B-1)+Str4+sub(Str0,C+1,length(Str0)-C -> Str0
Return
End
sub(Str0,A-1,1 -> Str2
sub(Str0,B+1,1 -> Str3
programme[théta][théta]ADD (addition-soustraction)
"^/*) -> Str1
"^/*([inverse][carré][cube][pi]e -> Str7
If sub(Str0,A,2)="+{" or "}+"=sub(Str0,B,2
Then
1 -> X
prgm[théta][théta]ADDF
If not(X:Return
Else
prgm[théta][théta]DETBC
If not(X:Return
expr(Str2 -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
End
sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A
programme[théta][théta]ADDF (addition et soustractions avec fraction)
1 -> X
prgm[théta][théta]DETBC
If not(X:Return
sub(Str0,B+1,A-B-1 -> Str2
sub(Str0,A+1,C-A-1 -> Str3
inString(Str2,": -> H
inString(Str3,": -> M
If H
Then
expr(sub(Str2,2,H-2 -> N
expr(sub(Str2,H+1,length(Str2)-H-1 -> O
Else
expr(Str2 -> N
1 -> O
End
If M
Then
expr(sub(Str3,2,M-2 -> P
expr(sub(Str3,M+1,length(Str3)-M-1 -> Q
Else
expr(Str3 -> P
1 -> Q
End
While fPart(N) or fPart(O
10N -> N
10O -> O
End
While fPart(P) or fPart(Q
10P -> P
10Q -> Q
End
gcd(abs(N),abs(O))^-1 -> H
NH -> N
OH -> O
gcd(abs(P),abs(Q))^-1 -> M
PM -> P
QM -> Q
OQ -> V
NQ+PO -> U
(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> W
UW -> U
VW -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
If U=0
Then
"0 -> Str2
Else
sub(Str2,4,length(Str2)-3 -> Str2
If V=/=1
"{"+Str2+":"+sub(Str3,4,length(Str3)-3)+"} -> Str2
programme[théta][théta]CARCU (carré et cube)
If "}"=sub(Str0,B,1
Then
prgm[théta][théta]CARCUF
Else
While Bø1 and inString("0.123456789à",sub(Str0,B,1
B-1 -> B
End
If ")"=sub(Str0,B,1
Return
If B=1:0 -> B
sub(Str0,B+1,A-B -> Str2
expr(Str2 -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
End
sub(Str0,1,B)+Str2+sub(Str0,A+1,length(Str0)-A -> Str0
1 -> A
programme[théta][théta]CARCUF (cube et carré de fractions)
While Bø1 and "{"øsub(Str0,B,1
B-1 -> B
End
B-1 -> B
If B=1:0 -> B
inString(Str0,":",B+2 -> H
sub(Str0,B+2,H-B-2 -> Str2
sub(Str0,H+1,A-H-2 -> Str3
expr(Str2)^(2+[theta]) -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
expr(Str3)^(2+[theta]) -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
"{"+sub(Str2,4,length(Str2)-3)+":"+sub(Str3,4,length(Str3)-3)+"}" -> Str2
PROGRAMME[théta][théta]DETBC (calcule B et C, respectivement le rand du dernier carractère avant la chaîne exprimée et le premier après)
While Bø1 and inString("[le moins des relatifs]0.123456789à{:}",sub(Str0,B,1
B-1 -> B
End
If inString(Str1,sub(Str0,B,1
DelVar XReturn
If B=1:0 -> B
While Cølength(Str0) and inString("-0.123456789à{:}",sub(Str0,C,1
C+1 -> C
End
If inString(Str7,sub(Str0,C,1
DelVar XReturn
If C=length(Str0:C+1 -> C
sub(Str0,B+1,C-B-1 -> Str2
[théta][théta]DIV (division d'un nombre décimal par un autre
"/^) -> Str1
"^([inverse][carré][cube][pi]e -> Str7 //les crochets servent uniquement a marquer les carracteres speciaux
1 -> X
If "}"=sub(Str0,A-1,1) and inString("0.-123456789",sub(Str0,A+1,1
Then
prgm[theta][theta]DIVFPN
If not(X:Return
Else
If "/{"=sub(Str0,A,2
Then
prgm[thete][theta]DIVPF
If not(X:Return
Else
prgm[theta][theta]DETBC
If not(X:Return
expr(Str2 -> E
If not(fPart(E[E des puissances de 10]5
Then
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
Goto Q
End
sub(Str0,B+1,A-B-1 -> Str2
sub(Str0,A+1,C-A-1 -> Str3
expr(Str2 -> U
expr(Str3 -> V
While fPart(U) or fPart(V
10U -> U
10V -> V
End
(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> N
UN -> U
VN -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
"{"+sub(Str2,4,length(Str2)-3)+":"+sub(Str3,4,length(Str3)-3)+"} -> Str2
Lbl Q
End
End
sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A
[théta][théta]DIVFPN (division d'une fraction par un un nombre)
prgm[theta][theta]DETBC
If not(X:Return
inString(Str0,":",B+1 -> H
sub(Str0,B+2,H-B-2 -> Str2
sub(Str0,H+1,A-H-2 -> Str3
sub(Str0,A+1,C-A-1 -> Str4
expr(Str2 -> U
expr(Str3 -> V
expr(Str4 -> W
VW -> V
(-2(V<0)+1)gcd(abs(U),abs(V))^-1 -> N
UN -> U
VN -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
V -> E
LinReg(ax+b)L5,L6,Y9
EquåString(Y9,Str3
sub(Str3,4,length(Str3)-3 -> Str3
If V=/=0
"{"+Str2+":"+Str3+"}" -> Str2
programme[théta][théta]DIVPF (division par une fraction)
inString(Str0,":",A+2 -> H
inString(Str0,"}",H+2 -> I
sub(Str0,A+2,H-A-2 -> Str2
sub(Str0,H+1,I-H-1 -> Str3
"*{"+Str3+":"+Str2+"}" -> Str2
I+1 -> C
If inString("^[^-1][^2][^3][pi](e",sub(Str0,C,1
DelVar X
programme[théta][théta]INV (inverse d'un nombre)
While inString("[moins des relatifs]0.123456789{:}",sub(Str0,B,1
B-1 -> B
End
sub(Str0,B+1,A-B-1 -> Str4
inString(Str4,":" -> H
If H
Then
sub(Str4,2,H-2 -> Str2
sub(Str4,H+1,length(Str4)-H-1 -> Str3
expr(Str2 -> V
expr(Str3 -> U
Else
expr(Str4) -> V
1 -> U
End
While fPart(U) or fPart(V
10U -> U
10V -> V
End
(-2(U<0)+1)gcd(abs(U),abs(V))^-1 -> H
UH -> U
VH -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str3
If U=0
Then
"0 -> Str2
Else
sub(Str2,4,length(Str2)-3 -> Str2
If V=/=1
"{"+Str2+":"+sub(Str3,4,length(Str3)-3)+"}" -> Str2
sub(Str0,1,B)+Str2+sub(Str0,A+1,length(Str0)-A -> Str0
programme[théta][théta]MULT (multiplication)
"^)/ -> Str1
"^([^-1][^2][^3][pi]e -> Str7
1 -> X
If "}"=sub(Str0,A-1,1) or "{"=sub(Str0,A+1,1
Then
prgm[theta][theta]MULTF
If not(X:Return
Else
prgm[theta][theta]DETBC
If not(X:Return
expr(Str2 -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
End
sub(Str0,1,B)+Str2+sub(Str0,C,length(Str0)-C+1 -> Str0
1 -> A
programme[théta][théta]MULTF (multiplication avec fraction(s) )
While B=/=1 and inString(":{}-0.123456789",sub(Str0,B,1
B-1 -> B
End
If inString("^/)",sub(Str0,B,1
Return
If B=1:0 -> B
sub(Str0,B+1,A-B-1üStr2
inString(Str2,":" -> H
If H
Then
expr(sub(Str2,2,H-2 -> N
expr(sub(Str2,H+1,length(Str2)-H-1 -> O
Else
expr(Str2 -> N
1 -> O
While fPart(N
10N -> N
10O -> O
End
gcd(abs(N),O)^-1üG
NG -> N
OG -> O
End
A+1 -> C
While C=/=length(Str0) and inString(":{}-0.123456789",sub(Str0,C,1
C+1 -> C
End
If inString("^)sin(cos(tan(sin-1(cos-1(tan-1([pi]e[10^(][e^(][^-1][^2][^3][racine carre][racine cube] [racine X]",sub(Str0,C,1
DelVar XReturn
If C=length(Str0):C+1 -> C
sub(Str0,A+1,C-A-1 -> Str2
inString(Str2,":" -> H
If H
Then
expr(sub(Str2,2,H-2 -> P
expr(sub(Str2,H+1,length(Str2)-H-1 -> Q
Else
expr(Str2 -> P
1 -> Q
While fPart(P
10P -> P
10Q -> Q
End
gcd(abs(P),Q)^-1üG
PG -> P
QG -> Q
End
NP -> U
OQ -> V
(-2(V<0)+1)gcd(abs(U),abs(V))^-1üG
UG -> U
VG -> V
U -> E
LinReg(ax+b)L5,L6,Y9
Equ>String(Y9,Str2
sub(Str2,4,length(Str2)-3 -> Str2
V -> E
LinReg(ax+b)L5,L6,Y9
Eq>String(Y9,Str3
sub(Str3,4,length(Str3)-3 -> Str3
If U=0
Then
"0 -> Str2
Else
If V=/=1
"{"+Str2+":"+Str3+"}" -> Str2
programme[théta][théta]SIGNE (transforme la soustraction en addition)
1 -> Y
While Y
inString(Str0,"[moins des soustractions]",Y -> Y
If Y
Then
If "{"=sub(Str0,Y+1,1
Then
sub(Str0,1,Y-1)+"+{[moins des relatifs]"+sub(Str0,Y+2,length(Str0)-Y-1 -> Str0
Else
sub(Str0,1,Y-1)+"+[moins des relatifs]"+sub(Str0,Y+1,length(Str0)-Y -> Str0
End
End
End
Sandro
PS : je vais essayer d'étandre aux réels, mais je n'ai pas encore trouvé la meilleure méthode.

Le remplacement automatique me fait tout à tort et à travers