Aller au contenu

Mathc initiation/a375

Un livre de Wikilivres.


Sommaire


Installer et compiler ces fichiers dans votre répertoire de travail.

c00b.c
/* --------------------------------- */
/* save as c00b.c                    */
/* --------------------------------- */
#include "x_afile.h"
#include      "fb.h"
/* --------------------------------- */
#define FIRST_TERM_VALUE  1.
#define      SECOND_TERM  2
#define        FIVE_TERM  5
#define      TWENTY_TERM 20
/* --------------------------------- */
int main(void)
{
int      n;
double a_n;

 clrscrn();
 
 printf(" If a sequence is defined recursively by a_1 = %.0f \n\n",
                                                      FIRST_TERM_VALUE);
 printf(" and a_k+1 = f(a_k), where \n\n\n");
 printf(" f : x-> %s\n\n\n", feq);
 printf(" a) Find the first five terms.\n\n");
 printf(" b) What happens to the terms of the sequence as k increases.\n\n");
 stop();

 clrscrn();
 printf(" a) The first five terms are :\n\n");

 printf("  1   %+6.7f\n",FIRST_TERM_VALUE);
 for(a_n = FIRST_TERM_VALUE, 
       n = SECOND_TERM;      n <= FIVE_TERM; ++n)
    {
     a_n = f(a_n);
     printf(" %2d   %+6.7f\n",n,a_n);
    }
 stop();

 clrscrn();
 printf(" b) The sequence appears to converge to :\n\n");

 printf("  1   %+6.7f\n",FIRST_TERM_VALUE);
 for(a_n = FIRST_TERM_VALUE, 
       n = SECOND_TERM;        n <= TWENTY_TERM; ++n)
    {
     a_n = f(a_n);
     printf(" %2d   %+6.12f\n",n,a_n);
    }
    
 stop();

 return 0;
}
/* --------------------------------- */
/* --------------------------------- */


Exemple de sortie écran :

 If a sequence is defined recursively by a_1 = 1 

 and a_k+1 = f(a_k), where 


 f : x-> cos(x)


 a) Find the first five terms.

 b) What happens to the terms of the sequence as k increases.

 Press return to continue.


Exemple de sortie écran :

 a) The first five terms are :

  1   +1.0000000
  2   +0.5403023
  3   +0.8575532
  4   +0.6542898
  5   +0.7934804
 Press return to continue.