25.06.2013 Views

Cours et activités en arithmétique pour les classes ... - Robert Rolland

Cours et activités en arithmétique pour les classes ... - Robert Rolland

Cours et activités en arithmétique pour les classes ... - Robert Rolland

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Activités 43<br />

a = 2 6 + 23, 23 = 2 4 + 7, 7 = 2 2 + 3, 3 = 2 + 1<br />

Donc<br />

a = 1 × 2 6 + 0 × 2 5 + 1 × 2 4 + 0 × 2 3 + 1 × 2 2 + 1 × 2 + 1 = (1010111)2.<br />

Utilisation de la base 2 <strong>pour</strong> accélérer le calcul de x n .<br />

En calculant directem<strong>en</strong>t x.x · · · .x on fait n−1 multiplications. Si on décompose<br />

n <strong>en</strong> base 2 on obti<strong>en</strong>t<br />

Alors<br />

n = ak2 k + · · · + a12 + a0.<br />

x n = x ak2 k +···+a12+a0 = x a0 × (x 2 ) a1 × · · · × ((x 2 k−1<br />

) 2 ) ak .<br />

Il y a donc au maximum k − 1 carrés à effectuer de proche <strong>en</strong> proche <strong>et</strong> au<br />

maximum k − 1 autres produits, donc au plus 2(k − 1) multiplications.<br />

Par exemple si n = 15 alors on calcule x 2 puis x 4 = (x 2 ) 2 puis x 8 = (x 4 ) 2<br />

<strong>et</strong> <strong>en</strong>fin x 15 = x × x 2 × x 4 × x 8 , soit 6 multiplications. Remarquons qu’une<br />

décomposition astucieuse de 15 <strong>en</strong> 6 + 9 perm<strong>et</strong> de ne faire que 5 multiplications.<br />

Passage d’une écriture binaire à une écriture décimale<br />

Si n = ak2 k +· · ·+a0, il suffit de calculer c<strong>et</strong>te somme de manière ”habituelle”<br />

<strong>pour</strong> avoir le développem<strong>en</strong>t décimal. Ce qui nous perm<strong>et</strong> d’avoir le résultat,<br />

c’est bi<strong>en</strong> sûr qu’on utilise <strong>les</strong> notations <strong>et</strong> <strong>les</strong> tab<strong>les</strong> d’opérations du calcul<br />

décimal.<br />

Le calcul peut être fait de manière astucieuse (surtout si ce calcul doit être<br />

programmé sur une machine) <strong>en</strong> utilisant l’algorithme de Hörner proposé,<br />

qui consiste à écrire le calcul sous la forme<br />

n = (· · · ((an × 2 + an−1) × 2 + an−2) · · ·) × 2 + a0.<br />

Par exemple si n = (10011)2 alors on calcule<br />

n = ((((1 × 2) + 0) × 2 + 0) × 2 + 1) × 2 + 1,<br />

<strong>et</strong> comme on calcule <strong>en</strong> base dix, on obti<strong>en</strong>t le résultat 19 <strong>en</strong> base dix. Quand<br />

on calcule ”à la main” sur des p<strong>et</strong>its nombres, il est plus facile d’additionner<br />

directem<strong>en</strong>t <strong>les</strong> puissances de 2. Ainsi, dans notre exemple, n = 2 4 + 2 + 1 =<br />

19.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!