SQRT |
Racine carré |
|---|---|
Perl |
POSIX |
Syntaxe
| sub POSIX::sqrt($expression); |
Paramètres
| Nom | Description |
|---|---|
| $expression | Ce paramètre permet d'indiquer une expression représentant un nombre à traiter |
Description
Cette fonction retourne la racine carrée d'un nombre.
Algorithme
|
MODULE POSIX::SQRT(X) SI X = 0.0 ALORS RETOURNE 0.0 SINON M ← 1.0 XN ← X 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 A ← XN B ← 1.0 - XN BOUCLE REPETER A ← A 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 |
Voir également
Langage de programmation - Perl - Référence de procédures et fonctions - sqrt
Langage de programmation - Fonction C pour Linux - sqrt
Dernière mise à jour : Dimanche, le 18 octobre 2015