Bonjour,

J'ai un problème avec ce code car j'ai PEUT ETRE fait des erreurs pour calculer les polynômes et les encoder

Est ce que quelqu'un peut m'aider pour encoder les polynômes et les calculer car le reste est PEUT ETRE juste pour la recherche dichotomique

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main()
{
    float a,b,c,fa,fb,fc,precision;
    float vec[50];
    int cpt=0;
    int i,degre,nbel;
    /**************nombre de case utiliser*************/
    printf("Entrez Degre de l'equation :  ");
    fflush(stdin);
    scanf("%d",&nbel);
    /************precision************/
    printf("Entrez la precision :  ");
    fflush(stdin);
    scanf("%f",&precision);
   // precision=pow(10,-2);
   // printf("\n\nprec = %.8f",precision);
 
    /*************/
    i=nbel;
    while(i>0)
    {
        printf("\nEncode l'element de degre %d :",i);
        fflush(stdin);
        scanf("%f",&vec[i]);
        i--;
 
    }
    printf("Entrez valeur du terme independant : ");
    fflush(stdin);
    scanf("%f",&vec[0]);
 
    printf("\nINTERVALLE\n");
    printf("Entrez a : ");
    fflush(stdin);
    scanf("%f",&a);
    printf("Entrez b : ");
    fflush(stdin);
    scanf("%f",&b);
 
 
 
 
 
   /*********EQUATION*************/
    degre=nbel;
    i=nbel;
  while(i>0)
    {
        fa+=vec[degre]*pow(a,degre);
        degre--;
        i--;
    }fa=fa+vec[0];
     degre=nbel;
    i=nbel;
     while(i>0)
    {
        fb+=vec[degre]*pow(b,degre);
        degre--;
        i--;
    } fb=fb+vec[0];
 
   printf("FA:%.8f FB:%.8f",fa,fb);
 
   if((fa*fb)>0)
   {
       printf("\npas de racine");
   }
   else
   {
       if(fa==0)
       {
 
           printf("m=a");
       }
       else
       {
           if(fb==0)
           {
               printf("m=b");
           }
           else
           {
 
               do
               {
 
 
            cpt++;
            c = (a+b)/2;// c = cordesp11
    degre=nbel;
    i=nbel;
     while(i>0)
    {
        fc+=vec[degre]*pow(c,degre);
        degre--;
        i--;
    }
    fc=fc+vec[0];
 
  /* degre=nbel;
    i=nbel;
  while(i>0)
    {
        fa+=vec[degre]*pow(a,degre);
        degre--;
        i--;
    }fa=fa+vec[0];
     degre=nbel;
    i=nbel;
     while(i>0)
    {
        fb+=vec[degre]*pow(b,degre);
        degre--;
        i--;
    } fb=fb+vec[0];*/
 
 
    if(fc==0.0)
        printf("la racine est %f",c);
            //ap = a;
            //bp = b;
            if(fc!=0.0)
            {
                if ((fc*fa)<0.0)
                {
                    b = c;
                }
                else
                {
                    a = c;
                }
            }
             printf("Iteratiion %d : c=%f , fc=%f\nfa = %f\n fb = %f\nfabs(b-a)=%f A : %f \n B = %f\n\n",cpt,c,fc,fa,fb,b-a,a,b);
        }
        while(fabs(b-a)>=precision && fc!=0);
        printf("Iteration num.%d ==> racine : x=%f\n\n",cpt,c);
    }
 
 
 }
}return 0;
}