Skip to content

Commit d6b8dd3

Browse files
authoredOct 5, 2020
Chore(math-translation-FR-fr): a pack of translations for the math section (trekhleb#558)
* chore(factorial): translation fr-FR * feat(math-translation-fr-FR): fast powering * feat(math-translation-fr-FR): fibonacci numbers * chore(math-translation-fr-FR): bits * chore(math-translation-fr-FR): complex number * chore(math-translation-fr-FR): euclidean algorithm * chore(math-translation-fr-FR): fibonacci number * chore(math-translation-fr-FR): fourier transform * chore(math-translation-fr-FR): fourier transform WIP * chore(math-translation-fr-FR): fourier transform done * chore(math-translation-fr-FR): fourier transform in menu
1 parent 07bc4a4 commit d6b8dd3

File tree

15 files changed

+1201
-329
lines changed

15 files changed

+1201
-329
lines changed
 

‎README.fr-FR.md

+191-185
Large diffs are not rendered by default.
+295
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
# Manipulation de bits
2+
3+
_Read this in other languages:_
4+
[english](README.md).
5+
6+
#### Vérifier un bit (_get_)
7+
8+
Cette méthode décale le bit correspondant (_bit shifting_) à la position zéro.
9+
Ensuite, nous exécutons l'opération `AND` avec un masque comme `0001`.
10+
Cela efface tous les bits du nombre original sauf le correspondant.
11+
Si le bit pertinent est `1`, le résultat est `1`, sinon le résultat est `0`.
12+
13+
> Voir [getBit.js](getBit.js) pour plus de détails.
14+
15+
#### Mettre un bit à 1(_set_)
16+
17+
Cette méthode met un bit à `1` en fonction d'un rang (`bitPosition`),
18+
créant ainsi une valeur qui ressemble à `00100`.
19+
Ensuite, nous effectuons l'opération `OU` qui met un bit spécifique
20+
en `1` sans affecter les autres bits du nombre.
21+
22+
> Voir [setBit.js](setBit.js) pour plus de détails.
23+
24+
#### Mettre un bit à 0 (_clear_)
25+
26+
Cette méthode met un bit à `1` en fonction d'un rang (`bitPosition`),
27+
créant ainsi une valeur qui ressemble à `00100`.
28+
Puis on inverse ce masque de bits pour obtenir un nombre ressemblant à `11011`.
29+
Enfin, l'opération `AND` est appliquée au nombre et au masque.
30+
Cette opération annule le bit.
31+
32+
> Voir [clearBit.js](clearBit.js) pour plus de détails.
33+
34+
#### Mettre à jour un Bit (_update_)
35+
36+
Cette méthode est une combinaison de l'"annulation de bit"
37+
et du "forçage de bit".
38+
39+
> Voir [updateBit.js](updateBit.js) pour plus de détails.
40+
41+
#### Vérifier si un nombre est pair (_isEven_)
42+
43+
Cette méthode détermine si un nombre donné est pair.
44+
Elle s'appuie sur le fait que les nombres impairs ont leur dernier
45+
bit droit à `1`.
46+
47+
```text
48+
Nombre: 5 = 0b0101
49+
isEven: false
50+
51+
Nombre: 4 = 0b0100
52+
isEven: true
53+
```
54+
55+
> Voir [isEven.js](isEven.js) pour plus de détails.
56+
57+
#### Vérifier si un nombre est positif (_isPositive_)
58+
59+
Cette méthode détermine un le nombre donné est positif.
60+
Elle s'appuie sur le fait que tous les nombres positifs
61+
ont leur bit le plus à gauche à `0`.
62+
Cependant, si le nombre fourni est zéro
63+
ou zéro négatif, il doit toujours renvoyer `false`.
64+
65+
```text
66+
Nombre: 1 = 0b0001
67+
isPositive: true
68+
69+
Nombre: -1 = -0b0001
70+
isPositive: false
71+
```
72+
73+
> Voir [isPositive.js](isPositive.js) pour plus de détails.
74+
75+
#### Multiplier par deux
76+
77+
Cette méthode décale un nombre donné d'un bit vers la gauche.
78+
Ainsi, toutes les composantes du nombre binaire (en puissances de deux) sont
79+
multipliées par deux et donc le nombre lui-même est
80+
multiplié par deux.
81+
82+
```
83+
Avant le décalage
84+
Nombre: 0b0101 = 5
85+
Puissances de deux: 0 + 2^2 + 0 + 2^0
86+
87+
Après le décalage
88+
Nombre: 0b1010 = 10
89+
Puissances de deux: 2^3 + 0 + 2^1 + 0
90+
```
91+
92+
> Voir [multiplyByTwo.js](multiplyByTwo.js) pour plus de détails.
93+
94+
#### Diviser par deux
95+
96+
Cette méthode décale un nombre donné d'un bit vers la droite.
97+
Ainsi, toutes les composantes du nombre binaire (en puissances de deux) sont
98+
divisées par deux et donc le nombre lui-même est
99+
divisé par deux, sans reste.
100+
101+
```
102+
Avant le décalage
103+
Nombre: 0b0101 = 5
104+
Puissances de deux: 0 + 2^2 + 0 + 2^0
105+
106+
Après le décalage
107+
Nombre: 0b0010 = 2
108+
Puissances de deux: 0 + 0 + 2^1 + 0
109+
```
110+
111+
> Voir [divideByTwo.js](divideByTwo.js) pour plus de détails.
112+
113+
#### Inverser le signe (_Switch Sign_)
114+
115+
Cette méthode rend positifs les nombres négatifs, et vice-versa.
116+
Pour ce faire, elle s'appuie sur l'approche "Complément à deux",
117+
qui inverse tous les bits du nombre et y ajoute 1.
118+
119+
```
120+
1101 -3
121+
1110 -2
122+
1111 -1
123+
0000 0
124+
0001 1
125+
0010 2
126+
0011 3
127+
```
128+
129+
> Voir [switchSign.js](switchSign.js) pour plus de détails.
130+
131+
#### Multiplier deux nombres signés
132+
133+
Cette méthode multiplie deux nombres entiers signés
134+
à l'aide d'opérateurs bit à bit.
135+
Cette méthode est basée sur les faits suivants:
136+
137+
```text
138+
a * b peut être écrit sous les formes suivantes:
139+
0 si a est zero ou b est zero ou les deux sont zero
140+
2a * (b/2) si b est pair
141+
2a * (b - 1)/2 + a si b est impair et positif
142+
2a * (b + 1)/2 - a si b est impair et negatif
143+
```
144+
145+
L'avantage de cette approche est qu'à chaque étape de la récursion
146+
l'un des opérandes est réduit à la moitié de sa valeur d'origine.
147+
Par conséquent, la complexité d'exécution est `O(log(b))`
148+
`b` est l'opérande qui se réduit de moitié à chaque récursion.
149+
150+
> Voir [multiply.js](multiply.js) pour plus de détails.
151+
152+
#### Multiplier deux nombres positifs
153+
154+
Cette méthode multiplie deux nombres entiers à l'aide d'opérateurs bit à bit.
155+
Cette méthode s'appuie sur le fait que "Chaque nombre peut être lu
156+
comme une somme de puissances de 2".
157+
158+
L'idée principale de la multiplication bit à bit
159+
est que chaque nombre peut être divisé en somme des puissances de deux:
160+
161+
Ainsi
162+
163+
```text
164+
19 = 2^4 + 2^1 + 2^0
165+
```
166+
167+
Donc multiplier `x` par `19` est equivalent à :
168+
169+
```text
170+
x * 19 = x * 2^4 + x * 2^1 + x * 2^0
171+
```
172+
173+
Nous devons maintenant nous rappeler que `x * 2 ^ 4` équivaut
174+
à déplacer`x` vers la gauche par `4` bits (`x << 4`).
175+
176+
> Voir [multiplyUnsigned.js](multiplyUnsigned.js) pour plus de détails.
177+
178+
#### Compter les bits à 1
179+
180+
This method counts the number of set bits in a number using bitwise operators.
181+
The main idea is that we shift the number right by one bit at a time and check
182+
the result of `&` operation that is `1` if bit is set and `0` otherwise.
183+
184+
Cette méthode décompte les bits à `1` d'un nombre
185+
à l'aide d'opérateurs bit à bit.
186+
L'idée principale est de décaler le nombre vers la droite, un bit à la fois,
187+
et de vérifier le résultat de l'opération `&` :
188+
`1` si le bit est défini et `0` dans le cas contraire.
189+
190+
```text
191+
Nombre: 5 = 0b0101
192+
Décompte des bits à 1 = 2
193+
```
194+
195+
> Voir [countSetBits.js](countSetBits.js) pour plus de détails.
196+
197+
#### Compter les bits nécessaire pour remplacer un nombre
198+
199+
This methods outputs the number of bits required to convert one number to another.
200+
This makes use of property that when numbers are `XOR`-ed the result will be number
201+
of different bits.
202+
203+
Cette méthode retourne le nombre de bits requis
204+
pour convertir un nombre en un autre.
205+
Elle repose sur la propriété suivante:
206+
lorsque les nombres sont évalués via `XOR`, le résultat est le nombre
207+
de bits différents entre les deux.
208+
209+
```
210+
5 = 0b0101
211+
1 = 0b0001
212+
Nombre de bits pour le remplacement: 1
213+
```
214+
215+
> Voir [bitsDiff.js](bitsDiff.js) pour plus de détails.
216+
217+
#### Calculer les bits significatifs d'un nombre
218+
219+
Pour connaître les bits significatifs d'un nombre,
220+
on peut décaler `1` d'un bit à gauche plusieurs fois d'affilée
221+
jusqu'à ce que ce nombre soit plus grand que le nombre à comparer.
222+
223+
```
224+
5 = 0b0101
225+
Décompte des bits significatifs: 3
226+
On décale 1 quatre fois pour dépasser 5.
227+
```
228+
229+
> Voir [bitLength.js](bitLength.js) pour plus de détails.
230+
231+
#### Vérifier si un nombre est une puissance de 2
232+
233+
Cette méthode vérifie si un nombre donné est une puissance de deux.
234+
Elle s'appuie sur la propriété suivante.
235+
Disons que `powerNumber` est une puissance de deux (c'est-à-dire 2, 4, 8, 16 etc.).
236+
Si nous faisons l'opération `&` entre `powerNumber` et `powerNumber - 1`,
237+
elle retournera`0` (dans le cas où le nombre est une puissance de deux).
238+
239+
```
240+
Nombre: 4 = 0b0100
241+
Nombre: 3 = (4 - 1) = 0b0011
242+
4 & 3 = 0b0100 & 0b0011 = 0b0000 <-- Égal à zéro, car c'est une puissance de 2.
243+
244+
Nombre: 10 = 0b01010
245+
Nombre: 9 = (10 - 1) = 0b01001
246+
10 & 9 = 0b01010 & 0b01001 = 0b01000 <-- Différent de 0, donc n'est pas une puissance de 2.
247+
```
248+
249+
> Voir [isPowerOfTwo.js](isPowerOfTwo.js) pour plus de détails.
250+
251+
#### Additionneur complet
252+
253+
Cette méthode ajoute deux nombres entiers à l'aide d'opérateurs bit à bit.
254+
255+
Elle implémente un [additionneur](https://fr.wikipedia.org/wiki/Additionneur)
256+
simulant un circuit électronique logique,
257+
pour additionner deux entiers de 32 bits,
258+
sous la forme « complément à deux ».
259+
Elle utilise la logique booléenne pour couvrir tous les cas possibles
260+
d'ajout de deux bits donnés:
261+
avec et sans retenue de l'ajout de l'étape précédente la moins significative.
262+
263+
Légende:
264+
265+
- `A`: Nombre `A`
266+
- `B`: Nombre `B`
267+
- `ai`: ième bit du nombre `A`
268+
- `bi`: ième bit du nombre `B`
269+
- `carryIn`: un bit retenu de la précédente étape la moins significative
270+
- `carryOut`: un bit retenu pour la prochaine étape la plus significative
271+
- `bitSum`: La somme de `ai`, `bi`, et `carryIn`
272+
- `resultBin`: Le résultat complet de l'ajout de l'étape actuelle avec toutes les étapes moins significatives (en binaire)
273+
- `resultDec`: Le résultat complet de l'ajout de l'étape actuelle avec toutes les étapes moins significatives (en decimal)
274+
275+
```
276+
A = 3: 011
277+
B = 6: 110
278+
┌──────┬────┬────┬───────┬────────┬───────┬────────┬─────────┐
279+
│ bit │ ai │ bi │ carryIn │ carryOut │ bitSum │ resultBin │ resultDec │
280+
├──────┼────┼────┼───────┼────────┼───────┼────────┼─────────┤
281+
│ 0 │ 1 │ 0 │ 0 │ 0 │ 1 │ 1 │ 1 │
282+
│ 1 │ 1 │ 1 │ 0 │ 1 │ 0 │ 01 │ 1 │
283+
│ 2 │ 0 │ 1 │ 1 │ 1 │ 0 │ 001 │ 1 │
284+
│ 3 │ 0 │ 0 │ 1 │ 0 │ 1 │ 1001 │ 9 │
285+
└──────┴────┴────┴───────┴────────┴───────┴────────┴─────────┘
286+
```
287+
288+
> Voir [fullAdder.js](fullAdder.js) pour plus de détails.
289+
> Voir [Full Adder on YouTube](https://www.youtube.com/watch?v=wvJc9CZcvBc&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8).
290+
291+
## Références
292+
293+
- [Bit Manipulation on YouTube](https://www.youtube.com/watch?v=NLKQEOgBAnw&t=0s&index=28&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
294+
- [Negative Numbers in binary on YouTube](https://www.youtube.com/watch?v=4qH4unVtJkE&t=0s&index=30&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
295+
- [Bit Hacks on stanford.edu](https://graphics.stanford.edu/~seander/bithacks.html)

‎src/algorithms/math/bits/README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Bit Manipulation
22

3+
_Read this in other languages:_
4+
[français](README.fr-FR.md).
5+
36
#### Get Bit
47

58
This method shifts the relevant bit to the zeroth position.
69
Then we perform `AND` operation with one which has bit
7-
pattern like `0001`. This clears all bits from the original
10+
pattern like `0001`. This clears all bits from the original
811
number except the relevant one. If the relevant bit is one,
912
the result is `1`, otherwise the result is `0`.
1013

@@ -53,7 +56,7 @@ isEven: true
5356
5457
#### isPositive
5558

56-
This method determines if the number is positive. It is based on the fact that all positive
59+
This method determines if the number is positive. It is based on the fact that all positive
5760
numbers have their leftmost bit to be set to `0`. However, if the number provided is zero
5861
or negative zero, it should still return `false`.
5962

@@ -230,12 +233,13 @@ Number: 9 = (10 - 1) = 0b01001
230233

231234
This method adds up two integer numbers using bitwise operators.
232235

233-
It implements [full adder](https://en.wikipedia.org/wiki/Adder_(electronics))
236+
It implements [full adder](<https://en.wikipedia.org/wiki/Adder_(electronics)>)
234237
electronics circuit logic to sum two 32-bit integers in two's complement format.
235238
It's using the boolean logic to cover all possible cases of adding two input bits:
236239
with and without a "carry bit" from adding the previous less-significant stage.
237240

238241
Legend:
242+
239243
- `A`: Number `A`
240244
- `B`: Number `B`
241245
- `ai`: ith bit of number `A`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
# Nombre complexe
2+
3+
_Read this in other languages:_
4+
[english](README.md).
5+
6+
Un **nombre complexe** est un nombre qui peut s'écrire sous la forme
7+
`a + b * i`, tels que `a` et `b` sont des nombres réels,
8+
et `i` est la solution de l'équation `x^2 = −1`.
9+
Du fait qu'aucun _nombre réel_ ne statisfait l'équation,
10+
`i` est appellé _nombre imaginaire_. Étant donné le nombre complexe `a + b * i`,
11+
`a` est appellé _partie réelle_, et `b`, _partie imaginaire_.
12+
13+
![Complex Number](https://www.mathsisfun.com/numbers/images/complex-example.svg)
14+
15+
Un nombre complexe est donc la combinaison
16+
d'un nombre réel et d'un nombre imaginaire :
17+
18+
![Complex Number](https://www.mathsisfun.com/numbers/images/complex-number.svg)
19+
20+
En géométrie, les nombres complexes étendent le concept
21+
de ligne de nombres sur une dimension à un _plan complexe à deux dimensions_
22+
en utilisant l'axe horizontal pour lepartie réelle
23+
et l'axe vertical pour la partie imaginaire. Le nombre complexe `a + b * i`
24+
peut être identifié avec le point `(a, b)` dans le plan complexe.
25+
26+
Un nombre complexe dont la partie réelle est zéro est dit _imaginaire pur_;
27+
les points pour ces nombres se trouvent sur l'axe vertical du plan complexe.
28+
Un nombre complexe dont la partie imaginaire est zéro
29+
peut être considéré comme un _nombre réel_; son point
30+
se trouve sur l'axe horizontal du plan complexe.
31+
32+
| Nombre complexe | Partie réelle | partie imaginaire | |
33+
| :-------------- | :-----------: | :---------------: | ---------------- |
34+
| 3 + 2i | 3 | 2 | |
35+
| 5 | 5 | **0** | Purely Real |
36+
| −6i | **0** | -6 | Purely Imaginary |
37+
38+
A complex number can be visually represented as a pair of numbers `(a, b)` forming
39+
a vector on a diagram called an _Argand diagram_, representing the _complex plane_.
40+
`Re` is the real axis, `Im` is the imaginary axis, and `i` satisfies `i^2 = −1`.
41+
42+
Un nombre complexe peut être représenté visuellement comme une paire de nombres
43+
`(a, b)` formant un vecteur sur un diagramme appelé _diagramme d'Argand_,
44+
représentant le _plan complexe_.
45+
_Re_ est l'axe réel, _Im_ est l'axe imaginaire et `i` satisfait `i^2 = −1`.
46+
47+
![Complex Number](https://upload.wikimedia.org/wikipedia/commons/a/af/Complex_number_illustration.svg)
48+
49+
> Complexe ne veut pas dire compliqué. Cela signifie simplement que
50+
> les deux types de nombres, réels et imaginaires, forment ensemble un complexe
51+
> comme on le dirait d'un complexe de bâtiments (bâtiments réunis).
52+
53+
## Forme polaire
54+
55+
Une manière de définir un point `P` dans le plan complexe, autre que d'utiliser
56+
les coordonnées x et y, consiste à utiliser la distance entre le point `O`, le point
57+
dont les coordonnées sont `(0, 0)` (l'origine), et l'angle sous-tendu
58+
entre l'axe réel positif et le segment de droite `OP` dans le sens antihoraire.
59+
Cette idée conduit à la forme polaire des nombres complexes.
60+
61+
![Polar Form](https://upload.wikimedia.org/wikipedia/commons/7/7a/Complex_number_illustration_modarg.svg)
62+
63+
The _valeur absolue_ (ou module) d'un nombre complexe `z = x + yi` est:
64+
65+
![Radius](https://wikimedia.org/api/rest_v1/media/math/render/svg/b59629c801aa0ddcdf17ee489e028fb9f8d4ea75)
66+
67+
L'argument de `z` (parfois appelé « phase » ou « amplitude ») est l'angle
68+
du rayon `OP` avec l'axe des réels positifs, et s'écrit `arg(z)`. Comme
69+
avec le module, l'argument peut être trouvé à partir de la forme rectangulaire `x + yi`:
70+
71+
![Phase](https://wikimedia.org/api/rest_v1/media/math/render/svg/7cbbdd9bb1dd5df86dd2b820b20f82995023e566)
72+
73+
Ensemble, `r` et`φ` donnent une autre façon de représenter les nombres complexes, la
74+
forme polaire, car la combinaison du module et de l'argument suffit à indiquer la
75+
position d'un point sur le plan. Obtenir les coordonnées du rectangle d'origine
76+
à partir de la forme polaire se fait par la formule appelée forme trigonométrique :
77+
78+
![Polar Form](https://wikimedia.org/api/rest_v1/media/math/render/svg/b03de1e1b7b049880b5e4870b68a57bc180ff6ce)
79+
80+
En utilisant la formule d'Euler, cela peut être écrit comme suit:
81+
82+
![Euler's Form](https://wikimedia.org/api/rest_v1/media/math/render/svg/0a087c772212e7375cb321d83fc1fcc715cd0ed2)
83+
84+
## Opérations de base
85+
86+
### Addition
87+
88+
Pour ajouter deux nombres complexes, nous ajoutons chaque partie séparément :
89+
90+
```text
91+
(a + b * i) + (c + d * i) = (a + c) + (b + d) * i
92+
```
93+
94+
**Exemple**
95+
96+
```text
97+
(3 + 5i) + (4 − 3i) = (3 + 4) + (5 − 3)i = 7 + 2i
98+
```
99+
100+
Dans un plan complexe, l'addition ressemblera à ceci:
101+
102+
![Complex Addition](https://www.mathsisfun.com/algebra/images/complex-plane-vector-add.svg)
103+
104+
### Soustraction
105+
106+
Pour soustraire deux nombres complexes, on soustrait chaque partie séparément :
107+
108+
```text
109+
(a + b * i) - (c + d * i) = (a - c) + (b - d) * i
110+
```
111+
112+
**Exemple**
113+
114+
```text
115+
(3 + 5i) - (4 − 3i) = (3 - 4) + (5 + 3)i = -1 + 8i
116+
```
117+
118+
### Multiplication
119+
120+
Pour multiplier les nombres complexes, chaque partie du premier nombre complexe est multipliée
121+
par chaque partie du deuxième nombre complexe:
122+
123+
On peut utiliser le "FOIL" (parfois traduit PEID en français), acronyme de
124+
**F**irsts (Premiers), **O**uters (Extérieurs), **I**nners (Intérieurs), **L**asts (Derniers)" (
125+
voir [Binomial Multiplication](ttps://www.mathsisfun.com/algebra/polynomials-multiplying.html) pour plus de détails):
126+
127+
![Complex Multiplication](https://www.mathsisfun.com/algebra/images/foil-complex.svg)
128+
129+
- Firsts: `a × c`
130+
- Outers: `a × di`
131+
- Inners: `bi × c`
132+
- Lasts: `bi × di`
133+
134+
En général, cela ressemble à:
135+
136+
```text
137+
(a + bi)(c + di) = ac + adi + bci + bdi^2
138+
```
139+
140+
Mais il existe aussi un moyen plus rapide !
141+
142+
Utiliser cette loi:
143+
144+
```text
145+
(a + bi)(c + di) = (ac − bd) + (ad + bc)i
146+
```
147+
148+
**Exemple**
149+
150+
```text
151+
(3 + 2i)(1 + 7i)
152+
= 3×1 + 3×7i + 2i×1+ 2i×7i
153+
= 3 + 21i + 2i + 14i^2
154+
= 3 + 21i + 2i − 14 (because i^2 = −1)
155+
= −11 + 23i
156+
```
157+
158+
```text
159+
(3 + 2i)(1 + 7i) = (3×1 − 2×7) + (3×7 + 2×1)i = −11 + 23i
160+
```
161+
162+
### Conjugués
163+
164+
En mathématiques, le conjugué d'un nombre complexe z
165+
est le nombre complexe formé de la même partie réelle que z
166+
mais de partie imaginaire opposée.
167+
168+
Un conjugué vois son signe changer au milieu comme suit:
169+
170+
![Complex Conjugate](https://www.mathsisfun.com/numbers/images/complex-conjugate.svg)
171+
172+
Un conjugué est souvent écrit avec un trait suscrit (barre au-dessus):
173+
174+
```text
175+
______
176+
5 − 3i = 5 + 3i
177+
```
178+
179+
Dans un plan complexe, le nombre conjugué sera mirroir par rapport aux axes réels.
180+
181+
![Complex Conjugate](https://upload.wikimedia.org/wikipedia/commons/6/69/Complex_conjugate_picture.svg)
182+
183+
### Division
184+
185+
Le conjugué est utiliser pour aider à la division de nombres complexes
186+
187+
L'astuce est de _multiplier le haut et le bas par le conjugué du bas_.
188+
189+
**Exemple**
190+
191+
```text
192+
2 + 3i
193+
------
194+
4 − 5i
195+
```
196+
197+
Multiplier le haut et le bas par le conjugué de `4 − 5i`:
198+
199+
```text
200+
(2 + 3i) * (4 + 5i) 8 + 10i + 12i + 15i^2
201+
= ------------------- = ----------------------
202+
(4 − 5i) * (4 + 5i) 16 + 20i − 20i − 25i^2
203+
```
204+
205+
Et puisque `i^2 = −1`, il s'ensuit que:
206+
207+
```text
208+
8 + 10i + 12i − 15 −7 + 22i −7 22
209+
= ------------------- = -------- = -- + -- * i
210+
16 + 20i − 20i + 25 41 41 41
211+
212+
```
213+
214+
Il existe cependant un moyen plus direct.
215+
216+
Dans l'exemple précédent, ce qui s'est passé en bas était intéressant:
217+
218+
```text
219+
(4 − 5i)(4 + 5i) = 16 + 20i − 20i − 25i
220+
```
221+
222+
Les termes du milieu `(20i − 20i)` s'annule! Et pusique `i^2 = −1` on retrouve:
223+
224+
```text
225+
(4 − 5i)(4 + 5i) = 4^2 + 5^2
226+
```
227+
228+
Ce qui est vraiment un résultat assez simple. La règle générale est:
229+
230+
```text
231+
(a + bi)(a − bi) = a^2 + b^2
232+
```
233+
234+
## Références
235+
236+
- [Wikipedia](https://fr.wikipedia.org/wiki/Nombre_complexe)
237+
- [Math is Fun](https://www.mathsisfun.com/numbers/complex-numbers.html)

‎src/algorithms/math/complex-number/README.md

+38-35
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,71 @@
11
# Complex Number
22

3-
A **complex number** is a number that can be expressed in the
3+
_Read this in other languages:_
4+
[français](README.fr-FR.md).
5+
6+
A **complex number** is a number that can be expressed in the
47
form `a + b * i`, where `a` and `b` are real numbers, and `i` is a solution of
5-
the equation `x^2 = −1`. Because no *real number* satisfies this
6-
equation, `i` is called an *imaginary number*. For the complex
7-
number `a + b * i`, `a` is called the *real part*, and `b` is called
8-
the *imaginary part*.
8+
the equation `x^2 = −1`. Because no _real number_ satisfies this
9+
equation, `i` is called an _imaginary number_. For the complex
10+
number `a + b * i`, `a` is called the _real part_, and `b` is called
11+
the _imaginary part_.
912

1013
![Complex Number](https://www.mathsisfun.com/numbers/images/complex-example.svg)
1114

1215
A Complex Number is a combination of a Real Number and an Imaginary Number:
1316

1417
![Complex Number](https://www.mathsisfun.com/numbers/images/complex-number.svg)
1518

16-
Geometrically, complex numbers extend the concept of the one-dimensional number
17-
line to the *two-dimensional complex plane* by using the horizontal axis for the
18-
real part and the vertical axis for the imaginary part. The complex
19-
number `a + b * i` can be identified with the point `(a,b)` in the complex plane.
19+
Geometrically, complex numbers extend the concept of the one-dimensional number
20+
line to the _two-dimensional complex plane_ by using the horizontal axis for the
21+
real part and the vertical axis for the imaginary part. The complex
22+
number `a + b * i` can be identified with the point `(a, b)` in the complex plane.
2023

21-
A complex number whose real part is zero is said to be *purely imaginary*; the
24+
A complex number whose real part is zero is said to be _purely imaginary_; the
2225
points for these numbers lie on the vertical axis of the complex plane. A complex
23-
number whose imaginary part is zero can be viewed as a *real number*; its point
26+
number whose imaginary part is zero can be viewed as a _real number_; its point
2427
lies on the horizontal axis of the complex plane.
2528

26-
| Complex Number | Real Part | Imaginary Part | |
27-
| :------------- | :-------: | :------------: | --- |
28-
| 3 + 2i | 3 | 2 | |
29-
| 5 | 5 | **0** | Purely Real |
30-
| −6i | **0** | -6 | Purely Imaginary |
29+
| Complex Number | Real Part | Imaginary Part | |
30+
| :------------- | :-------: | :------------: | ---------------- |
31+
| 3 + 2i | 3 | 2 | |
32+
| 5 | 5 | **0** | Purely Real |
33+
| −6i | **0** | -6 | Purely Imaginary |
3134

32-
A complex number can be visually represented as a pair of numbers `(a,b)` forming
33-
a vector on a diagram called an *Argand diagram*, representing the *complex plane*.
35+
A complex number can be visually represented as a pair of numbers `(a, b)` forming
36+
a vector on a diagram called an _Argand diagram_, representing the _complex plane_.
3437
`Re` is the real axis, `Im` is the imaginary axis, and `i` satisfies `i^2 = −1`.
3538

3639
![Complex Number](https://upload.wikimedia.org/wikipedia/commons/a/af/Complex_number_illustration.svg)
3740

38-
> Complex does not mean complicated. It means the two types of numbers, real and
39-
imaginary, together form a complex, just like a building complex (buildings
40-
joined together).
41+
> Complex does not mean complicated. It means the two types of numbers, real and
42+
> imaginary, together form a complex, just like a building complex (buildings
43+
> joined together).
4144
4245
## Polar Form
4346

44-
An alternative way of defining a point `P` in the complex plane, other than using
47+
An alternative way of defining a point `P` in the complex plane, other than using
4548
the x- and y-coordinates, is to use the distance of the point from `O`, the point
46-
whose coordinates are `(0,0)` (the origin), together with the angle subtended
47-
between the positive real axis and the line segment `OP` in a counterclockwise
49+
whose coordinates are `(0, 0)` (the origin), together with the angle subtended
50+
between the positive real axis and the line segment `OP` in a counterclockwise
4851
direction. This idea leads to the polar form of complex numbers.
4952

5053
![Polar Form](https://upload.wikimedia.org/wikipedia/commons/7/7a/Complex_number_illustration_modarg.svg)
5154

52-
The *absolute value* (or modulus or magnitude) of a complex number `z = x + yi` is:
55+
The _absolute value_ (or modulus or magnitude) of a complex number `z = x + yi` is:
5356

5457
![Radius](https://wikimedia.org/api/rest_v1/media/math/render/svg/b59629c801aa0ddcdf17ee489e028fb9f8d4ea75)
5558

5659
The argument of `z` (in many applications referred to as the "phase") is the angle
57-
of the radius `OP` with the positive real axis, and is written as `arg(z)`. As
60+
of the radius `OP` with the positive real axis, and is written as `arg(z)`. As
5861
with the modulus, the argument can be found from the rectangular form `x+yi`:
5962

6063
![Phase](https://wikimedia.org/api/rest_v1/media/math/render/svg/7cbbdd9bb1dd5df86dd2b820b20f82995023e566)
6164

62-
Together, `r` and `φ` give another way of representing complex numbers, the
63-
polar form, as the combination of modulus and argument fully specify the
64-
position of a point on the plane. Recovering the original rectangular
65-
co-ordinates from the polar form is done by the formula called trigonometric
65+
Together, `r` and `φ` give another way of representing complex numbers, the
66+
polar form, as the combination of modulus and argument fully specify the
67+
position of a point on the plane. Recovering the original rectangular
68+
co-ordinates from the polar form is done by the formula called trigonometric
6669
form:
6770

6871
![Polar Form](https://wikimedia.org/api/rest_v1/media/math/render/svg/b03de1e1b7b049880b5e4870b68a57bc180ff6ce)
@@ -107,7 +110,7 @@ To subtract two complex numbers we subtract each part separately:
107110

108111
### Multiplying
109112

110-
To multiply complex numbers each part of the first complex number gets multiplied
113+
To multiply complex numbers each part of the first complex number gets multiplied
111114
by each part of the second complex number:
112115

113116
Just use "FOIL", which stands for "**F**irsts, **O**uters, **I**nners, **L**asts" (
@@ -138,7 +141,7 @@ Use this rule:
138141
**Example**
139142

140143
```text
141-
(3 + 2i)(1 + 7i)
144+
(3 + 2i)(1 + 7i)
142145
= 3×1 + 3×7i + 2i×1+ 2i×7i
143146
= 3 + 21i + 2i + 14i^2
144147
= 3 + 21i + 2i − 14 (because i^2 = −1)
@@ -164,15 +167,15 @@ ______
164167
5 − 3i = 5 + 3i
165168
```
166169

167-
On the complex plane the conjugate number will be mirrored against real axes.
170+
On the complex plane the conjugate number will be mirrored against real axes.
168171

169172
![Complex Conjugate](https://upload.wikimedia.org/wikipedia/commons/6/69/Complex_conjugate_picture.svg)
170173

171174
### Dividing
172175

173176
The conjugate is used to help complex division.
174177

175-
The trick is to *multiply both top and bottom by the conjugate of the bottom*.
178+
The trick is to _multiply both top and bottom by the conjugate of the bottom_.
176179

177180
**Example**
178181

@@ -207,7 +210,7 @@ In the previous example, what happened on the bottom was interesting:
207210
(4 − 5i)(4 + 5i) = 16 + 20i − 20i − 25i
208211
```
209212

210-
The middle terms `(20i − 20i)` cancel out! Also `i^2 = −1` so we end up with this:
213+
The middle terms `(20i − 20i)` cancel out! Also `i^2 = −1` so we end up with this:
211214

212215
```text
213216
(4 − 5i)(4 + 5i) = 4^2 + 5^2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Algorithme d'Euclide
2+
3+
_Read this in other languages:_
4+
[english](README.md).
5+
6+
En mathématiques, l'algorithme d'Euclide est un algorithme qui calcule le plus grand commun diviseur (PGCD) de deux entiers, c'est-à-dire le plus grand entier qui divise les deux entiers, en laissant un reste nul. L'algorithme ne connaît pas la factorisation de ces deux nombres.
7+
8+
Le PGCD de deux entiers relatifs est égal au PGCD de leurs valeurs absolues : de ce fait, on se restreint dans cette section aux entiers positifs. L'algorithme part du constat suivant : le PGCD de deux nombres n'est pas changé si on remplace le plus grand d'entre eux par leur différence. Autrement dit, `pgcd(a, b) = pgcd(b, a - b)`. Par exemple, le PGCD de `252` et `105` vaut `21` (en effet, `252 = 21 × 12` and `105 = 21 × 5`), mais c'est aussi le PGCD de `252 - 105 = 147` et `105`. Ainsi, comme le remplacement de ces nombres diminue strictement le plus grand d'entre eux, on peut continuer le processus, jusqu'à obtenir deux nombres égaux.
9+
10+
En inversant les étapes, le PGCD peut être exprimé comme une somme de
11+
les deux nombres originaux, chacun étant multiplié
12+
par un entier positif ou négatif, par exemple `21 = 5 × 105 + (-2) × 252`.
13+
Le fait que le PGCD puisse toujours être exprimé de cette manière est
14+
connue sous le nom de Théorème de Bachet-Bézout.
15+
16+
![GCD](https://upload.wikimedia.org/wikipedia/commons/3/37/Euclid%27s_algorithm_Book_VII_Proposition_2_3.png)
17+
18+
La Méthode d'Euclide pour trouver le plus grand diviseur commun (PGCD)
19+
de deux longueurs de départ`BA` et `DC`, toutes deux définies comme étant
20+
multiples d'une longueur commune. La longueur `DC` étant
21+
plus courte, elle est utilisée pour « mesurer » `BA`, mais une seule fois car
22+
le reste `EA` est inférieur à `DC`. `EA` mesure maintenant (deux fois)
23+
la longueur la plus courte `DC`, le reste `FC` étant plus court que `EA`.
24+
Alors `FC` mesure (trois fois) la longueur `EA`. Parce qu'il y a
25+
pas de reste, le processus se termine par `FC` étant le « PGCD ».
26+
À droite, l'exemple de Nicomaque de Gérase avec les nombres `49` et `21`
27+
ayan un PGCD de `7` (dérivé de Heath 1908: 300).
28+
29+
![GCD](https://upload.wikimedia.org/wikipedia/commons/7/74/24x60.svg)
30+
31+
Un de rectangle de dimensions `24 par 60` peux se carreler en carrés de `12 par 12`,
32+
puisque `12` est le PGCD ed `24` et `60`. De façon générale,
33+
un rectangle de dimension `a par b` peut se carreler en carrés
34+
de côté `c`, seulement si `c` est un diviseur commun de `a` et `b`.
35+
36+
![GCD](https://upload.wikimedia.org/wikipedia/commons/1/1c/Euclidean_algorithm_1071_462.gif)
37+
38+
Animation basée sur la soustraction via l'algorithme euclidien.
39+
Le rectangle initial a les dimensions `a = 1071` et `b = 462`.
40+
Des carrés de taille `462 × 462` y sont placés en laissant un
41+
rectangle de `462 × 147`. Ce rectangle est carrelé avec des
42+
carrés de `147 × 147` jusqu'à ce qu'un rectangle de `21 × 147` soit laissé,
43+
qui à son tour estcarrelé avec des carrés `21 × 21`,
44+
ne laissant aucune zone non couverte.
45+
La plus petite taille carrée, `21`, est le PGCD de `1071` et `462`.
46+
47+
## References
48+
49+
[Wikipedia](https://fr.wikipedia.org/wiki/Algorithme_d%27Euclide)

‎src/algorithms/math/euclidean-algorithm/README.md

+39-36
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
11
# Euclidean algorithm
22

3-
In mathematics, the Euclidean algorithm, or Euclid's algorithm,
4-
is an efficient method for computing the greatest common divisor
5-
(GCD) of two numbers, the largest number that divides both of
3+
_Read this in other languages:_
4+
[français](README.fr-FR.md).
5+
6+
In mathematics, the Euclidean algorithm, or Euclid's algorithm,
7+
is an efficient method for computing the greatest common divisor
8+
(GCD) of two numbers, the largest number that divides both of
69
them without leaving a remainder.
710

8-
The Euclidean algorithm is based on the principle that the
9-
greatest common divisor of two numbers does not change if
10-
the larger number is replaced by its difference with the
11-
smaller number. For example, `21` is the GCD of `252` and
12-
`105` (as `252 = 21 × 12` and `105 = 21 × 5`), and the same
13-
number `21` is also the GCD of `105` and `252 − 105 = 147`.
14-
Since this replacement reduces the larger of the two numbers,
15-
repeating this process gives successively smaller pairs of
16-
numbers until the two numbers become equal.
17-
When that occurs, they are the GCD of the original two numbers.
18-
19-
By reversing the steps, the GCD can be expressed as a sum of
20-
the two original numbers each multiplied by a positive or
21-
negative integer, e.g., `21 = 5 × 105 + (−2) × 252`.
22-
The fact that the GCD can always be expressed in this way is
11+
The Euclidean algorithm is based on the principle that the
12+
greatest common divisor of two numbers does not change if
13+
the larger number is replaced by its difference with the
14+
smaller number. For example, `21` is the GCD of `252` and
15+
`105` (as `252 = 21 × 12` and `105 = 21 × 5`), and the same
16+
number `21` is also the GCD of `105` and `252 − 105 = 147`.
17+
Since this replacement reduces the larger of the two numbers,
18+
repeating this process gives successively smaller pairs of
19+
numbers until the two numbers become equal.
20+
When that occurs, they are the GCD of the original two numbers.
21+
22+
By reversing the steps, the GCD can be expressed as a sum of
23+
the two original numbers each multiplied by a positive or
24+
negative integer, e.g., `21 = 5 × 105 + (−2) × 252`.
25+
The fact that the GCD can always be expressed in this way is
2326
known as Bézout's identity.
2427

2528
![GCD](https://upload.wikimedia.org/wikipedia/commons/3/37/Euclid%27s_algorithm_Book_VII_Proposition_2_3.png)
2629

27-
Euclid's method for finding the greatest common divisor (GCD)
28-
of two starting lengths `BA` and `DC`, both defined to be
29-
multiples of a common "unit" length. The length `DC` being
30-
shorter, it is used to "measure" `BA`, but only once because
31-
remainder `EA` is less than `DC`. EA now measures (twice)
32-
the shorter length `DC`, with remainder `FC` shorter than `EA`.
33-
Then `FC` measures (three times) length `EA`. Because there is
34-
no remainder, the process ends with `FC` being the `GCD`.
35-
On the right Nicomachus' example with numbers `49` and `21`
30+
Euclid's method for finding the greatest common divisor (GCD)
31+
of two starting lengths `BA` and `DC`, both defined to be
32+
multiples of a common "unit" length. The length `DC` being
33+
shorter, it is used to "measure" `BA`, but only once because
34+
remainder `EA` is less than `DC`. EA now measures (twice)
35+
the shorter length `DC`, with remainder `FC` shorter than `EA`.
36+
Then `FC` measures (three times) length `EA`. Because there is
37+
no remainder, the process ends with `FC` being the `GCD`.
38+
On the right Nicomachus' example with numbers `49` and `21`
3639
resulting in their GCD of `7` (derived from Heath 1908:300).
3740

3841
![GCD](https://upload.wikimedia.org/wikipedia/commons/7/74/24x60.svg)
3942

40-
A `24-by-60` rectangle is covered with ten `12-by-12` square
41-
tiles, where `12` is the GCD of `24` and `60`. More generally,
42-
an `a-by-b` rectangle can be covered with square tiles of
43+
A `24-by-60` rectangle is covered with ten `12-by-12` square
44+
tiles, where `12` is the GCD of `24` and `60`. More generally,
45+
an `a-by-b` rectangle can be covered with square tiles of
4346
side-length `c` only if `c` is a common divisor of `a` and `b`.
4447

4548
![GCD](https://upload.wikimedia.org/wikipedia/commons/1/1c/Euclidean_algorithm_1071_462.gif)
4649

47-
Subtraction-based animation of the Euclidean algorithm.
48-
The initial rectangle has dimensions `a = 1071` and `b = 462`.
49-
Squares of size `462×462` are placed within it leaving a
50-
`462×147` rectangle. This rectangle is tiled with `147×147`
51-
squares until a `21×147` rectangle is left, which in turn is
52-
tiled with `21×21` squares, leaving no uncovered area.
50+
Subtraction-based animation of the Euclidean algorithm.
51+
The initial rectangle has dimensions `a = 1071` and `b = 462`.
52+
Squares of size `462×462` are placed within it leaving a
53+
`462×147` rectangle. This rectangle is tiled with `147×147`
54+
squares until a `21×147` rectangle is left, which in turn is
55+
tiled with `21×21` squares, leaving no uncovered area.
5356
The smallest square size, `21`, is the GCD of `1071` and `462`.
5457

5558
## References
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Factorielle
2+
3+
_Lisez ceci dans d'autres langues:_
4+
[english](README.md), [_简体中文_](README.zh-CN.md).
5+
6+
En mathématiques, la factorielle d'un entier naturel `n`,
7+
notée avec un point d'exclamation `n!`, est le produit des nombres entiers
8+
strictement positifs inférieurs ou égaux à n. Par exemple:
9+
10+
```
11+
5! = 5 * 4 * 3 * 2 * 1 = 120
12+
```
13+
14+
| n | n! |
15+
| --- | ----------------: |
16+
| 0 | 1 |
17+
| 1 | 1 |
18+
| 2 | 2 |
19+
| 3 | 6 |
20+
| 4 | 24 |
21+
| 5 | 120 |
22+
| 6 | 720 |
23+
| 7 | 5 040 |
24+
| 8 | 40 320 |
25+
| 9 | 362 880 |
26+
| 10 | 3 628 800 |
27+
| 11 | 39 916 800 |
28+
| 12 | 479 001 600 |
29+
| 13 | 6 227 020 800 |
30+
| 14 | 87 178 291 200 |
31+
| 15 | 1 307 674 368 000 |
32+
33+
## References
34+
35+
[Wikipedia](https://fr.wikipedia.org/wiki/Factorielle)

‎src/algorithms/math/factorial/README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
# Factorial
22

33
_Read this in other languages:_
4-
[_简体中文_](README.zh-CN.md),
4+
[_简体中文_](README.zh-CN.md), [français](README.fr-FR.md).
55

6-
In mathematics, the factorial of a non-negative integer `n`,
7-
denoted by `n!`, is the product of all positive integers less
6+
In mathematics, the factorial of a non-negative integer `n`,
7+
denoted by `n!`, is the product of all positive integers less
88
than or equal to `n`. For example:
99

1010
```
1111
5! = 5 * 4 * 3 * 2 * 1 = 120
1212
```
1313

14-
| n | n! |
15-
| ----- | --------------------------: |
16-
| 0 | 1 |
17-
| 1 | 1 |
18-
| 2 | 2 |
19-
| 3 | 6 |
20-
| 4 | 24 |
21-
| 5 | 120 |
22-
| 6 | 720 |
23-
| 7 | 5 040 |
24-
| 8 | 40 320 |
25-
| 9 | 362 880 |
26-
| 10 | 3 628 800 |
27-
| 11 | 39 916 800 |
28-
| 12 | 479 001 600 |
29-
| 13 | 6 227 020 800 |
30-
| 14 | 87 178 291 200 |
31-
| 15 | 1 307 674 368 000 |
14+
| n | n! |
15+
| --- | ----------------: |
16+
| 0 | 1 |
17+
| 1 | 1 |
18+
| 2 | 2 |
19+
| 3 | 6 |
20+
| 4 | 24 |
21+
| 5 | 120 |
22+
| 6 | 720 |
23+
| 7 | 5 040 |
24+
| 8 | 40 320 |
25+
| 9 | 362 880 |
26+
| 10 | 3 628 800 |
27+
| 11 | 39 916 800 |
28+
| 12 | 479 001 600 |
29+
| 13 | 6 227 020 800 |
30+
| 14 | 87 178 291 200 |
31+
| 15 | 1 307 674 368 000 |
3232

3333
## References
3434

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Algorithme d'exponentiation rapide
2+
3+
_Read this in other languages:_
4+
[english](README.md).
5+
6+
En algèbre, une **puissance** d'un nombre est le résultat de la multiplication répétée de ce nombre avec lui-même.
7+
8+
Elle est souvent notée en assortissant le nombre d'un entier, typographié en exposant, qui indique le nombre de fois qu'apparaît le nombre comme facteur dans cette multiplication.
9+
10+
![Power](https://www.mathsisfun.com/algebra/images/exponent-8-2.svg)
11+
12+
## Implémentation « naïve »
13+
14+
Comment trouver `a` élevé à la puissance `b` ?
15+
16+
On multiplie `a` avec lui-même, `b` nombre de fois.
17+
Ainsi, `a^b = a * a * a * ... * a` (`b` occurrences de `a`).
18+
19+
Cette opération aura un complexité linéaire, notée `O(n)`,
20+
car la multiplication aura lieu exactement `n` fois.
21+
22+
## Algorithme d'exponentiation rapide
23+
24+
Peut-on faire mieux que cette implémentation naïve?
25+
Oui, on peut réduire le nombre de puissance à un complexité de `O(log(n))`.
26+
27+
Cet algorithme utilise l'approche « diviser pour mieux régner »
28+
pour calculer cette puissance.
29+
En l'état, cet algorithme fonctionne pour deux entiers positifs `X` et `Y`.
30+
31+
L'idée derrière cet algorithme est basée sur l'observation suivante.
32+
33+
Lorsque `Y` est **pair**:
34+
35+
```text
36+
X^Y = X^(Y/2) * X^(Y/2)
37+
```
38+
39+
Lorsque `Y` est **impair**:
40+
41+
```text
42+
X^Y = X^(Y//2) * X^(Y//2) * X
43+
où Y//2 est le résultat de la division entière de Y par 2.
44+
```
45+
46+
**Par exemple**
47+
48+
```text
49+
2^4 = (2 * 2) * (2 * 2) = (2^2) * (2^2)
50+
```
51+
52+
```text
53+
2^5 = (2 * 2) * (2 * 2) * 2 = (2^2) * (2^2) * (2)
54+
```
55+
56+
Ainsi, puisqu'à chaque étape on doits calculer
57+
deux fois la même puissance `X ^ (Y / 2)`,
58+
on peut optimiser en l'enregistrant dans une variable intermédiaire
59+
pour éviter son calcul en double.
60+
61+
**Complexité en temps**
62+
63+
Comme à chaque itération nous réduisons la puissance de moitié,
64+
nous appelons récursivement la fonction `log(n)` fois. Le complexité de temps de cet algorithme est donc réduite à:
65+
66+
```text
67+
O(log(n))
68+
```
69+
70+
## Références
71+
72+
- [YouTube](https://www.youtube.com/watch?v=LUWavfN9zEo&index=80&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8&t=0s)
73+
- [Wikipedia](https://fr.wikipedia.org/wiki/Exponentiation_rapide)

‎src/algorithms/math/fast-powering/README.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Fast Powering Algorithm
22

3-
**The power of a number** says how many times to use the number in a
3+
_Read this in other languages:_
4+
[français](README.fr-FR.md).
5+
6+
**The power of a number** says how many times to use the number in a
47
multiplication.
58

69
It is written as a small number to the right and above the base number.
@@ -11,7 +14,7 @@ It is written as a small number to the right and above the base number.
1114

1215
How to find `a` raised to the power `b`?
1316

14-
We multiply `a` to itself, `b` times. That
17+
We multiply `a` to itself, `b` times. That
1518
is, `a^b = a * a * a * ... * a` (`b` occurrences of `a`).
1619

1720
This operation will take `O(n)` time since we need to do multiplication operation
@@ -20,17 +23,17 @@ exactly `n` times.
2023
## Fast Power Algorithm
2124

2225
Can we do better than naive algorithm does? Yes we may solve the task of
23-
powering in `O(log(n))` time.
26+
powering in `O(log(n))` time.
2427

25-
The algorithm uses divide and conquer approach to compute power. Currently the
28+
The algorithm uses divide and conquer approach to compute power. Currently the
2629
algorithm work for two positive integers `X` and `Y`.
2730

2831
The idea behind the algorithm is based on the fact that:
2932

3033
For **even** `Y`:
3134

3235
```text
33-
X^Y = X^(Y/2) * X^(Y/2)
36+
X^Y = X^(Y/2) * X^(Y/2)
3437
```
3538

3639
For **odd** `Y`:
@@ -50,17 +53,17 @@ where Y//2 is result of division of Y by 2 without reminder.
5053
2^5 = (2 * 2) * (2 * 2) * 2 = (2^2) * (2^2) * (2)
5154
```
5255

53-
Now, since on each step we need to compute the same `X^(Y/2)` power twice we may optimise
54-
it by saving it to some intermediate variable to avoid its duplicate calculation.
56+
Now, since on each step we need to compute the same `X^(Y/2)` power twice we may optimise
57+
it by saving it to some intermediate variable to avoid its duplicate calculation.
5558

5659
**Time Complexity**
5760

58-
Since each iteration we split the power by half then we will call function
61+
Since each iteration we split the power by half then we will call function
5962
recursively `log(n)` times. This the time complexity of the algorithm is reduced to:
6063

6164
```text
6265
O(log(n))
63-
```
66+
```
6467

6568
## References
6669

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Nombre de Fibonacci
2+
3+
_Read this in other languages:_
4+
[english](README.md).
5+
6+
En mathématiques, la suite de Fibonacci est une suite d'entiers
7+
dans laquelle chaque terme (après les deux premiers)
8+
est la somme des deux termes qui le précèdent.
9+
Les termes de cette suite sont appelés nombres de Fibonacci:
10+
11+
`0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...`
12+
13+
Les carrés de Fibonacci en spirale s'ajustent ensemble pour former une spirale d'or.
14+
15+
![Fibonacci](https://upload.wikimedia.org/wikipedia/commons/d/db/34%2A21-FibonacciBlocks.png)
16+
17+
La spirale de Fibonacci: approximation d'une spirale d'or créée en dessinant des arcs de cercle reliant les coins opposés de carrés dans un pavage Fibonacci[4] . Celui-ci utilise des carrés de tailles 1, 1, 2, 3, 5, 8, 13, 21, et 34.
18+
19+
![Fibonacci Spiral](https://upload.wikimedia.org/wikipedia/commons/2/2e/FibonacciSpiral.svg)
20+
21+
## References
22+
23+
- [Wikipedia](https://fr.wikipedia.org/wiki/Suite_de_Fibonacci)

‎src/algorithms/math/fibonacci/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# Fibonacci Number
22

3-
In mathematics, the Fibonacci numbers are the numbers in the following
4-
integer sequence, called the Fibonacci sequence, and characterized by
5-
the fact that every number after the first two is the sum of the two
3+
_Read this in other languages:_
4+
[français](README.fr-FR.md).
5+
6+
In mathematics, the Fibonacci numbers are the numbers in the following
7+
integer sequence, called the Fibonacci sequence, and characterized by
8+
the fact that every number after the first two is the sum of the two
69
preceding ones:
710

811
`0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Transformation de Fourier
2+
3+
_Read this in other languages:_
4+
[english](README.md).
5+
6+
## Définitions
7+
8+
La transformation de Fourier (****) est une opération qui transforme
9+
une fonction intégrable sur ℝ en une autre fonction,
10+
décrivant le spectre fréquentiel de cette dernière
11+
12+
La **Transformée de Fourier Discrète** (**TFD**) convertit une séquence finie d'échantillons également espacés d'une fonction, dans une séquence de même longueur d'échantillons, également espacés de la Transformée de Fourier à temps discret (TFtd), qui est une fonction complexe de la fréquence.
13+
L'intervalle auquel le TFtd est échantillonné est l'inverse de la durée de la séquence d'entrée.
14+
Une TFD inverse est une série de Fourier, utilisant les échantillons TFtd comme coefficients de sinusoïdes complexes aux fréquences TFtd correspondantes. Elle a les mêmes valeurs d'échantillonnage que la
15+
séquence d'entrée originale. On dit donc que la TFD est une représentation du domaine fréquentiel
16+
de la séquence d'entrée d'origine. Si la séquence d'origine couvre toutes les
17+
valeurs non nulles d'une fonction, sa TFtd est continue (et périodique), et la TFD fournit
18+
les échantillons discrets d'une fenêtre. Si la séquence d'origine est un cycle d'une fonction périodique, la TFD fournit toutes les valeurs non nulles d'une fenêtre TFtd.
19+
20+
Transformée de Fourier Discrète converti une séquence de `N` nombres complexes:
21+
22+
{x<sub>n</sub>} = x<sub>0</sub>, x<sub>1</sub>, x<sub>2</sub> ..., x<sub>N-1</sub>
23+
24+
en une atre séquence de nombres complexes::
25+
26+
{X<sub>k</sub>} = X<sub>0</sub>, X<sub>1</sub>, X<sub>2</sub> ..., X<sub>N-1</sub>
27+
28+
décrite par:
29+
30+
![DFT](https://wikimedia.org/api/rest_v1/media/math/render/svg/1af0a78dc50bbf118ab6bd4c4dcc3c4ff8502223)
31+
32+
The **Transformée de Fourier à temps discret** (**TFtd**) est une forme d'analyse de Fourier
33+
qui s'applique aux échantillons uniformément espacés d'une fonction continue. Le terme "temps discret" fait référence au fait que la transformée fonctionne sur des données discrètes
34+
(échantillons) dont l'intervalle a souvent des unités de temps.
35+
À partir des seuls échantillons, elle produit une fonction de fréquence qui est une somme périodique de la
36+
Transformée de Fourier continue de la fonction continue d'origine.
37+
38+
A **Transformation de Fourier rapide** (**FFT** pour Fast Fourier Transform) est un algorithme de calcul de la transformation de Fourier discrète (TFD). Il est couramment utilisé en traitement numérique du signal pour transformer des données discrètes du domaine temporel dans le domaine fréquentiel, en particulier dans les oscilloscopes numériques (les analyseurs de spectre utilisant plutôt des filtres analogiques, plus précis). Son efficacité permet de réaliser des filtrages en modifiant le spectre et en utilisant la transformation inverse (filtre à réponse impulsionnelle finie).
39+
40+
Cette transformation peut être illustée par la formule suivante. Sur la période de temps mesurée
41+
dans le diagramme, le signal contient 3 fréquences dominantes distinctes.
42+
43+
Vue d'un signal dans le domaine temporel et fréquentiel:
44+
45+
![FFT](https://upload.wikimedia.org/wikipedia/commons/6/61/FFT-Time-Frequency-View.png)
46+
47+
An FFT algorithm computes the discrete Fourier transform (DFT) of a sequence, or
48+
its inverse (IFFT). Fourier analysis converts a signal from its original domain
49+
to a representation in the frequency domain and vice versa. An FFT rapidly
50+
computes such transformations by factorizing the DFT matrix into a product of
51+
sparse (mostly zero) factors. As a result, it manages to reduce the complexity of
52+
computing the DFT from O(n<sup>2</sup>), which arises if one simply applies the
53+
definition of DFT, to O(n log n), where n is the data size.
54+
55+
Un algorithme FFT calcule la Transformée de Fourier discrète (TFD) d'une séquence, ou
56+
son inverse (IFFT). L'analyse de Fourier convertit un signal de son domaine d'origine
57+
en une représentation dans le domaine fréquentiel et vice versa. Une FFT
58+
calcule rapidement ces transformations en factorisant la matrice TFD en un produit de
59+
facteurs dispersés (généralement nuls). En conséquence, il parvient à réduire la complexité de
60+
calcul de la TFD de O (n <sup> 2 </sup>), qui survient si l'on applique simplement la
61+
définition de TFD, à O (n log n), où n est la taille des données.
62+
63+
Voici une analyse de Fourier discrète d'une somme d'ondes cosinus à 10, 20, 30, 40,
64+
et 50 Hz:
65+
66+
![FFT](https://upload.wikimedia.org/wikipedia/commons/6/64/FFT_of_Cosine_Summation_Function.png)
67+
68+
## Explanation
69+
70+
La Transformée de Fourier est l'une des connaissances les plus importante jamais découverte. Malheureusement, le
71+
son sens est enfoui dans des équations denses::
72+
73+
![](https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/45c088dbb767150fc0bacfeb49dd49e5.png)
74+
75+
et
76+
77+
![](https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/faeb9c5bf2e60add63ae4a70b293c7b4.png)
78+
79+
Plutôt que se noyer dans les symboles, faisons en premier lieu l'expérience de l'idée principale. Voici une métaphore en français simple:
80+
81+
- _Que fait la transformée de Fourier ?_ A partir d'un smoothie, elle trouve sa recette.
82+
- _Comment ?_ Elle passe le smoothie dans un filtre pour en extraire chaque ingrédient.
83+
- _Pourquoi ?_ Les recettes sont plus faciles à analyser, comparer et modifier que le smoothie lui-même.
84+
- _Comment récupérer le smoothie ?_ Re-mélanger les ingrédients.
85+
86+
**Pensez en cercles, pas seulement en sinusoïdes**
87+
88+
La transformée de Fourier concerne des trajectoires circulaires (pas les sinusoïdes 1-d)
89+
et la formuled'Euler est une manière intelligente d'en générer une:
90+
91+
![](https://betterexplained.com/wp-content/uploads/euler/equal_paths.png)
92+
93+
Doit-on utiliser des exposants imaginaires pour se déplacer en cercle ? Non. Mais c'est pratique
94+
et compact. Et bien sûr, nous pouvons décrire notre chemin comme un mouvement coordonné en deux
95+
dimensions (réelle et imaginaire), mais n'oubliez pas la vue d'ensemble: nous sommes juste
96+
en déplacement dans un cercle.
97+
98+
**À la découverte de la transformation complète**
99+
100+
L'idée générale: notre signal n'est qu'un tas de pics de temps, d'instant T ! Si nous combinons les
101+
recettes pour chaque pic de temps, nous devrions obtenir la recette du signal complet.
102+
103+
La transformée de Fourier construit cette recette fréquence par fréquence:
104+
105+
![](https://betterexplained.com/wp-content/uploads/images/fourier-explained-20121219-224649.png)
106+
107+
Quelques notes
108+
109+
- N = nombre d'échantillons de temps dont nous disposons
110+
- n = échantillon actuellement étudié (0 ... N-1)
111+
- x<sub>n</sub> = valeur du signal au temps n
112+
- k = fréquence actuellement étudiée (0 Hertz up to N-1 Hertz)
113+
- X<sub>k</sub> = quantité de fréquence k dans le signal (amplitude et phase, un nombre complexe)
114+
- Le facteur 1 / N est généralement déplacé vers la transformée inverse (passant des fréquences au temps). Ceci est autorisé, bien que je préfère 1 / N dans la transformation directe car cela donne les tailles réelles des pics de temps. Vous pouvez être plus ambitieux et utiliser 1 / racine carrée de (N) sur les deux transformations (aller en avant et en arrière crée le facteur 1 / N).
115+
- n/N est le pourcentage du temps que nous avons passé. 2 _ pi _ k est notre vitesse en radians/s. e ^ -ix est notre chemin circulaire vers l'arrière. La combinaison est la distance parcourue, pour cette vitesse et ce temps.
116+
- Les équations brutes de la transformée de Fourier consiste simplement à "ajouter les nombres complexes". De nombreux langages de programmation ne peuvent pas gérer directement les nombres complexes, on converti donc tout en coordonnées rectangulaires, pour les ajouter.
117+
118+
Stuart Riffle a une excellente interprétation de la transformée de Fourier:
119+
120+
![](https://betterexplained.com/wp-content/uploads/images/DerivedDFT.png)
121+
122+
## Références
123+
124+
- Wikipedia
125+
126+
- [TF](https://fr.wikipedia.org/wiki/Transformation_de_Fourier)
127+
- [TFD](https://fr.wikipedia.org/wiki/Transformation_de_Fourier_discr%C3%A8te)
128+
- [FFT](https://fr.wikipedia.org/wiki/Transformation_de_Fourier_rapide)
129+
- [TFtd (en anglais)](https://en.wikipedia.org/wiki/Discrete-time_Fourier_transform)
130+
131+
- en Anglais
132+
- [An Interactive Guide To The Fourier Transform](https://betterexplained.com/articles/an-interactive-guide-to-the-fourier-transform/)
133+
- [DFT on YouTube by Better Explained](https://www.youtube.com/watch?v=iN0VG9N2q0U&t=0s&index=77&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
134+
- [FT on YouTube by 3Blue1Brown](https://www.youtube.com/watch?v=spUNpyF58BY&t=0s&index=76&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8)
135+
- [FFT on YouTube by Simon Xu](https://www.youtube.com/watch?v=htCj9exbGo0&index=78&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8&t=0s)

‎src/algorithms/math/fourier-transform/README.md

+40-37
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
# Fourier Transform
22

3+
_Read this in other languages:_
4+
[français](README.fr-FR.md).
5+
36
## Definitions
47

5-
The **Fourier Transform** (**FT**) decomposes a function of time (a signal) into
6-
the frequencies that make it up, in a way similar to how a musical chord can be
8+
The **Fourier Transform** (**FT**) decomposes a function of time (a signal) into
9+
the frequencies that make it up, in a way similar to how a musical chord can be
710
expressed as the frequencies (or pitches) of its constituent notes.
811

9-
The **Discrete Fourier Transform** (**DFT**) converts a finite sequence of
10-
equally-spaced samples of a function into a same-length sequence of
11-
equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a
12-
complex-valued function of frequency. The interval at which the DTFT is sampled
13-
is the reciprocal of the duration of the input sequence. An inverse DFT is a
14-
Fourier series, using the DTFT samples as coefficients of complex sinusoids at
15-
the corresponding DTFT frequencies. It has the same sample-values as the original
16-
input sequence. The DFT is therefore said to be a frequency domain representation
17-
of the original input sequence. If the original sequence spans all the non-zero
18-
values of a function, its DTFT is continuous (and periodic), and the DFT provides
19-
discrete samples of one cycle. If the original sequence is one cycle of a periodic
12+
The **Discrete Fourier Transform** (**DFT**) converts a finite sequence of
13+
equally-spaced samples of a function into a same-length sequence of
14+
equally-spaced samples of the discrete-time Fourier transform (DTFT), which is a
15+
complex-valued function of frequency. The interval at which the DTFT is sampled
16+
is the reciprocal of the duration of the input sequence. An inverse DFT is a
17+
Fourier series, using the DTFT samples as coefficients of complex sinusoids at
18+
the corresponding DTFT frequencies. It has the same sample-values as the original
19+
input sequence. The DFT is therefore said to be a frequency domain representation
20+
of the original input sequence. If the original sequence spans all the non-zero
21+
values of a function, its DTFT is continuous (and periodic), and the DFT provides
22+
discrete samples of one cycle. If the original sequence is one cycle of a periodic
2023
function, the DFT provides all the non-zero values of one DTFT cycle.
2124

2225
The Discrete Fourier transform transforms a sequence of `N` complex numbers:
23-
26+
2427
{x<sub>n</sub>} = x<sub>0</sub>, x<sub>1</sub>, x<sub>2</sub> ..., x<sub>N-1</sub>
2528

2629
into another sequence of complex numbers:
@@ -31,16 +34,16 @@ which is defined by:
3134

3235
![DFT](https://wikimedia.org/api/rest_v1/media/math/render/svg/1af0a78dc50bbf118ab6bd4c4dcc3c4ff8502223)
3336

34-
The **Discrete-Time Fourier Transform** (**DTFT**) is a form of Fourier analysis
35-
that is applicable to the uniformly-spaced samples of a continuous function. The
37+
The **Discrete-Time Fourier Transform** (**DTFT**) is a form of Fourier analysis
38+
that is applicable to the uniformly-spaced samples of a continuous function. The
3639
term discrete-time refers to the fact that the transform operates on discrete data
37-
(samples) whose interval often has units of time. From only the samples, it
38-
produces a function of frequency that is a periodic summation of the continuous
40+
(samples) whose interval often has units of time. From only the samples, it
41+
produces a function of frequency that is a periodic summation of the continuous
3942
Fourier transform of the original continuous function.
4043

4144
A **Fast Fourier Transform** (**FFT**) is an algorithm that samples a signal over
42-
a period of time (or space) and divides it into its frequency components. These
43-
components are single sinusoidal oscillations at distinct frequencies each with
45+
a period of time (or space) and divides it into its frequency components. These
46+
components are single sinusoidal oscillations at distinct frequencies each with
4447
their own amplitude and phase.
4548

4649
This transformation is illustrated in Diagram below. Over the time period measured
@@ -50,22 +53,22 @@ View of a signal in the time and frequency domain:
5053

5154
![FFT](https://upload.wikimedia.org/wikipedia/commons/6/61/FFT-Time-Frequency-View.png)
5255

53-
An FFT algorithm computes the discrete Fourier transform (DFT) of a sequence, or
54-
its inverse (IFFT). Fourier analysis converts a signal from its original domain
55-
to a representation in the frequency domain and vice versa. An FFT rapidly
56-
computes such transformations by factorizing the DFT matrix into a product of
57-
sparse (mostly zero) factors. As a result, it manages to reduce the complexity of
58-
computing the DFT from O(n<sup>2</sup>), which arises if one simply applies the
56+
An FFT algorithm computes the discrete Fourier transform (DFT) of a sequence, or
57+
its inverse (IFFT). Fourier analysis converts a signal from its original domain
58+
to a representation in the frequency domain and vice versa. An FFT rapidly
59+
computes such transformations by factorizing the DFT matrix into a product of
60+
sparse (mostly zero) factors. As a result, it manages to reduce the complexity of
61+
computing the DFT from O(n<sup>2</sup>), which arises if one simply applies the
5962
definition of DFT, to O(n log n), where n is the data size.
6063

61-
Here a discrete Fourier analysis of a sum of cosine waves at 10, 20, 30, 40,
64+
Here a discrete Fourier analysis of a sum of cosine waves at 10, 20, 30, 40,
6265
and 50 Hz:
6366

6467
![FFT](https://upload.wikimedia.org/wikipedia/commons/6/64/FFT_of_Cosine_Summation_Function.png)
6568

6669
## Explanation
6770

68-
The Fourier Transform is one of deepest insights ever made. Unfortunately, the
71+
The Fourier Transform is one of deepest insights ever made. Unfortunately, the
6972
meaning is buried within dense equations:
7073

7174
![](https://betterexplained.com/wp-content/plugins/wp-latexrender/pictures/45c088dbb767150fc0bacfeb49dd49e5.png)
@@ -76,26 +79,26 @@ and
7679

7780
Rather than jumping into the symbols, let's experience the key idea firsthand. Here's a plain-English metaphor:
7881

79-
- *What does the Fourier Transform do?* Given a smoothie, it finds the recipe.
80-
- *How?* Run the smoothie through filters to extract each ingredient.
81-
- *Why?* Recipes are easier to analyze, compare, and modify than the smoothie itself.
82-
- *How do we get the smoothie back?* Blend the ingredients.
82+
- _What does the Fourier Transform do?_ Given a smoothie, it finds the recipe.
83+
- _How?_ Run the smoothie through filters to extract each ingredient.
84+
- _Why?_ Recipes are easier to analyze, compare, and modify than the smoothie itself.
85+
- _How do we get the smoothie back?_ Blend the ingredients.
8386

8487
**Think With Circles, Not Just Sinusoids**
8588

86-
The Fourier Transform is about circular paths (not 1-d sinusoids) and Euler's
89+
The Fourier Transform is about circular paths (not 1-d sinusoids) and Euler's
8790
formula is a clever way to generate one:
8891

8992
![](https://betterexplained.com/wp-content/uploads/euler/equal_paths.png)
9093

9194
Must we use imaginary exponents to move in a circle? Nope. But it's convenient
92-
and compact. And sure, we can describe our path as coordinated motion in two
93-
dimensions (real and imaginary), but don't forget the big picture: we're just
95+
and compact. And sure, we can describe our path as coordinated motion in two
96+
dimensions (real and imaginary), but don't forget the big picture: we're just
9497
moving in a circle.
9598

9699
**Discovering The Full Transform**
97100

98-
The big insight: our signal is just a bunch of time spikes! If we merge the
101+
The big insight: our signal is just a bunch of time spikes! If we merge the
99102
recipes for each time spike, we should get the recipe for the full signal.
100103

101104
The Fourier Transform builds the recipe frequency-by-frequency:
@@ -110,7 +113,7 @@ A few notes:
110113
- k = current frequency we're considering (0 Hertz up to N-1 Hertz)
111114
- X<sub>k</sub> = amount of frequency k in the signal (amplitude and phase, a complex number)
112115
- The 1/N factor is usually moved to the reverse transform (going from frequencies back to time). This is allowed, though I prefer 1/N in the forward transform since it gives the actual sizes for the time spikes. You can get wild and even use 1/sqrt(N) on both transforms (going forward and back creates the 1/N factor).
113-
- n/N is the percent of the time we've gone through. 2 * pi * k is our speed in radians / sec. e^-ix is our backwards-moving circular path. The combination is how far we've moved, for this speed and time.
116+
- n/N is the percent of the time we've gone through. 2 _ pi _ k is our speed in radians / sec. e^-ix is our backwards-moving circular path. The combination is how far we've moved, for this speed and time.
114117
- The raw equations for the Fourier Transform just say "add the complex numbers". Many programming languages cannot handle complex numbers directly, so you convert everything to rectangular coordinates and add those.
115118

116119
Stuart Riffle has a great interpretation of the Fourier Transform:

0 commit comments

Comments
 (0)
Please sign in to comment.