A voir également:
- Méthode de l'analyse numérique en pascal
- Turbo pascal - Télécharger - Édition & Programmation
- Télévision numérique - Guide
- Télévision numérique terrestre - Accueil - TV & Vidéo
- My pascal - Télécharger - Édition & Programmation
- Pavé numérique bloqué - Guide
5 réponses
Précises ton sujet, pour l'instant c'est pas très clair, on pourra t'aider pour le comment faire ceci ou cela en Pascal, mais c'est pas évident de donner les réponses si on a pas les questions
program ziouche_interface;
uses crt;
var xmin,xmax,pas,a,seuil,x0,x1,y:real;
s:integer;
function f(x0:real):real;
begin
f:=x0*x0*x0+2*x0+1;
end;
Function newt(x:real):real;
Begin
newt:=(2*x*x*x-1)/(3*x*x+2);
End;
Function lag(x:real):real;
Begin
lag:=(-x*x+x-1)/(x*x-x+3);
end;
Function pf(x:real):real;
Begin
pf:=(-x*x*x-1)/2;
End;
procedure entree;
begin
gotoxy(1,10);
textcolor(14);
write('Donner la valeur de xmin :');
readln(xmin);
write('Donner la valeur de xmax :');
readln(xmax);
write('Donner la valeur de seuil: ');
readln(seuil);
End;
procedure baly(a,seuil:real);
var y1,y2,xsuit:real;
begin
while a<xmax do
begin
y1:=f(a);
xsuit:=a+seuil;
y2:=f(xsuit);
if (y1*y2)<0 then
writeln('la solution entre ',a,' et ',xsuit);
a:=a+Seuil;
end;
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
end;
procedure dicho(a,b,seuil:real);
var mil:real;
begin
writeln ('la solution est dans l''intervelle ');
writeln('[',a,',',b,']');
while abs(b-a)>=seuil do
begin
mil:=(a+b)/2 ;
if (f(a)*f(mil))<=0 then
b:=mil
else a:=mil;
writeln('[',a,',',b,']');
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
end;
end;
Procedure Newton(x1,seuil:real);
Begin
x0:=x1;
while abs(x0-newt(x0))>=seuil do
Begin
y:=newt(x0);
x0:=y;
End;
writeln ('Valeur de solution est de: ',x0);
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
End;
Procedure Lagrange(x1,seuil:real);
Begin
x0:=x1;
while abs(x0-lag(x0))>=seuil do
Begin
y:=lag(x0);
x0:=y;
End;
writeln('Valeur de solution de: ',x0);
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
End;
Procedure Pointfixe(x1,seuil:real);
Begin
x0:=x1;
while abs(x0-pf(x0))>=seuil do
Begin
y:=pf(x0);
x0:=y;
End;
writeln ('Valeur de solution de : ',x0);
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
End;
procedure fausep(a,b,seuil:real);
var mil:real;
begin
writeln ('la solution est dans l intervale ');
writeln('[',a,',',b,']');
while abs(b-a)>=seuil do
begin
mil:=a-((f(a)/(f(b)-f(a)))*(b-a)) ;
if (f(a)*f(mil))<=0 then
b:=mil
else a:=mil;
writeln('[',a,',',b,']');
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
end;
end;
begin
repeat
clrscr;
gotoxy(28,2);
textcolor(10);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(30);
gotoxy(23,4);
writeln('le mini projet d"analyse Nemurique ');
textcolor(10);
gotoxy(15,6);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
gotoxy(18,8);
textcolor(9);
writeln('********************************************');
gotoxy(18,9);
textcolor(2);
writeln('* Choisisez la methode que vous voulez: *');
gotoxy(18,10);
textcolor(1);
writeln('* -1- pour la methode de balayage *');
gotoxy(18,11);
textcolor(8);
writeln('* -2- pour la methode de DECHOTOMIE *');
gotoxy(18,12);
textcolor(3) ;
writeln('* -3- pour la methode de NEWTON *');
gotoxy(18,13);
textcolor(4) ;
writeln('* -4- pour la methode de point fixe *');
gotoxy(18,14);
textcolor(5) ;
writeln('* -5- pour la methode de fausse position *');
gotoxy(18,15);
textcolor(6) ;
writeln('* -6- pour la methode de lagrange *');
gotoxy(18,16);
textcolor(7);
writeln('* -7- pour sortir *');
gotoxy(18,17);
textcolor(9) ;
writeln('********************************************');
textcolor(15);
readln(s);
case s of
1:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
baly(xmin,seuil);
end;
2:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
dicho(xmin,xmax,seuil);
end;
3:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
newton(xmin,seuil);
end;
4:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
pointfixe(xmin,seuil);
end;
5:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
Fausep(xmin,xmax,seuil);
end;
6:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
Lagrange(xmin,seuil);
end;
end;
readln;
until s=7;
end.
uses crt;
var xmin,xmax,pas,a,seuil,x0,x1,y:real;
s:integer;
function f(x0:real):real;
begin
f:=x0*x0*x0+2*x0+1;
end;
Function newt(x:real):real;
Begin
newt:=(2*x*x*x-1)/(3*x*x+2);
End;
Function lag(x:real):real;
Begin
lag:=(-x*x+x-1)/(x*x-x+3);
end;
Function pf(x:real):real;
Begin
pf:=(-x*x*x-1)/2;
End;
procedure entree;
begin
gotoxy(1,10);
textcolor(14);
write('Donner la valeur de xmin :');
readln(xmin);
write('Donner la valeur de xmax :');
readln(xmax);
write('Donner la valeur de seuil: ');
readln(seuil);
End;
procedure baly(a,seuil:real);
var y1,y2,xsuit:real;
begin
while a<xmax do
begin
y1:=f(a);
xsuit:=a+seuil;
y2:=f(xsuit);
if (y1*y2)<0 then
writeln('la solution entre ',a,' et ',xsuit);
a:=a+Seuil;
end;
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
end;
procedure dicho(a,b,seuil:real);
var mil:real;
begin
writeln ('la solution est dans l''intervelle ');
writeln('[',a,',',b,']');
while abs(b-a)>=seuil do
begin
mil:=(a+b)/2 ;
if (f(a)*f(mil))<=0 then
b:=mil
else a:=mil;
writeln('[',a,',',b,']');
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
end;
end;
Procedure Newton(x1,seuil:real);
Begin
x0:=x1;
while abs(x0-newt(x0))>=seuil do
Begin
y:=newt(x0);
x0:=y;
End;
writeln ('Valeur de solution est de: ',x0);
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
End;
Procedure Lagrange(x1,seuil:real);
Begin
x0:=x1;
while abs(x0-lag(x0))>=seuil do
Begin
y:=lag(x0);
x0:=y;
End;
writeln('Valeur de solution de: ',x0);
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
End;
Procedure Pointfixe(x1,seuil:real);
Begin
x0:=x1;
while abs(x0-pf(x0))>=seuil do
Begin
y:=pf(x0);
x0:=y;
End;
writeln ('Valeur de solution de : ',x0);
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
End;
procedure fausep(a,b,seuil:real);
var mil:real;
begin
writeln ('la solution est dans l intervale ');
writeln('[',a,',',b,']');
while abs(b-a)>=seuil do
begin
mil:=a-((f(a)/(f(b)-f(a)))*(b-a)) ;
if (f(a)*f(mil))<=0 then
b:=mil
else a:=mil;
writeln('[',a,',',b,']');
textcolor(4);
writeln('voullez tapez la touche Entr pour choisir une autre methode');
end;
end;
begin
repeat
clrscr;
gotoxy(28,2);
textcolor(10);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(30);
gotoxy(23,4);
writeln('le mini projet d"analyse Nemurique ');
textcolor(10);
gotoxy(15,6);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
gotoxy(18,8);
textcolor(9);
writeln('********************************************');
gotoxy(18,9);
textcolor(2);
writeln('* Choisisez la methode que vous voulez: *');
gotoxy(18,10);
textcolor(1);
writeln('* -1- pour la methode de balayage *');
gotoxy(18,11);
textcolor(8);
writeln('* -2- pour la methode de DECHOTOMIE *');
gotoxy(18,12);
textcolor(3) ;
writeln('* -3- pour la methode de NEWTON *');
gotoxy(18,13);
textcolor(4) ;
writeln('* -4- pour la methode de point fixe *');
gotoxy(18,14);
textcolor(5) ;
writeln('* -5- pour la methode de fausse position *');
gotoxy(18,15);
textcolor(6) ;
writeln('* -6- pour la methode de lagrange *');
gotoxy(18,16);
textcolor(7);
writeln('* -7- pour sortir *');
gotoxy(18,17);
textcolor(9) ;
writeln('********************************************');
textcolor(15);
readln(s);
case s of
1:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
baly(xmin,seuil);
end;
2:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
dicho(xmin,xmax,seuil);
end;
3:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
newton(xmin,seuil);
end;
4:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
pointfixe(xmin,seuil);
end;
5:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
Fausep(xmin,xmax,seuil);
end;
6:
begin
clrscr;
gotoxy(28,4);
textcolor(26);
writeln('ZIOUCHE Abdelhak D0307010') ;
textcolor(14);
gotoxy(23,6);
writeln('le mini projet d"analyse Nemurique ');
gotoxy(15,8);
textcolor(26);
writeln('"le Recherche du solutions de l"equation :xü+2x+1"');
entree;
Lagrange(xmin,seuil);
end;
end;
readln;
until s=7;
end.
exucuter ce prg pour resoudre l'equation x³+2x+1 =0 sachant que cette equation n a pas une solution uniquement
mais le prg realise la avec les méthodes :NEWTON, DECHOTOMIE, LAGRANGE ,BALAYAGE, point fixe,fausse position
j 'espère que vous recherche soit ce sujet
mais le prg realise la avec les méthodes :NEWTON, DECHOTOMIE, LAGRANGE ,BALAYAGE, point fixe,fausse position
j 'espère que vous recherche soit ce sujet
Bonjour hakou28, je crois que tu postais ce programme pour aider dino (merci pour lui), cependant il m'a semblé bon d'y apporter quelques modifications...
J'ai principalement aérer le code pour bien voir les structures, et après je me suis apercu de nombreuses répétitions dans le code (surtout dans la partie affichage de ton programme principal) j'ai donc mis ensemble ce qui pouvait l'être pour finalement réussir à enlever plus de 100 lignes de code inutile !
Après j'ai apporté quelques améliorations ici ou là, notamment dans l'utilisation des variables globales qu'il faut à tout prix éviter...
Et puis tant que j'y étais j'ai aussi corriger les fautes de français et en particulier lors de l'utilisation du vocabulaire mathématiques.
Par contre je n'ai pas vérifié le cœur du programme (les calculs) j'ai considéré que c'était juste, enfin bref, voici ce que ça donne...
J'ai principalement aérer le code pour bien voir les structures, et après je me suis apercu de nombreuses répétitions dans le code (surtout dans la partie affichage de ton programme principal) j'ai donc mis ensemble ce qui pouvait l'être pour finalement réussir à enlever plus de 100 lignes de code inutile !
Après j'ai apporté quelques améliorations ici ou là, notamment dans l'utilisation des variables globales qu'il faut à tout prix éviter...
Et puis tant que j'y étais j'ai aussi corriger les fautes de français et en particulier lors de l'utilisation du vocabulaire mathématiques.
Par contre je n'ai pas vérifié le cœur du programme (les calculs) j'ai considéré que c'était juste, enfin bref, voici ce que ça donne...
program ziouche_interface; uses crt; function f(x:real):real; begin f:=(sqr(x)+2)*x+1; end; function newt(x:real):real; begin newt:=(2*sqr(x)*x-1)/(3*sqr(x)+2); end; function lag(x:real):real; begin lag:=(-sqr(x)+x-1)/(sqr(x)-x+3); end; function pf(x:real):real; begin pf:=(-sqr(x)*x-1)/2; end; procedure entree(var xmin,xmax,seuil:real); begin textcolor(14); gotoxy(1,10); write('Donnez une valeur < -1 pour xmin : '); readln(xmin); write('Donnez une valeur > 0 pour xmax : '); readln(xmax); write('Donnez une valeur pour le seuil : '); readln(seuil); End; procedure baly(a,xmax,seuil:real); var y1,y2,xsuit:real; begin while a<xmax do begin y1:=f(a); xsuit:=a+seuil; y2:=f(xsuit); if (y1*y2)<0 then writeln('La solution reelle est dans l''intervalle [',a:0:5,',',xsuit:0:5,']'); a:=a+Seuil; end; end; procedure dicho(a,b,seuil:real); var mil:real; begin writeln ('La solution reelle est dans l''intervalle '); writeln('[',a:0:5,',',b:0:5,']'); while abs(b-a)>=seuil do begin mil:=(a+b)/2 ; if (f(a)*f(mil))<=0 then b:=mil else a:=mil; writeln('[',a:0:5,',',b:0:5,']'); end; end; procedure Newton(x1,seuil:real); var x0,y:real; begin x0:=x1; while abs(x0-newt(x0))>=seuil do begin y:=newt(x0); x0:=y; end; writeln('La solution reelle est environ ',x0:0:9); end; procedure Lagrange(x1,seuil:real); var x0,y:real; begin x0:=x1; while abs(x0-lag(x0))>=seuil do begin y:=lag(x0); x0:=y; end; writeln('La solution reelle est environ ',x0:0:9); end; procedure Pointfixe(x1,seuil:real); var x0,y:real; begin x0:=x1; while abs(x0-pf(x0))>=seuil do begin y:=pf(x0); x0:=y; end; writeln('La solution reelle est environ ',x0:0:9); End; procedure fausep(a,b,seuil:real); var mil:real; begin writeln('La solution reelle est dans l intervalle '); writeln('[',a:0:5,',',b:0:5,']'); while abs(b-a)>=seuil do begin mil:=a-((f(a)/(f(b)-f(a)))*(b-a)) ; if (f(a)*f(mil))<=0 then b:=mil else a:=mil; writeln('[',a:0:5,',',b:0:5,']'); end; end; procedure Menu; begin clrscr; textcolor(10); gotoxy(27,2); writeln('ZIOUCHE Abdelhak D0307010') ; textcolor(30); gotoxy(22,4); writeln('Le mini projet d''Analyse Numerique '); textcolor(10); gotoxy(12,6); writeln('Recherche de la solution reelle de l''equation xü+2x+1=0'); textcolor(9); gotoxy(18,8); writeln('*****************************************'); textcolor(2); gotoxy(20,9); writeln('Choisissez comment faire le calcul'); textcolor(1); gotoxy(20,11); writeln('-1- par balayage'); textcolor(8); gotoxy(20,12); writeln('-2- par dichotomie'); textcolor(3); gotoxy(20,13); writeln('-3- par la methode de Newton'); textcolor(4); gotoxy(20,14); writeln('-4- par la methode du point fixe'); textcolor(5); gotoxy(20,15); writeln('-5- par la methode de fausse position'); textcolor(6); gotoxy(20,16); writeln('-6- par la methode de Lagrange'); textcolor(7); gotoxy(20,17); writeln('-7- sortir'); textcolor(9); gotoxy(18,18); writeln('*****************************************'); textcolor(15); end; procedure EnTete; begin clrscr; textcolor(26); gotoxy(27,4); writeln('ZIOUCHE Abdelhak D0307010') ; textcolor(14); gotoxy(22,6); writeln('Le mini projet d''Analyse Numerique '); textcolor(26); gotoxy(15,8); writeln('Recherche de la solution reelle de l''equation xü+2x+1=0'); end; var s:integer; xmin,xmax,seuil:real; begin repeat Menu; readln(s); EnTete; entree(xmin,xmax,seuil); writeln; case s of 1:baly(xmin,xmax,seuil); 2:dicho(xmin,xmax,seuil); 3:newton(xmin,seuil); 4:pointfixe(xmin,seuil); 5:Fausep(xmin,xmax,seuil); 6:Lagrange(xmin,seuil); end; textcolor(4); writeln; writeln('Veuillez taper sur la touche Entree pour choisir une autre methode'); readln; until s=7; end.
En fait ce n'est pas sqrt(x) (la racine carré) mais sqr(x) (le carré de x)
Donc sqr(x)*x+2x+1=x²*x+2x+1=x³+2x+1
Mais le calcul de sqr(x) est plus facile (et plus rapide) à calculer que x*x, alors comme c'est une opération que tu fais souvent, j'ai optimisé ce petit calcul, mais en fait c'est le même qu'avant
Donc sqr(x)*x+2x+1=x²*x+2x+1=x³+2x+1
Mais le calcul de sqr(x) est plus facile (et plus rapide) à calculer que x*x, alors comme c'est une opération que tu fais souvent, j'ai optimisé ce petit calcul, mais en fait c'est le même qu'avant
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question