home *** CD-ROM | disk | FTP | other *** search
- /*********************************************************************
- * CH06_08.C Comparaison de fonctions rΘcurrentes *
- * et non rΘcurrentes *
- *********************************************************************/
-
- #include<stdio.h>
- #include<math.h>
-
- int LitInt( void);
- void LitDouble( double*);
- void ArcTangente1( int, double, double*);
- double ArcTangente2( int, double);
-
- main( void)
- {
- int n;
- double x, arctg1, arctg2;
-
- printf(" *** Calcul de l'arc dont la tangente est x ***\n");
-
- do
- {
- printf("\n Combien de termes voulez vous calculer: n= ");
- n= LitInt();
- }
- while( n<= 0);
-
- printf("\n Entrez x: ");
- LitDouble( &x);
-
- ArcTangente1( n, x, &arctg1);
- arctg2= ArcTangente2( n, x);
-
- printf("\n Avec %d termes, Arc tg1 %lf= %lf\n\t\t"
- " Arc tg2 %lf= %lf",
- n, x, arctg1, x, arctg2 );
- }
-
- void ArcTangente1( int q, double v, double *arctg)
- {
- int i;
- double a= 0;
-
- for( i= 0; i<= q; i++)
- {
- a+= ( pow( -1, i)* pow( v, 2* i+ 1)/ ( 2* i+ 1));
- }
- *arctg= a;
- }
-
- double ArcTangente2( int p, double u)
- {
- if( p< 0)
- return 0;
- else
- return( pow( -1, p)* pow( u, 2* p+ 1)/ ( 2* p+ 1)
- + ArcTangente2( p- 1, u) );
- }
-
- int LitInt( void)
- {
- int entier;
- while( scanf("%d", &entier)!= 1)
- while( getchar() != '\n');
- while( getchar() != '\n');
- return ( entier);
- }
-
- void LitDouble( double *reel)
- {
- while( scanf("%lf", reel)!= 1)
- while( getchar() != '\n');
- while( getchar() != '\n');
- }
-