Inscription / Connexion Nouveau Sujet
Niveau première
Partager :

Algorithme

Posté par
a95
07-01-12 à 13:44

Bonjour a tous,
Voila, j'ai un Dm a faire mais je n'arrive pas a faire fonctionner mes algorithmes... Pourriez-vous m'aider au moin sur un?
Voici le 1er exercice:

I/Soit la fonction f définie sur par f(x)=x3-0.3x2+2.
L'équation admet une solution unique dans . Mais on ne sait pas trouver la valeur exacte de cette solution par le calcul.On cherche donc à encadrer au mieux cette solution.
1)Trouver a l'aide de la calculatrice graphique les 2 entiers consécutifs c et d tels que la solution de l'équation f(x)=0 soit comprise entre c et d.
2) Executer l'algorithme ci-dessous pour N=5 en indiquant soigneusement les calculs de chaque étape (les nombres affichés devront etre des valeurs exactes).

Algorithme:
Variables: i, N, a , b, t, u.
Entrer N
a=-2
b=-1
Pour i allant de 1 a N
m <- a+b/2
t <- f(m)
u <- f(a)
Si t et u sont de même signe alors
a <- m
sinon
b <- m
Finsi
Finpour
Afficher a et b

Merci d'avance de votre aide!

Posté par
Hiphigenie
re : Algorithme 08-01-12 à 08:20

Bonjour a95,

Bizarre... L'algorithme fonctionne.
N'oublie pas de déclarer la variable m (cela manque dans ton exemple)

1   VARIABLES
2     i EST_DU_TYPE NOMBRE
3     N EST_DU_TYPE NOMBRE
4     a EST_DU_TYPE NOMBRE
5     b EST_DU_TYPE NOMBRE
6     t EST_DU_TYPE NOMBRE
7     u EST_DU_TYPE NOMBRE
8     m EST_DU_TYPE NOMBRE
9   DEBUT_ALGORITHME
10    LIRE N
11    a PREND_LA_VALEUR -2
12    b PREND_LA_VALEUR -1
13    POUR i ALLANT_DE 1 A N
14      DEBUT_POUR
15      AFFICHER "i = "
16      AFFICHER i
17      m PREND_LA_VALEUR (a+b)/2
18      AFFICHER "m = "
19      AFFICHER m
20      t PREND_LA_VALEUR F1(m)
21      AFFICHER "t = "
22      AFFICHER t
23      u PREND_LA_VALEUR F1(a)
24      AFFICHER "u = "
25      AFFICHER u
26      SI (t*u>0) ALORS
27        DEBUT_SI
28        a PREND_LA_VALEUR m
29        AFFICHER "a = "
30        AFFICHER a
31        AFFICHER "b = "
32        AFFICHER b
33        FIN_SI
34        SINON
35          DEBUT_SINON
36          b PREND_LA_VALEUR m
37          AFFICHER "b = "

Posté par
Hiphigenie
re : Algorithme 08-01-12 à 08:26

***Algorithme lancé***
i = 1
m = -1.5
t = -2.05
u = -7.2
a = -1.5
b = -1


i = 2
m = -1.25
t = -0.421875
u = -2.05
a = -1.25
b = -1


i = 3
m = -1.125
t = 0,19648437
u = -0.421875
b = -1.125
i = 4


m = -1.1875
t = -0.097607422
u = -0.421875
a = -1.1875
b = -1.125


i = 5
m = -1.15625
t = 0.053118896
u = -0.097607422
b = -1.15625
a = -1.1875
b = -1.15625
***Algorithme terminé***

Posté par
Hiphigenie
re : Algorithme 08-01-12 à 08:45

Je m'aperçois que l'algorithme n'a pas été complètement copié...
Le revoici complété :

1   VARIABLES
2     i EST_DU_TYPE NOMBRE
3     N EST_DU_TYPE NOMBRE
4     a EST_DU_TYPE NOMBRE
5     b EST_DU_TYPE NOMBRE
6     t EST_DU_TYPE NOMBRE
7     u EST_DU_TYPE NOMBRE
8     m EST_DU_TYPE NOMBRE
9   DEBUT_ALGORITHME
10    LIRE N
11    a PREND_LA_VALEUR -2
12    b PREND_LA_VALEUR -1
13    POUR i ALLANT_DE 1 A N
14      DEBUT_POUR
15      AFFICHER "i = "
16      AFFICHER i
17      m PREND_LA_VALEUR (a+b)/2
18      AFFICHER "m = "
19      AFFICHER m
20      t PREND_LA_VALEUR F1(m)
21      AFFICHER "t = "
22      AFFICHER t
23      u PREND_LA_VALEUR F1(a)
24      AFFICHER "u = "
25      AFFICHER u
26      SI (t*u>0) ALORS
27        DEBUT_SI
28        a PREND_LA_VALEUR m
29        AFFICHER "a = "
30        AFFICHER a
31        AFFICHER "b = "
32        AFFICHER b
33        FIN_SI
34        SINON
35          DEBUT_SINON
36          b PREND_LA_VALEUR m
37          AFFICHER "a = "
38          AFFICHER a
39          AFFICHER "b = "
40          AFFICHER b
41          FIN_SINON
42      FIN_POUR
43    AFFICHER "a = "
44    AFFICHER a
45    AFFICHER "b = "
46    AFFICHER b
47  FIN_ALGORITHME

***Algorithme lancé***
i = 1
m = -1.5
t = -2.05
u = -7.2
a = -1.5
b = -1

i = 2
m = -1.25
t = -0.421875
u = -2.05
a = -1.25
b = -1

i = 3
m = -1.125
t = 0,19648437
u = -0.421875
a = -1.25
b = -1.125

i = 4
m = -1.1875
t = -0.097607422
u = -0.421875
a = -1.1875
b = -1.125

i = 5
m = -1.15625
t = 0.053118896
u = -0.097607422
a = -1.1875
b = -1.15625

a = -1.1875
b = -1.15625
***Algorithme terminé***

Posté par
a95
re : Algorithme 09-01-12 à 18:18

Merci pour ton aide Hiphigenie, j'ai trouvé mon erreur.

Posté par
Hiphigenie
re : Algorithme 09-01-12 à 18:30

Parfait alors !

Posté par
a95
re : Algorithme 09-01-12 à 18:46

Mais j'ai une question, comment trouve tu a=1,1875 quand i=4?

Posté par
a95
re : Algorithme 09-01-12 à 18:49

Ah non...je n'ai rien dit! Escuse moi.

Posté par
Hiphigenie
re : Algorithme 09-01-12 à 19:29

Ce n'est pas moi qui l'ai trouvé... C'est Algobox



Vous devez être membre accéder à ce service...

Pas encore inscrit ?

1 compte par personne, multi-compte interdit !

Ou identifiez-vous :


Rester sur la page

Inscription gratuite

Fiches en rapport

parmi 1675 fiches de maths

Désolé, votre version d'Internet Explorer est plus que périmée ! Merci de le mettre à jour ou de télécharger Firefox ou Google Chrome pour utiliser le site. Votre ordinateur vous remerciera !