Mathc initiation/c81 d
Installer et compiler ces fichiers dans votre répertoire de travail.
c0d.c |
---|
/* --------------------------------- */
/* save as c0d.c */
/* --------------------------------- */
#include "x_a.h"
#include "fd.h"
/* --------------------------------- */
int main(void)
{
double x = 3.;
double base = 5.;
clrscrn();
printf(" The logarithm of x in base a is : \n\n"
" log_a(x) = ln(x)/ln(a) \n\n\n"
" in C you must write \n\n"
" ln(x)/ln(a) as log(x)/log(a) \n\n\n\n");
printf(" The logarithm of %.2f in base %.2f is : %f\n\n\n",
x ,base, log_a(x, base));
/* with mathematica you can try log5(3)
*
* log5(3) = 0.682606... */
stop();
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
Vérifions par le calcul :
The logarithm of x in base a is :
log_a(x) = ln(x)/ln(a)
in C you must write
ln(x)/ln(a) as log(x)/log(a)
The logarithm of 3.00 in base 5.00 is : 0.682606
Press return to continue.
Vérifions les égalités :
Posons :
log_a(x) = X (1)
Introduisons a**() :
log_a(x) X
a = a
X
x = a
Introduisons ln() :
X
ln(x) = ln(a)
ln(x) = X ln(a)
ln(x)
----- = X (2)
ln(a)
Or nous avons (1) et (2)
log_a(x) = X (1)
Donc
(1) (2)
ln(x)
log_a(x) = -----
ln(a)