Aller au contenu

Mathc initiation/a383

Un livre de Wikilivres.


Sommaire


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

c00d.c
/* --------------------------------- */
/* save as c00d.c                    */
/* --------------------------------- */
#include "x_afile.h"
#include      "fd.h"
/* --------------------------------- */
#define FIRST_TERM_VALUE  3.
#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 = 3 

 and a_k+1 = f(a_k), where 


 f : x-> x-tan(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   +3.0000000
  2   +3.1425465
  3   +3.1415927
  4   +3.1415927
  5   +3.1415927
 Press return to continue.
Remarque : Pi = 3.1415926
           5   +3.1415927