Section courante

A propos

Section administrative du site

LOG10

Logarithme en base 10
MySQL  

Syntaxe

Log10(Nombre)

Paramètres

Nom Description
Nombre Ce paramètre permet d'indiquer l'expression contenant le nombre à traiter

Description

Cette fonction retourne le logarithme de la base 10.

Algorithme

MODULE SQRT(X)
   SI X = 0.0 ALORS
      RETOURNE 0.0
   SINON
      M ← 1.0
      XNX
      BOUCLE FAIRE TANT QUE XN >= 2.0
         XN ← 0.25 x XN
         M ← 2.0 x M
      FIN BOUCLE FAIRE TANT QUE
      BOUCLE FAIRE TANT QUE XN < 0.5
         XN ← 4.0 x XN
         M ← 0.5 x M
      FIN BOUCLE FAIRE TANT QUE
      AXN
      B ← 1.0 - XN
      BOUCLE REPETER
         AA x (1.0 + 0.5 x B)
         B ← 0.25 x (3.0 + B) x B x B
      FIN BOUCLE JUSQU'A B ← 1.0E - 15
      RETOURNE A x M
   FIN SI

MODULE LOG(x)
   negatif ← faux
   fois ← 1
   ajout ← 0
   SI x <= 0.0 ALORS
      RETOURNE 0
   FIN SI
   SI x < 1.0 ALORS
      negatif ← vrai
      x ← 1.0 / x
   FIN SI
   BOUCLE FAIRE TANT QUE x >= 10.0
      xx / 10.0
      ajoutajout + 2.302585092994046
   FIN BOUCLE FAIRE TANT QUE
   BOUCLE FAIRE TANT QUE x >= 1.1
      x ← SQRT(x)
      foisfois x 2
   FIN BOUCLE FAIRE TANT QUE
   xx - 1
   savxx
   i ← 2
   xpx x x
   quotient ← (xp / i)
   dlx - quotient
   BOUCLE FAIRE TANT QUE 1.0E-15 ← quotient
      ii + 1
      xpxp x x
      dldl + (xp / i)
      ii + 1
      xpxp x x
      quotient ← (xp / i)
      dldl - quotient
   FIN BOUCLE FAIRE TANT QUE
   dldl x fois
   dldl + ajout
   SI negatif ALORS
      dl ← -dl
   FIN SI
   RETOURNE dl

MODULE LOG10(DansNombre)
   RETOURNE LOG(DansNombre) / 2,3025850930

Exemple

Voici un exemple permet d'afficher les logarithmes 10 inférieurs à 2 :

  1. DROP PROCEDURE IF EXISTS WHILELOG10;
  2. CREATE PROCEDURE WHILELOG10()
  3. BEGIN
  4. DECLARE R DOUBLE  DEFAULT 0.0;
  5. WHILE R < 2 DO
  6. SELECT CONCAT("Log10(",R,")=",log10(R));
  7.         SET R = R + 0.1;
  8. END WHILE;
  9. END;
  10.  
  11. CALL WHILELOG10();

on obtiendra le résultat suivant :

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| NULL |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.1)=-1 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.2)=-0.698970004336019 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.3)=-0.522878745280338 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.4)=-0.397940008672038 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.5)=-0.301029995663981 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.6)=-0.221848749616356 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.7)=-0.154901959985743 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.8)=-0.0969100130080564 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(0.9)=-0.0457574905606752 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1)=-4.82163733276644e-017 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.1)=0.041392685158225 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.2)=0.0791812460476248 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.3)=0.113943352306837 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.4)=0.146128035678238 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.5)=0.176091259055681 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.6)=0.204119982655925 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.7)=0.230448921378274 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.8)=0.255272505103306 |
+----------------------------------+

+----------------------------------+
| CONCAT("Log10(",R,")=",log10(R)) |
+----------------------------------+
| Log10(1.9)=0.278753600952829 |
+----------------------------------+

Voir également

Article - Les géants de l'informatique - Oracle

Références

MySQL - Référence, Edition Micro Application, Nicolas Rivereau, Antoine Pichot, 2002, ISBN: 2-7429-2560-0, page 927.
MySQL: The definitive guide to using, programming, and administering MySQL 4 databases - Second Edition, Paul Dubois, 2003, ISBN: 0-7357-1212-3, page 806

Dernière mise à jour : Mercredi, le 29 avril 2015