from github to this gitea
This commit is contained in:
14
gists/0-my gists.md
Normal file
14
gists/0-my gists.md
Normal file
@@ -0,0 +1,14 @@
|
||||
up:: [[PKM|PKM]]
|
||||
title::"list of my gists"
|
||||
#PKM
|
||||
|
||||
---
|
||||
# my gists
|
||||
|
||||
```dataview
|
||||
TABLE gists.url as "link", gists.isPublic
|
||||
FROM "gists"
|
||||
WHERE file.link != this.file.link
|
||||
SORT gists.isPublic
|
||||
```
|
||||
|
@@ -0,0 +1,147 @@
|
||||
---
|
||||
gists:
|
||||
- id: 982f721e53dce3613d68cd2512a4b721
|
||||
url: 'https://gist.github.com/982f721e53dce3613d68cd2512a4b721'
|
||||
createdAt: '2022-09-24T23:15:29Z'
|
||||
updatedAt: '2023-03-11T11:54:39Z'
|
||||
filename: 'Contre, l''usage abusif, de la virgule, dans la notation, mathématique.md'
|
||||
isPublic: true
|
||||
---
|
||||
# Contre, l'usage abusif, de la virgule, dans la notation, mathématique
|
||||
|
||||
La notation mathématique traditionnelle cherche à traduire des phrases et des calculs en symboles. Par exemple, on peut dire "tous les nombres entiers sont pairs ou impairs", mais on peut également écrire $\forall n \in \mathbb{N}, \quad (2\mid n) \vee (2 \nmid n)$, ce qui veut dire la même chose.
|
||||
|
||||
La notation mathématique intéressante principalement pour deux choses :
|
||||
- elle est plus lisible : on préfère $\forall x \in N, \forall i, j \in \mathbb{N}, \quad i\times j|n \implies (i\mid n) \wedge (j\mid n)$ plutôt que "si un entier est divisible par le produit de deux entiers, alors il est divisible par chacun des deux entiers"
|
||||
- elle est plus rigoureuse : écrire des théorèmes ou expressions mathématiques en français peut être ambigu et sujet à interprétation
|
||||
|
||||
C'est pour ce deuxième point que la virgule pose un problème : elle rend la notation mathématique moins rigoureuse, et parfois même ambigüe.
|
||||
|
||||
## Les différentes significations de la virgule
|
||||
Pour comprendre les problèmes de la virgule, listons les significations possibles de ce symbole :
|
||||
|
||||
- pour des vecteurs, elle sépare les valeurs : $(x, y, z)$
|
||||
- Elle sépare les quantificateurs : $\forall x \in \mathbb{R}, \exists y \in \mathbb{R} \dots$
|
||||
- Elle signifie "tel que" : $\exists x \in \mathbb{R}, x^{2} < 42$
|
||||
- Elle "distribue" un $\in$ sur plusieurs valeurs : $\forall x, y \in \mathbb{R}\dots$
|
||||
|
||||
## Ambiguïtés créées par la virgule
|
||||
|
||||
Nous avons vu que la virgule possède plusieurs utilisations différentes. En fait, on peut aisément construire un exemple qui utilise toutes ces significations :
|
||||
|
||||
$\forall x, y \in \mathbb{R}, \exists y \in \mathbb{R}, y \in (x, y)$
|
||||
|
||||
Ici, on a le même problème qu'avec l'écriture en français : le même mot (symbole) peut avoir beaucoup de significations selon le contexte. On peut tout de même donner des règles qui permettent de reconnaître quelle interprétation est la bonne :
|
||||
- dans un vecteur (une valeur entre parenthèses), c'est un séparateur des coefficients du vecteur
|
||||
- avant un $\in$, c'est un raccourci pour dire que toutes les variables listées appartiennent à l'ensemble désigné
|
||||
- Après / entre des quantificateurs
|
||||
- c'est un "tel que" s'il est suivi par une expression ou bien par un "il existe"
|
||||
- c'est un séparateur s'il est suivi par un quantificateur "pour tout" ( $\forall$ )
|
||||
|
||||
### Cas où la notation est vraiment ambigue
|
||||
On a vu que, si les interprétations possibles de la virgule, on peut dire @de façon certaine laquelle est la bonne en fonction du contexte.
|
||||
|
||||
Mais il arrive que, quand on sait que l'on travaille sur un ensemble particulier (par exemple en arithmétique, on travaille très souvent sur $\mathbb{Z}$, ou bien en analyse sur $\mathbb{R}$) on note $\forall x, \dots$ pour dire $\forall x \in \text{ensemble concerné}, \dots$.
|
||||
C'est un raccourci de notation qui est pratique, mais on peut alors écrire :
|
||||
|
||||
|
||||
$\forall x,y \in \mathbb{R}$
|
||||
|
||||
Le problème est le suivant : si $y$ est une variable qui dépend de $x$ (par exemple, si on a posé avant $y = x+1$), on peut interpréter l'expression comme $\forall x \in \mathbb{R}, x+1 \in \mathbb{R}$. L'interprétation est logique, mais on a bien sûr d'abord pensé à ceci : $\forall x \in \mathbb{R}, \forall y \in \mathbb{R}$ (ou $\forall (x, y)\in \mathbb{R}^{2}$, ce qui est équivalent).
|
||||
|
||||
On voit donc que quelques cas (rares, il faut l'admettre) sont réellement sujets à interprétation
|
||||
|
||||
### Description des ensembles
|
||||
Une autre notation intéressante est celle que l'on utilise pour décrire les ensembles.
|
||||
|
||||
La notation générale est : $\lbrace x \in E \mid \mathscr{P}(x) \rbrace$ où $\mathscr{P}$ est une propriété qui dépend de $x$.
|
||||
On voit pafois aussi $\lbrace x \in E : \mathscr{P}(x) \rbrace$.
|
||||
|
||||
Bien sûr, la propriété $\mathscr{P}$ peut contenir des quantificateurs. Par exemple, on peut noter $\lbrace x \in \mathbb{R} \mid \not \exists y \in \mathbb{Q}, x \cdot y \in \mathbb{Z} \rbrace$
|
||||
|
||||
Ici, on note que le "tel que" est noté avec un $\mid$. L'utilisation de la virgule dans ce contexte est assez rare. En effet, les expressions sont alors beaucoup moins lisibles : $\lbrace x \in \mathbb{R}, \forall y \in \mathbb{N}, x\cdot y \notin \mathbb{N} \rbrace$
|
||||
J'ai pourtant déjà lù cette expression : $\{ \overrightarrow{MN}, M, N \in F\}$.
|
||||
|
||||
|
||||
Dans le contexte de la définition d'ensembles, il arrive également que l'on utilise la virgule comme "et" logique : $\left\lbrace \frac{a}{b} \mid a \in \mathbb{Z}, b \in \mathbb{Z}^{\ast} \right\rbrace$ ou même $\left\lbrace q \mid a \in \mathbb{Z}, b \in \mathbb{Z}^{\ast}, q = \frac{a}{b} \right\rbrace$.
|
||||
|
||||
On pourrait donc avoir cette formule : $\left\lbrace q, a, b \in \mathbb{Z}, b \neq 0, q = \frac{a}{b} \right\rbrace$, que l'on n'écrira bien sûr jamais, mais qui montre bien les nombreuses significations possibles de la virgule, et le travail d'interprétation que l'on doit faire à chaque fois pour deviner laquelle est la bonne.
|
||||
|
||||
### Inégalités
|
||||
|
||||
Lorsque l'on veut combiner des inégalités, on utilise parfois une virgule. Par exemple, si on veut dire que $i$ et $j$ sont toutes les deux comprises entre $1$ et $n$, ou pourrait écrire $1 \leq i \leq n \text{ et } 1 \leq j \leq n$, mais c'est assez long. On voit donc parfois $1 \leq i,j \leq n$. Le problème est que ceci est indifférenciable de $1 \leq i \text{ et } j \leq n$ : on ne sait pas faire la différence entre les deux sans contexte.
|
||||
|
||||
Par exemple, pour des matrices, on pourrait noter $A + B = (A_{i,j} + B_{i,j})_{1 \leq i,j \leq n}$.
|
||||
|
||||
Ou encore, pour des sommes : $\sum\limits_{1 \leq i,j \leq n} i\times j = \sum\limits_{1 \leq i \leq n} \left( \sum\limits_{1 \leq j \leq n} \Big( i \times j \Big) \right)$
|
||||
|
||||
Aussi noté $\underset{1 \leq i,j \leq n}{\sum \sum} i \times j$, pour diminuer les ambiguités.
|
||||
|
||||
Cela reste plus difficile à lire que si l'on écrit $\sum\limits_{\substack{1 \leq i \leq n\\1 \leq j \leq n}} (i\times j)$ ou même $\sum\limits_{(i,j) \in [\hspace{-0.15em}[1, n]\hspace{-.15em}]} (i\times j)$
|
||||
|
||||
## Solutions possibles
|
||||
|
||||
### Solution de la logique formelle
|
||||
En logique formelle, quand on utilise les quantificateurs, on ne met jamais de virgules, ni pour les séparer, ni pour mettre plusieurs variables à la fois.
|
||||
Par exemple, on ne noterait pas $\forall x, y \in \mathbb{R}, \exists z \in \mathbb{R}, z = x+y$, mais plutôt $\forall x \in \mathbb{R} \left( \forall y \in \mathbb{R} \left( \exists z \in \mathbb{R} \left( z = x+y \right) \right) \right)$
|
||||
|
||||
La solution consiste donc à :
|
||||
- ne jamais mettre deux variables ensemble (utiliser plusieurs quantificateurs, un par variable)
|
||||
- on peut aussi écrire $(x, y) \in \mathbb{R}^{2}$ (on a en fait qu'une seule variable : le vecteur $(x, y)$ )
|
||||
- mettre des parenthèses plutôt que des virgules (élimine toutes les ambiguïtés)
|
||||
|
||||
### Utiliser de meilleurs symboles
|
||||
La solution proposée par la logique formelle est plutôt lourde (longue à écrire et moins lisible).
|
||||
|
||||
On peut, plus simplement, utiliser des symboles spécialisés pour chacune des significations
|
||||
|
||||
- Le $;$ est un meilleur symbole pour séparer les éléments d'un vecteur
|
||||
- Dans les langues où c'est la virgule qui est l'indicateur pour les nombres décimaux, on préfère le " $;$ " dans les vecteurs
|
||||
- Pour "tel que", on préfère " $\mid$ ", " $/$ " ou bien quelquefois " $:$ "
|
||||
- **Exemple :** $\forall x \in \mathbb{R}, \exists y \in \mathbb{R} \mid y = x+1$ ou bien $\lbrace x \in \mathbb{R} : \cos(x) = 0 \rbrace$
|
||||
- Pour décrire que plusieurs variables sont dans un ensemble, on utilise $(x, y) \in \mathbb{R}^{2}$ ou bien $(x, y, z) \in \mathbb{R}^{3}$ etc.
|
||||
- On peut d'ailleurs utiliser le $;$ pour séparer les éléments : $(x;y;z)\in \mathbb{R}^{3}$
|
||||
|
||||
Ces remplacements ont plusieurs avantages :
|
||||
- ils retirent tout ambiguïté, même celles qui n'en sont pas, mais qui sont des erreurs de lecture
|
||||
- ils sont plus lisibles : avoir un symbole pour chaque signification permet au cerveau de comprendre et d'utiliser plus facilement ces symboles et de mieux les associer à leur signification
|
||||
|
||||
Ils ont cependant un problème : ils obligent parfois à être plus formel, et donc à écrire plus de choses.
|
||||
Par exemple, $\left\lbrace \frac{a}{b} \mid a, b \in \mathbb{Z}, b \neq 0 \right\rbrace$ est plus lisible que $\left\lbrace \frac{a}{b} \mid (a;b)\in \mathbb{Z}\times \mathbb{Z}^{\ast} \right\rbrace$, ou bien $\left\lbrace \frac{a}{b}\mid (a;b)\in\mathbb{Z}^{2} \wedge b\neq 0 \right\rbrace$ ou encore $\left\lbrace \frac{a}{b} \mid a \in \mathbb{Z} \wedge b \in \mathbb{Z}^{\ast} \right\rbrace$ (bien sûr, les 4 ont la même signification, et sont donc tous aussi simples, mais il faut moins d'efforts au cerveau pour comprendre les valeurs possibles de $a$ et $b$ dans le premier cas, car la notation donne sans détour les informations que l'on recherche).
|
||||
|
||||
Il semble donc que, dans certains cas, c'est au contrainre l'utilisation de notation plus abrégées, par exemple avec des virgules, qui est plus lisible.
|
||||
|
||||
### Exemples
|
||||
Voici quelques exemples d'expressions écrite en utilisant plus ou moins de virgules
|
||||
|
||||
| maximum de virgules | intermédiaire | minimum de virgules |
|
||||
| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| $\forall x, y \in \mathbb{R}, \exists a, b \in \mathbb{R}, x+y = a+b, x\neq a, y \neq b$ | $\forall (x, y) \in \mathbb{R}^{2}, \exists (a, b) \in \mathbb{R}^{2}, x+y = a+b \wedge x\neq a \wedge y \neq b$ | $\forall (x;y)\in\mathbb{R}^{2}, \exists (a;b)\in\mathbb{R}^{2}, x+y=a+b \wedge x\neq a \wedge y \neq b$ |
|
||||
| $\left\lbrace q,a,b\in\mathbb{Z}, b \neq 0, q=\frac{a}{b} \right\rbrace$ | $\left\lbrace q \mid a \in \mathbb{Z}, b \in \mathbb{Z}^{\ast}, q = \frac{a}{b} \right\rbrace$ | $\left\lbrace q \mid (a; b) \in \mathbb{Z}^{2} \wedge b \neq 0 \wedge q = \frac{a}{b} \right\rbrace$ ou bien $\left\lbrace q \mid (a; b) \in \mathbb{Z} \times \mathbb{Z}^{\ast} \wedge q = \frac{a}{b} \right\rbrace$ |
|
||||
| $\{ \overrightarrow{MN},M,N \in F \}$ | $\{ \overrightarrow{MN} \mid M, N \in F \}$ | $\{ \overrightarrow{MN} \mid (M, N) \in F^{2} \}$ |
|
||||
| $\sum\limits_{1\leq i,j \leq n} i\times j$ | $\underset{1 \leq i,j \leq n}{\sum\sum\limits}$ | $\sum\limits_{\substack{1 \leq i \leq n\\1 \leq j \leq n}} (i\times j)$ |
|
||||
|
||||
|
||||
_(des exemples supplémentaire dans les commentaires sont les bienvenus)_
|
||||
|
||||
### Quand utiliser quoi ?
|
||||
|
||||
Nous avons vu que, dans certains cas, la virgule est plus lisible car elle abrège les notations, et nous évite des réflexions inutiles sur le sens qu'apporte un symbole donné.
|
||||
|
||||
Mon avis personnel est donc :
|
||||
|
||||
- Dans un contexte où il est nécessaire d'être précis (articles, cours, énoncés, définitions...), utiliser des symboles adaptés pour chaque signification
|
||||
- notamment, le fait de ne pas utiliser de raccourcis de notation apporte un formalisme supplémentaire
|
||||
- Dans un contexte où le but est simplement de faire comprendre (solution ou correction d'un exercice, cours et énoncés simples de choses connues ou évidentes), utiliser des virgules (et autres abbréviations) peut être avantageux
|
||||
- cela allège la rédaction et rend donc la lecture et la compréhension plus rapides
|
||||
- cela permet d'écrire plus vite (notamment utile losqu'on résout un exercice)
|
||||
J'ajouterai que, avant d'utiliser des notations raccourcies, il est nécessaire de bien comprendre comment les notations formelles fonctionnent. Pour cela, écrire sans aucune abbréviations (de manière rigoureuse) est utile.
|
||||
Il vaut mieux s'habituer d'abord à une utilisation stricte, puis ensuite utiliser des raccourcis quand c'est justifié (ceci ne se limite pas aux raccourcis de notation traités ici, mais est valable pour toutes les abbréviations, comme $2\mathbb{N}$ pour $\{ 2n \mid n \in \mathbb{N} \}$, ou bien $\sum\limits_{i}v_{i}$ pour $\sum\limits_{i=0}^n v_{i} \text{ où } n \text{ est la dimension du vecteur } v$)
|
||||
|
||||
## Conclusion
|
||||
L'utilisation de la virgule dans la notation mathématique peut parfois conduire, sinon à des ambiguïtés, à des erreurs de lectures ou d'interprétation. Elle vont aussi rendre la compréhension de certaines expression plus difficile.
|
||||
|
||||
Les alternatives disponibles sont meilleures, car elles facilitent la compréhension et l'écriture des mathématiques.
|
||||
|
||||
Et en plus c'est beaucoup plus joli !
|
||||
|
9
gists/What are combinators.md
Normal file
9
gists/What are combinators.md
Normal file
@@ -0,0 +1,9 @@
|
||||
- [ ] #todo écrire
|
||||
# What are combinators
|
||||
|
||||
- definition of combinators
|
||||
- usage in CS
|
||||
- APL, haskell
|
||||
- implications on how programs can be done
|
||||
- tacit programming
|
||||
- concatenative programming
|
98
gists/cours analyse.md
Normal file
98
gists/cours analyse.md
Normal file
@@ -0,0 +1,98 @@
|
||||
---
|
||||
gists:
|
||||
- id: 92a99bc2c3393fdc0bc655384cd16e72
|
||||
url: 'https://gist.github.com/92a99bc2c3393fdc0bc655384cd16e72'
|
||||
createdAt: '2022-09-22T22:57:58Z'
|
||||
updatedAt: '2022-09-25T20:13:00Z'
|
||||
filename: cours analyse.md
|
||||
isPublic: true
|
||||
---
|
||||
|
||||
# Notations de Laudau
|
||||
|
||||
## Négligeabilité
|
||||
Soient deux fonctions $f$ et $g$, on dit que $f$ est négligeable devant $g$ en $x_{0}\in \overline{\mathbb{R}}$, et on note $f = o_{x_{0}}(g)$ :
|
||||
$f = o_{x_{0}}(g) \iff \lim\limits_{ x \to x_{0} } \frac{f(x)}{g(x)} = 0$
|
||||
|
||||
### Définitions
|
||||
#### Définition formelle
|
||||
$f = o_{x_{0}}(g)$ ssi il existe une fonction $h$ telle que :
|
||||
- $\lim\limits_{ x_{0}} g = 0$
|
||||
- $f = hg$
|
||||
|
||||
#### Définition pratique
|
||||
Pour les calculs, on utilise plutôt :
|
||||
$f = o_{x_{0}}(g) \iff \lim\limits_{ x \to x_{0} } \frac{f(x)}{g(x)} = 0$
|
||||
|
||||
### Propriétés
|
||||
|
||||
- $f = o_{x_{0}}(g) \implies f=O_{x_{0}}(g)$
|
||||
- où $O$ désigne la _domination en un point_
|
||||
- Si $f = o_{+\infty}(g)$ et $h = o_{+\infty}(g)$, alors $\lambda f+\mu h=o_{+\infty}(g)$
|
||||
- $o(1)=\varepsilon(x)$ car $\lim\limits \frac{o(1)}{1} = 0$ donc $\lim\limits$
|
||||
- $f \sim _{x_{0}} g \iff f = g+o_{x_{0}}(g)$
|
||||
|
||||
|
||||
## Domination en un point
|
||||
Soient deux fonctions $f$ et $g$ de $I \setminus \{ a \}$ à valeurs dans $\mathbb{R}$ (avec $a \in \overline{\mathbb{R}}$)
|
||||
$f$ est _dominée par $g$ en $a$_, ssi $\frac{f}{g}$ est **bornée au voisinage de $a$**.
|
||||
On note alors $f = \mathcal{O}_{a}(g)$
|
||||
|
||||
### Définition
|
||||
$f = \mathcal{O}_{a}(g) \iff \exists M \in \mathbb{R}^{+},\quad |f(x)| \leq M|g(x)| \text{au voisinage de } a$
|
||||
Soit, formellement :
|
||||
$\exists M\in\mathbb{R}^{+},\quad > \exists \alpha \in\mathbb{R}^{+*},\quad \forall x \in ]a-\alpha; a+\alpha[,\quad |f(x)| \leq M|g(x)|$
|
||||
|
||||
### Propriétés
|
||||
- $f = \mathcal{O}_{x_{0}}(g) \iff g = \mathcal{O}_{x_{0}}(f)$
|
||||
- la domination est _commutative_
|
||||
- évident, car si $\frac{f}{g}$ est bornée, alors $\frac{g}{f}$ l'est aussi
|
||||
- $\mathcal{O}_{a}(1)$ désigne toute fonction bornée au voisinage de $a$
|
||||
|
||||
|
||||
- Si $f = \mathcal{O}(g)$ et $h = \mathcal{O}(g)$, alors $\lambda f + \mu h = \mathcal{O}(g) \mid_{(\lambda, \mu)\in\mathbb{R}^{2}}$
|
||||
- stable par [[combinaison linéaire]]
|
||||
- $\mathcal{O}(\mathcal{O}(f)) = \mathcal{O}(f)$
|
||||
- formellement : si $f = \mathcal{O}(g)$ et $g = \mathcal{O}(h)$ alors $f=\mathcal{O}(h)$
|
||||
- la domination est _transitive_
|
||||
|
||||
## Fonctions équivalentes
|
||||
Soient $f$ et $g$ deux fonctions, on dit qu'elles sont _équivalentes en_ $x_{0}\in \overline{\mathbb{R}}$, et on note $f(x) \sim_{x_{0}} g(x)$ ssi :
|
||||
$\boxed{f(x)\sim _{x_{0}} \iff \lim\limits_{ x \to x_{0} } \frac{f(x)}{g(x)} = 1}$
|
||||
|
||||
|
||||
**Remarques :**
|
||||
- on écrit pas $0 \sim_{x_{0}} f$ car c'est évidamment toujours faux
|
||||
- ⚠️ $f \sim_{x_{0}} 0$ n'a pas de sens
|
||||
|
||||
#### Autre définition
|
||||
$f \sim_{x_{0}} g$ si il existe une fonction $h$ telle que :
|
||||
- $\lim\limits_{ x_{0} } h = 1$
|
||||
- $f = hg$
|
||||
**Remarques** :
|
||||
- Dans cette définition, on peut avoir $f \sim_{x_{0}}0$
|
||||
- Si $x_{0}=\pm\infty$, on peut définir $h$ seulement $b \geq x_{0}$
|
||||
|
||||
#### Propriétés
|
||||
- l'équivalence de fonctions est une relation d'équivalence
|
||||
|
||||
- $f \sim g \implies f \circ \varphi \sim g \circ \varphi$varphi
|
||||
- composition **à droite**
|
||||
- la composition à gauche **ne fonctionne pas**
|
||||
- $x+1 \sim_{+\infty} x$ alors que $e^{x+1}\not\sim_{+\infty} e^{x}$
|
||||
- la composition fonctionne avec $\ln$ :
|
||||
- $f \sim g \implies \ln(f) \sim \ln(g)$
|
||||
|
||||
- si $\lim\limits_{ x \to x_{0} }f(x) = a \mid_{a \in \mathbb{R}^{*}}$ on a : $f \sim_{x_{0}} a$
|
||||
- si $a = 0$ ou $a = \pm \infty$ alors $f \not\sim_{x_{0}} a$
|
||||
- $f \sim_{x_{0}} g \iff \alpha f \sim_{x_{0}} \alpha g \mid_{\alpha \neq 0}$
|
||||
- stable par multiplication par un scalaire
|
||||
- $f \sim g \iff f^{\alpha}\sim g^{\alpha}\mid_{\alpha \in\mathbb{R}}$
|
||||
- stable par puissance
|
||||
- $\boxed{f\sim_{x_{0}}g \iff f = g+o_{x_{0}}(g)}$
|
||||
|
||||
- Avec les polynômes : Soit $P(x) = a_{0}+a_{1}x+a_{2}x^{2}+\cdots+a_{n}x^{n}$ un polynôme de degré $n$ (donc $a_{n} \neq 0$)
|
||||
- au voisinage de $0$ : $P(x) \sim a_{0}$
|
||||
- au voisinage de $\pm\infty$ $P(x) \sim a_{n}x^{n}$
|
||||
|
||||
- [ ] #todo continuer rédaction
|
171
gists/décomposition en éléments simples.md
Normal file
171
gists/décomposition en éléments simples.md
Normal file
@@ -0,0 +1,171 @@
|
||||
---
|
||||
gists:
|
||||
- id: cd5c909adde51bbeeb31dc01e4b1fe8a
|
||||
url: 'https://gist.github.com/cd5c909adde51bbeeb31dc01e4b1fe8a'
|
||||
createdAt: '2022-10-15T17:25:21Z'
|
||||
updatedAt: '2022-11-08T14:49:37Z'
|
||||
filename: décomposition en éléments simples.md
|
||||
isPublic: false
|
||||
---
|
||||
# Introduction
|
||||
|
||||
## Fonction rationnelle
|
||||
La décomposition en élément simple sert à exprimer de façon plus pratique des _fonctions rationelles_, c'est-à-dire des fonctions qui sont une fractions de _polynômes_. Par exemple :
|
||||
$$f(x) = \frac{4x^{3}+9x - 3}{4x^{2}+7}$$
|
||||
|
||||
## But de la décomposition en éléments simples
|
||||
La décomposition en éléments simples permet d'exprimer ces fonctions sous la forme d'une somme d'un polynôme et de fractions simples (les éléments simples) contenant une constante (ou éventuellement un polynôme de degré 1) divisée par un polynôme (de degré 2 au plus).
|
||||
Pour reprendre l'exemple de la fonction $f$, sa décomposition en éléments simples est :
|
||||
$$f = x + \frac{2x}{4x^{2}+7} - \frac{3}{4x^{2}+7}$$
|
||||
C'est donc une autre forme pour _la même fonction_, qui est plus pratique, notammen pour intégrer la fonction ou pour d'autres manipulations algébriques.
|
||||
|
||||
### Terminologie
|
||||
Encore avec l'exemple précédent, $f = x + \frac{2x}{4x^{2}+7} - \frac{3}{4x^{2}+7}$, on distingue deux parties : la partie entière, et les éléments simples
|
||||
$$f = \underbrace{x}_{\text{partie entière}} + \underbrace{\frac{2x}{4x^{2}+7} - \frac{3}{4x^{2}+7}}_{\text{éléments simples}}$$
|
||||
La partie entière est un polynôme, et les éléments simples sont des fractions de polynôme de degré 1 au plus pour le nominateur, et 2 au plus pour le numérateur. Ce sont toujours des polynômes irréductibles qui sont au dénominateur (c'est le but de la décomposition : décomposer au maximum les dénominateurs) (c'est pourquoi ils peuvent être de degré 2 au maximum : les polynômes de degré 3 ou plus sont tous factorisables sur $\mathbb{R}$).
|
||||
|
||||
On note que :
|
||||
- on peut avoir plusieurs dénominateurs différent
|
||||
- par exemple, $x^{2} + \frac{3}{x+3} - \frac{5}{x^{2}+1} + \frac{1}{x}$ est une forme valide
|
||||
- Si on travaille sur $\mathbb{C}$, les dénominateurs seront toujours de degré $1$
|
||||
|
||||
# Méthode
|
||||
|
||||
## Trouver la partie entière
|
||||
La partie entière est le résultat de la division de polynômes entre le numérateur et le dénominateur de la fonction de base.
|
||||
|
||||
Par exemple, la partie entière pour $\frac{x^3 - 3x +2}{x+1}$ est $x^{2} -x -2$ car $\underbrace{(x^{2} - x-2)}_{\text{partie entière}} \underbrace{(x + 1)}_{\text{diviseur}} + \underbrace{4}_{\text{reste}}= \underbrace{x^{3}-3x+2}_{\text{dividende}}$
|
||||
Comme on l'a dit, la décomposition en éléments simples commence toujours par la partie entière.
|
||||
Une fois que l'on a la partie entière, on sait que la fonction s'écrit : $\text{partie entière} + \dfrac{\text{reste}}{\text{diviseur}}$.
|
||||
Dans l'exemple précédent, on a : $(x^{2} - x - 2) + \dfrac{4}{x+1}$
|
||||
Dans ce cas, la décomposition est finie : $\frac{4}{x+1}$ est une fraction de deux polynômes que l'on ne peut pas factoriser
|
||||
|
||||
Remarques :
|
||||
- Si le numérateur est de plus faible de gré que le dénominateur, la partie entière est 0
|
||||
- Par exemple : $\dfrac{x^{2} - 2}{x^{3}+3x^{2}-x}$ (la division donne 0 reste $x^{2}-2$)
|
||||
- La décomposition du reste est la partie la plus compliquée
|
||||
|
||||
## Décomposition du reste
|
||||
Prenons la fonction :
|
||||
$\displaystyle g(x) = \frac{3x + 1}{x ^{2} - 1}$
|
||||
|
||||
La partie entière est bien nulle car le numérateur est de degré 1 quand le dénominateur est de degré 2 (et $1 < 2$)
|
||||
|
||||
Pour décomposer cette fraction, on commence par factoriser le dénominateur. Ici, $x^{2} - 1 = (x+1) (x-1)$
|
||||
|
||||
Ensuite, on sait que la décomposition sera de la forme :
|
||||
|
||||
$$\frac{a}{x+1} + \frac{b}{x-1}$$
|
||||
c'est-à-dire une constante divisée par chacun des termes de la factorisation.
|
||||
|
||||
Encore un exemple : $\dfrac{2x+1}{x^{3}+2x^{2}+x+2}$
|
||||
Le dénominateur se factorise :
|
||||
$x^{3}+2x^{2}+x+2 = (x^{2}+1)(x+2)$ (on note que $x^{2}+1$ ne se factorise pas plus)
|
||||
On a donc une décomposition de la forme :
|
||||
$$ \frac{ax+b}{x^{2}+1} + \frac{d}{x+2} $$
|
||||
On remarque que, puisque $x^{2} + 1$ est de degré 2, on doit mettre un polynôme de degré 1 au dessus.
|
||||
|
||||
La forme générale des décompositions est en fait :
|
||||
$\displaystyle\text{partie entière} + \frac{\text{constante}}{\text{polynôme de degré 1}} + \frac{\text{constante}}{\text{polynôme de degré 1}} + \cdots + \frac{\text{polynôme de degré 1}}{\text{polynôme de degré 2}} + \frac{\text{polynôme de degré 1}}{\text{polynôme de degré 2}} + \cdots$
|
||||
Où chaque polynôme dans les fraction est un [[polynôme irréductible]] (non factorisable).
|
||||
|
||||
### cas des polynômes répétés
|
||||
|
||||
Parfois, le dénominateur avant la décomposition possède plusieurs fois le même polynôme au dénominateur (ou bien un polynôme a une certaine puissance).
|
||||
Par exemple, dans $\frac{x^{2}+1}{(x-1)^{3}(x+3)}$
|
||||
|
||||
Dans ce cas, il faut mettre chaque puissance inférieure dans un dénominateur.
|
||||
Exemple : si $(x-1)^{3}(x+3)$ est au dénominateur, les dénominateurs de la décomposition seront :
|
||||
- $(x+3)$ cas de base bu précédemment
|
||||
- $(x-1)$ également évident
|
||||
- $(x-1)^{2}$ ⚠️ il faut bien penser à mettres les puissances plus grandes
|
||||
- $(x-1)^{3}$
|
||||
|
||||
Le cas fonctionne aussi si c'est un polynôme de degré $2$ qui est au carré :
|
||||
$\displaystyle\frac{x+2}{(x^{2}+1)^{4}(x+3)} = \frac{a}{x+3} + \frac{b}{x^{2}+1} + \frac{c}{(x^{2}+1)^{2}} + \frac{d}{(x^{2}+1)^{3}}+\frac{e}{(x^{2}+1)^{4}}$
|
||||
|
||||
|
||||
### Trouver la valeur des constantes
|
||||
|
||||
###### Exemple 1
|
||||
|
||||
Prenons la décomposition suivante :
|
||||
$$ \frac{3x+1}{x^{2}-1} = \frac{a}{x+1} + \frac{b}{x-1}$$
|
||||
On ne connaît pas les valeurs de $a$ et de $b$.
|
||||
|
||||
Pour les trouver, on peut multiplier par les dénominateurs qui divisent $a$ et $b$ (ici $x+1$ et $x-1$), et donner une valeur à $x$ pour annuler des termes
|
||||
|
||||
Par exemple, si on multiplie par $x+1$, on obtient :
|
||||
|
||||
$$\frac{3x+1}{x-1} = a + \frac{b(x+1)}{x-1}$$
|
||||
Ensuite, on pose $x = -1$ pour annuler $x+1$ (par lequel on à multiplié)
|
||||
On obtient alors :
|
||||
$$1 = a + 0$$
|
||||
car le terme contenant $b$ est alors multiplié par $x+1$ soit par $0$. On sait maintenant que $a = 1$
|
||||
|
||||
On peut ensuite procéder de même avec $b$ :
|
||||
$$
|
||||
\begin{align}
|
||||
&\frac{3x+1}{x^{2}-1} = \frac{a}{x+1} + \frac{b}{x-1} \\
|
||||
&\frac{3x+1}{x+1} = \frac{a(x-1)}{x+1} + b && \text{on multiplie par } x-1 \\
|
||||
&\text{ on pose }x = 1\\&\text{ pour annuler } x -1 \\
|
||||
&2 = 0+b \\
|
||||
&b = 2
|
||||
\end{align}
|
||||
$$
|
||||
On a donc $\begin{cases}a = 1\\ b = 2\end{cases}$
|
||||
|
||||
Soit :
|
||||
|
||||
$$
|
||||
\frac{3x+1}{x^{2}-1} = \frac{1}{x+1} + \frac{2}{x-1}
|
||||
$$
|
||||
|
||||
###### Exemple 2
|
||||
Si on prends la décomposition :
|
||||
|
||||
$$
|
||||
\dfrac{2x+1}{x^{3}+2x^{2}+x+2} =
|
||||
\frac{ax+b}{x^{2}+1} + \frac{d}{x+2}
|
||||
$$
|
||||
|
||||
On peut utiliser la même méthode :
|
||||
|
||||
$$
|
||||
\begin{align}
|
||||
&\dfrac{2x+1}{x^{3}+2x^{2}+x+2} = \frac{ax+b}{x^{2}+1} + \frac{d}{x+2} \\
|
||||
& \frac{2x+1}{x^{2}+1} = \frac{(ax + b)(x+2)}{x ^{2} +1} + d && \text{on multiplie par } x+2 \\
|
||||
&\text{ on fixe } x = -2 \text{ pour annuller } x+2 \\
|
||||
& - \frac{3}{5} = 0 + d \\
|
||||
& d = -\frac{3}{5}
|
||||
\end{align}
|
||||
$$
|
||||
Si on multiplie par $x^{2} + 1$ on obtient :
|
||||
$$\frac{2x+1}{x+2} = ax+b + \frac{d(x^{2}+1)}{x+2}$$
|
||||
Problème : on remarque que l'on ne peut pas annuller $x^{2}+1$
|
||||
Mais, dans ce cas, on connaît $d$, on peut donc donner une valeur simple pour $x$, comme $x = 0$ par exemple, et injecter aussi la valeur de $d$ dans l'équation :
|
||||
$$ \frac{1}{2} = ax+b - \frac{3}{10} $$
|
||||
Alors, on peut résoudre l'équation :
|
||||
$$
|
||||
\begin{align}
|
||||
\frac{1}{2} = ax + b - \frac{3}{10} &\iff ax+b = \frac{4}{5}
|
||||
\end{align}
|
||||
$$
|
||||
Mais il faut se rappeler que l'on à fixé $x$. Cette équation doit être valide pour $x = 0$, on a donc :
|
||||
$a\times 0 + b = \frac{4}{5}$ soit $b = \frac{4}{5}$
|
||||
|
||||
On doit ensuite recommencer avec une autre valeur de $x$ pour trouver $a$.
|
||||
Pour $x = 1$ on a :
|
||||
|
||||
$1 = ax+b - \frac{2}{5}$ soit $a + b = \frac{7}{5}$ puisque $x = 0$
|
||||
|
||||
Or, on sait que $b = \frac{4}{5}$, donc $a + \frac{4}{5} = \frac{7}{5}$ soit $a = \frac{3}{5}$
|
||||
|
||||
On peut donc enfin remplacer $a$, $b$ et $d$ par leurs valeurs dans la décomposition :
|
||||
|
||||
$$\frac{2x+1}{x^{3}+2x^{2}+x + 2} = \frac{\frac{3}{5}x + \frac{4}{5}}{x^{2}+1} + \frac{\frac{3}{5}}{x+2}$$
|
||||
Et on peut simplifier un peu :
|
||||
$$\frac{2x+1}{x^{3}+2x^{2}+x + 2} = \frac{x + 4}{5(x^{2}+1)} + \frac{3}{5(x+2)}$$
|
||||
|
||||
|
||||
|
371
gists/formulaire d'analyse.md
Normal file
371
gists/formulaire d'analyse.md
Normal file
@@ -0,0 +1,371 @@
|
||||
---
|
||||
gists:
|
||||
- id: de51c8e76d38d10836647f5269334af6
|
||||
url: 'https://gist.github.com/de51c8e76d38d10836647f5269334af6'
|
||||
createdAt: '2022-09-25T20:05:29Z'
|
||||
updatedAt: '2022-09-25T20:05:29Z'
|
||||
filename: formulaire d'analyse.md
|
||||
isPublic: true
|
||||
---
|
||||
|
||||
# formulaire d'analyse
|
||||
## Rappels : Identités remarquables
|
||||
|
||||
|
||||
$(a + b)^{2} = a^{2} + 2ab + b^{2}$
|
||||
|
||||
$(a - b)^{2} = a^{2} - 2ab + b^{2}$
|
||||
|
||||
$(a + b)(a - b) = a^{2} - b^{2}$
|
||||
|
||||
|
||||
$(a + b)^{3} = a^{3} + 3a^{2}b + 3ab^{2} + b^{3}$
|
||||
|
||||
$(a - b)^{3} = a^{3} - 3a^{2}b + 3ab^{2} - b^{3}$
|
||||
|
||||
$a^{3} - b^{3} = (a - b)\left( a^{2} + ab + b^{2} \right)$
|
||||
|
||||
$a^{3} + b^{3} = (a + b)\left( a^{2} - ab + b^{2} \right)$
|
||||
|
||||
|
||||
# I Suites arithmétiques et géométriques
|
||||
|
||||
## 1) Suites arithmétiques
|
||||
|
||||
Termes de la suite ($r$ désigne la raison):
|
||||
|
||||
$u_{n+1} - u_{n} = r$
|
||||
|
||||
$u_{n} = u_{0} + nr$
|
||||
|
||||
$u_{n} = u_{p} + (n-p)r$
|
||||
|
||||
Somme des termes :
|
||||
|
||||
$\displaystyle S_{n} = \sum_{k=0}^{n}u_{k} = \dfrac{(n+1)(u_{0}+u_{n})}{2}$
|
||||
|
||||
|
||||
Cas général avec $n_{1} \leq n_{2}$ :
|
||||
|
||||
|
||||
$\displaystyle S' = \sum_{k = n_{1}}^{n_{2}}u_{k} = \frac{(nombre\ de\ termes)(premier\ terme + dernier\ terme)}{2}$
|
||||
|
||||
|
||||
Cas particulier :
|
||||
|
||||
$1 + 2 + 3\ \cdots + (n - 1) + n = \frac{n(n + 1)}{2}$
|
||||
|
||||
|
||||
|
||||
## 2) Suites géométriques
|
||||
|
||||
|
||||
On suppose que la suite est non nulle. Termes de la suite (\(q\) désigne la raison) :
|
||||
|
||||
$\dfrac{u_{n+1}}{u_{n}} = q$
|
||||
|
||||
$u_{n} = u_{0} \times q^{n}$
|
||||
|
||||
$u_{n} = u_{p}\times q^{n-p}$
|
||||
|
||||
Somme des termes :
|
||||
|
||||
$S_{n} = \sum\limits_{k=0}^{n}u_{k}$
|
||||
|
||||
- Si $q \neq 1$ : $S_{n} = u_{0}\times \frac{1-q^{n+1}}{1-q}$
|
||||
- Si $q=1$ : $S_{n}=u_{0}(n+1)$
|
||||
|
||||
Cas général avec $n_{1} \leq n_{2}$ :
|
||||
$S'_{n} = \sum\limits_{k=0}^{n}u_{k}$
|
||||
|
||||
- Si $q \neq 1$ : $S'_{n} = (\text{premier terme}) \times \frac{1- \left( q^{\text{nombre de termes}} \right)}{1-q}$
|
||||
- Si $q = 1$ : $S'_{n} = (\text{nombre de termes}) \times (\text{premier terme})$
|
||||
|
||||
|
||||
# II Formules de dérivation
|
||||
|
||||
## 1) Formules générales
|
||||
|
||||
Dans ce qui suit, $u$ et $v$ désignent deus fonctions d'une variable réelle $x$, et $k$ une constante réelle.
|
||||
|
||||
$(u+v)' = u' + v'$
|
||||
|
||||
$(ku)' = ku'$
|
||||
|
||||
$(uv)' = u'v + uv'$
|
||||
|
||||
$\left( \dfrac{u}{v} \right)' = \dfrac{u'v - uv'}{v^{2}}$
|
||||
|
||||
$(v\circ u)' = u' \times (v'\circ u)$
|
||||
|
||||
$\displaystyle(u^{-1})' = \dfrac{1}{u' \circ u^{-1}}$
|
||||
|
||||
## 2) Fonctions usuelles
|
||||
|
||||
### a) fonctions non composées
|
||||
|
||||
| Fonction $f$ | $\mathscr{D}_{f}$ | Fonction dérivée $f'$ | $\mathscr{D}_{f'}$ |
|
||||
| --------------------------------------- | --------------------------------------------------------------------------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| $k$ | $\mathbb{R}$ | 0 | $\mathbb{R}$ |
|
||||
| $x$ | $\mathbb{R}$ | $1$ | $\mathbb{R}$ |
|
||||
| $\dfrac{1}{x}$ | $\mathbb{R}^{*}$ | $-\dfrac{1}{x^{2}}$ | $\mathbb{R}^{*}$ |
|
||||
| $\sqrt{ x }$ | $\mathbb{R}^{+}$ | $\frac{1}{2\sqrt{ x }}$ | $\mathbb{R}^{+*}$ |
|
||||
| $x^{n}$ avec $n \in\mathbb{Z}$ | $\mathbb{R}$ | $nx^{n-1}$ | $\mathbb{R} \text{ si } n \geq 0, \quad \mathbb{R}^{*} \text{ si } n < 0$ |
|
||||
| $x^{\alpha}$ avec $\alpha \in\mathbb{R}$ | $\mathbb{R}^{+} \text{ si } \alpha \geq 0, \quad \mathbb{R}^{+*} \text{ si } \alpha<0$ | $\alpha x^{\alpha-1}$ | $\mathbb{R} \text{ si } n \geq 0, \quad \mathbb{R}^{*} \text{ si } \alpha < 1$
|
||||
| $\ln \mid x \mid$ | $\mathbb{R}^{+*}$ | $\dfrac{1}{x}$ | $\mathbb{R}^{+*}$ |
|
||||
| $\exp x$ | $\mathbb{R}$ | $\exp x$ | $\mathbb{R}$ |
|
||||
| $\sin x$ | $\mathbb{R}$ | $\cos x$ | $\mathbb{R}$ |
|
||||
| $\cos x$ | $\mathbb{R}$ | $-\sin x$ | $\mathbb{R}$ |
|
||||
| $\tan x$ | $\mathbb{R} \setminus \left\lbrace \dfrac{\pi}{2} + k\pi \right\rbrace$ | $1+\tan^2 x = \dfrac{1}{\cos^2 x}$ | $\mathbb{R} \setminus \left\lbrace \dfrac{\pi}{2} + k\pi \right\rbrace$ |
|
||||
| $\mathrm{sh} x$ | $\mathbb{R}$ | $\mathrm{ch} x$ | $\mathbb{R}$ |
|
||||
| $\mathrm{ch} x$ | $\mathbb{R}$ | $\mathrm{sh} x$ | $\mathbb{R}$ |
|
||||
| $\mathrm{th} x$ | $\mathbb{R}$ | $1-\mathrm{th}^2 x = \dfrac{1}{\mathrm{ch}^2 x}$ | $\mathbb{R}$ |
|
||||
|
||||
|
||||
Les dérivées des fonctions réciproques des fonctions trigonométriques et hyperboliques figurent dans la section "trigonométrie réciproque
|
||||
|
||||
### b) Fonctions composées
|
||||
|
||||
| forme de la fonction | forme de la dérivée |
|
||||
| -------------------- | ----------------------------------------------- |
|
||||
| $\dfrac{1}{u}$ | $-\dfrac{u'}{u^2}$ |
|
||||
| $\sqrt{u}$ | $\dfrac{u'}{2 \sqrt{u}}$ |
|
||||
| $u^{\alpha}$ | $\alpha u' u^{\alpha - 1}$ |
|
||||
| $\ln\mid u \mid $ | $\dfrac{u'}{u}$ |
|
||||
| $\exp u$ | $u' \times \exp u$ |
|
||||
| $\sin u$ | $u'\times \cos u$ |
|
||||
| $\cos u$ | $-u' \times \sin u$ |
|
||||
| $\tan u$ | $u' \times (1+\tan^2 u) = \dfrac{u'}{\cos^2 u}$ |
|
||||
| $\mathrm{sh} u$ | $u' \times \mathrm{ch} u$ |
|
||||
| $\mathrm{ch} u$ | $u' \times \mathrm{sh} u$ |
|
||||
| $\mathrm{th} u$ | $u' \times (1-\mathrm{th}^2 u) = \dfrac{u'}{\mathrm{ch}^2 u}$ |
|
||||
|
||||
|
||||
# III Fonctions trigonométriques et hyperboliques
|
||||
|
||||
|
||||
## 1) Fonctions trigonométriques
|
||||
|
||||
$\cos^2 x + \sin^2 x = 1$
|
||||
|
||||
$\cos(a+b) = \cos a \cos b - \sin a \sin b$
|
||||
|
||||
$\cos(a-b) = \cos a \cos b + \sin a \sin b$
|
||||
|
||||
$\sin(a+b) = \sin a\cos b + \sin b \cos a$
|
||||
|
||||
$\sin(a-b) = \sin a \cos b - \sin b \cos a$
|
||||
|
||||
$\tan(a+b) = \dfrac{\tan a + \tan b}{1-\tan a \tan b}$
|
||||
|
||||
$\tan(a-b) = \dfrac{\tan a - \tan b}{1+\tan a \tan b}$
|
||||
|
||||
$\cos a \cos b = \dfrac{1}{2} \big( \cos(a+b)+\cos(a-b) \big)$
|
||||
|
||||
$\sin a\sin b = \dfrac{1}{2} \big( \cos(a-b) - \cos(a+b) \big)$
|
||||
|
||||
$\sin a \cos b = \dfrac12 \big( \sin(a+b) + \sin(a-b) \big)$
|
||||
|
||||
$\cos a + \cos b = 2\cos \dfrac{(a+b)}{2}\cos\dfrac{(a-b)}{2}$
|
||||
|
||||
$\cos a - \cos b = -2\sin\dfrac{a+b}{2}\sin\dfrac{a-b}{2}$
|
||||
|
||||
$\sin a + \sin b = 2\sin\dfrac{a+b}{2}\cos\dfrac{a-b}{2}$
|
||||
|
||||
$\sin a - \sin b = 2\sin\dfrac{a-b}{2} \cos\dfrac{a+b}{2}$
|
||||
|
||||
$\cos(2x) =\cos ^{2}x-\sin ^{2}x \quad= 2\cos ^{2}x-1 \quad= 1-2\sin ^{2}x \quad= \frac{1-\tan ^{2}x}{1+\tan ^{2}x}$
|
||||
|
||||
|
||||
$\cos^2 x = \dfrac{1+\cos(2x)}{2}$
|
||||
|
||||
$\sin^2 x = \dfrac{1-\cos(2x)}{2}$
|
||||
|
||||
$\tan^2 x = \dfrac{1-\cos(2x)}{1+\cos(2x)}$
|
||||
|
||||
$\sin(2x) = 2\sin x\cos x \quad= 1+\tan ^{2}x$
|
||||
|
||||
$\tan(2x) = \dfrac{2\tan x}{1 - \tan^2 x}$
|
||||
|
||||
|
||||
## 2) Fonctions hyperboliques
|
||||
|
||||
$\mathrm{ch}^2 x - \mathrm{sh}^2 x = 1$
|
||||
|
||||
$\mathrm{ch}(a+b) = \mathrm{ch} (a) \;\mathrm{ch} (a) + \mathrm{sh} a \mathrm{sh} b$
|
||||
|
||||
$\mathrm{ch}(a-b) = \mathrm{ch} (a)\; \mathrm{ch} (b) - \mathrm{sh} a \mathrm{sh} b$
|
||||
|
||||
$\mathrm{sh}(a+b) = \mathrm{sh} (a)\; \mathrm{ch} (b) + \mathrm{sh} (b)\; \mathrm{ch} (a)$
|
||||
|
||||
$\mathrm{sh}(a-b) = \mathrm{sh} (a); \mathrm{ch} (b) - \mathrm{sh} (b) \mathrm{ch} (a)$
|
||||
|
||||
$\mathrm{th}(a+b) = \dfrac{\mathrm{th} a + \mathrm{th} b}{1 + \mathrm{th} (a) \mathrm{th} (b)}$
|
||||
|
||||
$\mathrm{th}(a-b) = \dfrac{\mathrm{th} a - \mathrm{th} b}{1 - \mathrm{th} (a) \mathrm{th} (b)}$
|
||||
|
||||
$\mathrm{ch} (a) \;\mathrm{ch} (b) = \dfrac12 \big( \mathrm{ch}(a+b) + \mathrm{ch}(a-b) \big)$
|
||||
|
||||
$\mathrm{sh} (a)\; \mathrm{sh} (b) = \dfrac12 \big( \mathrm{ch}(a+b) - \mathrm{ch}(a-b) \big)$
|
||||
|
||||
$\mathrm{sh} (a)\; \mathrm{ch} (b) = \dfrac12 \big( \mathrm{sh}(a+b) + \mathrm{sh}(a-b) \big)$
|
||||
|
||||
$\mathrm{ch} (a) + \mathrm{ch} (b) = 2\mathrm{ch} \dfrac{a+b}{2} \mathrm{ch} \dfrac{a-b}{2}$
|
||||
|
||||
$\mathrm{ch} (a) - \mathrm{ch} (a) = 2\mathrm{sh} \dfrac{a+b}{2}\mathrm{sh}\dfrac{a-b}{2}$
|
||||
|
||||
$\mathrm{sh} (a) + \mathrm{sh} (b) = 2\mathrm{sh} \dfrac{a+b}{2}\mathrm{ch}\dfrac{a-b}{2}$
|
||||
|
||||
$\mathrm{sh} (a) - \mathrm{sh} (b) = 2\mathrm{sh}\dfrac{a-b}{2} \mathrm{ch}\dfrac{a+b}{2}$
|
||||
|
||||
$\mathrm{ch}(2x) = \mathrm{ch} ^{2}x + \mathrm{sh} ^{2}x \quad= 2\mathrm{ch} ^{2}x - 1 \quad= 1+2\mathrm{sh} ^{2}x \quad=\frac{1+\mathrm{th} ^{2}x}{1-\mathrm{th} ^{2}x}$
|
||||
|
||||
$\mathrm{ch}^2 x = \dfrac{1+\mathrm{ch}(2x)}{2}$
|
||||
|
||||
$\mathrm{sh}^2 x = \dfrac{\mathrm{ch}(2x) - 1}{2}$
|
||||
|
||||
$\mathrm{th}^2 x = \dfrac{\mathrm{ch}(2x) - 1}{\mathrm{ch}(2x) + 1}$
|
||||
|
||||
$\mathrm{sh}(2x) = 2\mathrm{sh}(x) \mathrm{ch}(x) \quad= \frac{2\mathrm{th}(x)}{1-\mathrm{th}^{2}(x)}$
|
||||
|
||||
$\mathrm{th}(2x) = \dfrac{2\mathrm{th} x}{1+\mathrm{th}^2 x}$
|
||||
|
||||
|
||||
|
||||
## 3) Points sur le cercle trigonométrique
|
||||
|
||||
| | $-x$ | $\frac{\pi}{2}+x$ | $\frac{\pi}{2}-x$ | $\pi+x$ | $\pi-x$ | $0$ | $\frac{\pi}{6}$ | $\frac{\pi}{4}$ | $\frac{\pi}{3}$ | $\frac{\pi}{2}$ |
|
||||
| ------ | --------- | ------------------- | ------------------ | --------- | --------- | --- | ---------------------- | ---------------------- | ---------------------- | --------------- |
|
||||
| $\sin$ | $-\sin x$ | $\cos x$ | $\cos x$ | $-\sin x$ | $\sin x$ | $0$ | $\frac{1}{2}$ | $\frac{\sqrt{ 2 }}{2}$ | $\frac{\sqrt{ 3 }}{2}$ | 1 |
|
||||
| $\cos$ | $\cos x$ | $-\sin x$ | $\sin x$ | $-\cos x$ | $-\cos x$ | $1$ | $\frac{\sqrt{ 3 }}{2}$ | $\frac{\sqrt{ 2 }}{2}$ | $\frac{1}{2}$ | 0 |
|
||||
| $\tan$ | $-\tan x$ | $-\frac{1}{\tan x}$ | $\frac{1}{\tan x}$ | $\tan x$ | $-\tan x$ | $0$ | $\frac{\sqrt{ 3 }}{2}$ | $1$ | $\sqrt{ 3 }$ | |
|
||||
|
||||
|
||||
|
||||
## 4) Trigonométrie réciproque
|
||||
|
||||
$\arcsin x + \arccos x = \dfrac{\pi}{2}$
|
||||
|
||||
$\arctan x + \arctan \dfrac{1}{x} = \text{sg}(x) \times \dfrac{\pi}{2}$ avec $\mathrm{sg}(x) = 1 \text{ si } x>0$ et $\mathrm{sg}(x) = -1 \text{ si } x < 0$
|
||||
|
||||
$(\arcsin x)' = \dfrac{1}{\sqrt{1-x^2}}$
|
||||
|
||||
$(\arccos x)' = -\dfrac{1}{\sqrt{1-x^2}}$
|
||||
|
||||
$(\arctan x)' = \dfrac{1}{1+x^2}$
|
||||
|
||||
$(\arcsin u)' = \dfrac{u'}{\sqrt{1-u^2}}$
|
||||
|
||||
$(\arccos u)' = -\dfrac{u'}{\sqrt{1-u^2}}$
|
||||
|
||||
$(\arctan u)' = \dfrac{u'}{1+u^2}$
|
||||
|
||||
|
||||
\columnbreak
|
||||
## 5) Trigonométrie hyperbolique réciproque
|
||||
|
||||
$\arg\mathrm{sh} x = \ln \left( x + \sqrt{ 1+x^2 } \right)$
|
||||
|
||||
$\arg\mathrm{ch} x = \ln \left( x + \sqrt{ 1 - x^2 } \right)$
|
||||
|
||||
$\arg\mathrm{th} x = \dfrac12 \ln \left( \dfrac{1+x}{1-x} \right)$
|
||||
|
||||
$(\arg\mathrm{sh} x)' = \dfrac{1}{\sqrt{ x^2 + 1 }}$
|
||||
|
||||
$(\arg\mathrm{ch} x)' = \dfrac{1}{\sqrt{x^2 - 1}}$
|
||||
|
||||
$(\arg\mathrm{th} x)' = \dfrac{1}{1-x^2}$
|
||||
|
||||
$(\arg\mathrm{sh} u)' = \dfrac{u'}{\sqrt{ u^2 + 1 }}$
|
||||
|
||||
$(\arg\mathrm{ch} u)' = \dfrac{u'}{\sqrt{ u^2 - 1}}$
|
||||
|
||||
$(\arg\mathrm{th} u)' = \dfrac{u'}{1 - u^2}$
|
||||
|
||||
|
||||
|
||||
# IV Limites usuelles
|
||||
|
||||
## 1) Comportement à l'infini
|
||||
|
||||
$\displaystyle\lim_{x\to+\infty} \ln x = +\infty$
|
||||
|
||||
$\displaystyle\lim_{x\to+\infty}\exp x = +\infty$
|
||||
|
||||
$\displaystyle\lim_{x\to-\infty}\exp x = 0$
|
||||
|
||||
|
||||
|
||||
Si $\alpha > 0$, $\displaystyle\lim_{x\to+\infty}x^{\alpha} = +\infty$
|
||||
|
||||
Si $\alpha < 0$, $\displaystyle\lim_{x\to+\infty}x^{\alpha} = 0$
|
||||
|
||||
Si $\alpha > 0$, $\displaystyle\lim_{x\to+\infty}\dfrac{\exp x}{x^\alpha} = \lim_{x\to+\infty}\dfrac{e^x}{x^\alpha} = +\infty$
|
||||
|
||||
Si $\alpha > 0$, $\displaystyle\lim_{x\to+\infty}x^\alpha\times\exp(-x) = \lim_{x\to+\infty}x^\alpha e^{-x} = 0$
|
||||
|
||||
|
||||
|
||||
## 2) Comportement à l'origine
|
||||
|
||||
|
||||
$\displaystyle\lim_{x \rightarrow 0} \ln x = + \infty$
|
||||
|
||||
Si $\alpha > 0$, $\displaystyle\lim_{x \rightarrow 0^+} x^\alpha = +\infty$
|
||||
|
||||
Si $\alpha < 0$, $\displaystyle\lim_{x \rightarrow 0^+} x^\alpha = +\infty$
|
||||
|
||||
Si $\alpha > 0$, $\displaystyle\lim_{x \rightarrow 0^+} \left( x^\alpha \ln x \right) = 0$ propriété de croissance comparée
|
||||
|
||||
$\displaystyle \lim_{x \rightarrow 0} \dfrac{\ln (1+x)}{x} = 1$
|
||||
|
||||
$\displaystyle \lim_{x \to 0} \dfrac{e^x - 1}{x} = 1$
|
||||
|
||||
$\displaystyle \lim_{x \rightarrow 0} \dfrac{\sin x}x = 1$
|
||||
|
||||
|
||||
|
||||
|
||||
# V Formules d'intégration
|
||||
|
||||
## 1) Primitives usuelles
|
||||
|
||||
|
||||
Si $\alpha \neq -1$, $\displaystyle \int x^\alpha \mathrm{d} x = \dfrac{1}{\alpha + 1}x^{\alpha +1} + \text{cte}$
|
||||
|
||||
$\displaystyle\int \dfrac{1}x \mathrm{d} x = \ln |x|+\text{cte}$
|
||||
|
||||
$\displaystyle\int \dfrac{1}{x+\alpha }\mathrm{d} x = \ln |x+\alpha |+\text{cte}$
|
||||
|
||||
$\displaystyle\int e^x \mathrm{d} x = e^x + \text{cte}$
|
||||
|
||||
Si $\alpha > 0$ et $\alpha \neq 1$, $\displaystyle\int \alpha^x \mathrm{d} x= \dfrac{1}{\ln \alpha }\times \alpha^x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \cos x \mathrm{d} x = \sin x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \sin x \mathrm{d} x = -\cos x + \text{cte}$
|
||||
Si $\alpha \neq 0$, $\displaystyle\int \cos \alpha x \mathrm{d} x = \dfrac{1}{\alpha} \sin \alpha x + \text{cte}$
|
||||
|
||||
Si $\alpha \neq 0$, $\displaystyle\int \sin \alpha x \mathrm{d} x = \dfrac{1}{\alpha} \cos \alpha x + \text{cte}$
|
||||
|
||||
|
||||
$\displaystyle \int \dfrac{1}{\cos ^2 x} \mathrm{d} x = \tan x + \text{cte}$
|
||||
|
||||
$\displaystyle\int 1 + \tan ^2 x \mathrm{d} x = \tan x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \dfrac{1}{\sin ^2 x} \mathrm{d} x = -\mathrm{cotan} x + \text{cte} \quad= -\dfrac{1}{\tan x} + \text{cte}$
|
||||
|
||||
$\displaystyle\int \dfrac{1}{1+x^2} \mathrm{d} x = \arctan x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \mathrm{ch} x \mathrm{d} x = \mathrm{sh} x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \mathrm{sh} x \mathrm{d} x = \mathrm{ch} x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \dfrac{1}{\mathrm{ch}^2 x} \mathrm{d} x = \mathrm{th} x + \text{cte}$
|
||||
|
||||
$\displaystyle\int \dfrac{1}{\mathrm{sh}^2 x} \mathrm{d} x = \dfrac{1}{\mathrm{th} x} + \text{cte}$
|
||||
|
||||
|
||||
|
||||
|
||||
|
70
gists/how i see the unix command line.md
Normal file
70
gists/how i see the unix command line.md
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
gists:
|
||||
- id: 88e29cabd85f710168ad836523fde914
|
||||
url: 'https://gist.github.com/88e29cabd85f710168ad836523fde914'
|
||||
createdAt: '2022-09-28T08:37:00Z'
|
||||
updatedAt: '2022-11-28T09:57:09Z'
|
||||
filename: how i see the unix command line.md
|
||||
isPublic: true
|
||||
---
|
||||
# How I see the UNIX command line
|
||||
|
||||
**Important :** When I use the term "command line", I really mean "UNIX command line", or at least "UNIX-like command line" (including Linux's, macOS's, BSD's command lines, bash, zsh, csh, or any command line that works like them).
|
||||
|
||||
## The command line
|
||||
|
||||
The [command line](https://en.wikipedia.org/wiki/Command-line_interface) is well known to be a very powerful tool for programmers : it allows the user to combine quickly, easily and in rich ways basically any utility, and therefore to automate and customize a lot of actions. It also permits a full control over what you do on your machine, since you can basically do anything.
|
||||
|
||||
But it is also a rough interface for anyone used to today's beautiful IDEs, where any action is one or two clicks of your mouse away, and where everything is "_plug and play_". Such smoothed interfaces exchange ability to automate, customize and combine things for ease of doing things that are already programmed. This is a serious advantage, especially for beginners, that can focus on what is really important (actually learning a programming language). And don't get me wrong : some IDEs have incredible features (like the ones from JetBrains), but even if they do _these things very well_, you are not able to change anything and to automate as much as you could with command line. The philosophy is different, for different use cases and different persons.
|
||||
|
||||
So here is a quick recap of why you should use the command line :
|
||||
- _control_ over basically everything (fine grain control over files, programs etc.)
|
||||
- _combine_ all the programs you have (all mechanisms to compose tools)
|
||||
- _automate_ the actions you often do or that are annoying or long (kind of the result of _control_ of _combine_)
|
||||
And here is what the graphical apps are good at :
|
||||
- ease of learning (just click buttons)
|
||||
- quickly find how to do something (just click buttons)
|
||||
- have some proprietary ~~garbage~~ features like in the JetBrains IDEs
|
||||
|
||||
## The good, the bad and the ugly
|
||||
|
||||
Now that we know what are the powers of the command line, we can easily find what tools are actually good or bad for it.
|
||||
|
||||
Just once more, the command line is about _control_, _combine_ and _automate_.
|
||||
So any good utility that integrates with the command line should have these properties, right ?
|
||||
- _control_ : especially, fine control over specific things
|
||||
- _combine_ : ability to integrate with other apps via the different standard mechanisms
|
||||
- _automate_ : again a mix of _control_ and _combine_
|
||||
|
||||
Obvious examples of good apps for the command line are the ones that are often shipped with it : basic ones like `cat`, `ls` (that are almost mandatory for using the command line), or more advanced ones like `grep`, `sort`, `uniq`, `xargs`, `find`, `sed`, `awk`...
|
||||
All of these have common properties : they can combine with other apps in many ways, they do a specific thing and allow fine control of that specific action.
|
||||
|
||||
You also have "bad" command line apps : apps that don't combine well with other ones, or that don't allow any accurate control of what they do.
|
||||
|
||||
I added another section : the "ugly" apps, in my mind these are the apps that integrate quite well, but that feel "hacky", or weird, because they are _just working_, but not with proper foundations, neither with any stability nor robustness : they are tools that are just a little more complex than an automation, but not as well-made as real apps. We all have faced at least one of these apps, that often do something very specific, and they work, but you know that they probably won't resist a lot of updates on anything. I don't put them in the class of "bad" apps, because they can be perfectly integrated in the command line interface, but i call them "ugly" because they obviously should be avoided (it is always a problem to rely on dangerous software, so you may search for better alternatives, or create one yourself). These include some scripts that you may write yourself, and in which you don't put a lot of care because they are only for a precise purpose, and not made to be shared or used in production.
|
||||
|
||||
The usual way to describe what a "good" app should do is the _UNIX philosophy_ : in Unix, apps should "do one thing, but do it well", and then be able to connect with other tools. What I call "bad tools" are either tools that do too many things (but that is not always a problem), and most importantly that don't connect well with other apps. The main nuance is that I don't consider that apps should do one thing. I see how it is of good for an app to do only one thing, but I also use apps that do a couple of things, do them well, and still connects well and allows accurate control. One example is [tmux](https://github.com/tmux/tmux/wiki) : it is a _terminal_ multiplexer (allows you to make tabs and split windows inside a command line), but it also saves your session, meaning that if, for instance, your ssh connection is cut, nothing is lost (not even what is printed on screen). So `tmux` does two tings, but they work well together (when you connect to your command line, you just have to type `tmux attach` to get back to your previous session), and most importantly, you have a plenty of options and ways to connect it with other tools, that make it a very helpful app for working in the terminal. So really, for me, "good" UNIX apps are not limited to doing one thing. What I understand of that "rule" is that it is made so you don't create an "ugly" app, and so users can learn how to use the app, and not be overwhelmed by the amount of things your app does (a good example of that would be a user searching for a new app, while an app he's already using does it perfectly, but he isn't aware of that, because the app does too many things).
|
||||
|
||||
### The case of Emacs
|
||||
|
||||
[Emacs](https://www.gnu.org/software/emacs/) is an app that runs in the command line (but now also has a GUI). It is an extremely powerful programming environment, that basically allows you to do almost everything in Emacs (very advanced coding environment, calendar, browser, note-taking, emails, music...).
|
||||
Emacs started as an advanced text editor, but with the years it grew and got to the point where it can embed basically everything.
|
||||
|
||||
According to the UNIX philosophy of "do one thing, but do it well", Emacs should be considered as a "bad" command line app, right ?
|
||||
|
||||
The special thing with Emacs is that the environment is not anymore the command line, but Emacs itself. Emacs has _control_, _composition_ and _automatization_, but not _with other UNIX apps_ : it has these between Emacs packages. So, for example, in Emacs, you can easily connect your email client, your calendar, your note-taking system etc.
|
||||
|
||||
What is important to understand is that this philosophy of _control_, _composition_ and _automatization_ is not at all limited to the command line (even if it is one of the places where it is the most important, and therefore the most implemented) : it can be realized anywhere to make any environment better.
|
||||
|
||||
|
||||
## Conclusion
|
||||
|
||||
For me, what is important is that you use an environment that allows you to fulfill your goals.
|
||||
Some of these goals may be to automate actions you often do, or to have a fine-grained control over how your tools behave.
|
||||
There are other considerations, for instance the time it takes to master the said environment (obviously, it depends on what you want to do with it), or if it is able to handle a particular feature that you need.
|
||||
Other environments have other ways to reach their goals.
|
||||
|
||||
|
||||
> **Disclaimer :**
|
||||
> In this article, I try to explain what I understand of some concepts and tools, in the hope that it will help some people to understand and use them.
|
||||
> It is widely based on my personal opinions. You may not agree with me, and if so I would be pleased to know your opinion !
|
55
gists/notions de base en maths.md
Normal file
55
gists/notions de base en maths.md
Normal file
@@ -0,0 +1,55 @@
|
||||
---
|
||||
gists:
|
||||
- id: 976cef2d994763cd454f2b461fa699c0
|
||||
url: 'https://gist.github.com/976cef2d994763cd454f2b461fa699c0'
|
||||
createdAt: '2022-09-23T09:52:01Z'
|
||||
updatedAt: '2022-09-23T10:27:58Z'
|
||||
filename: notions de base en maths.md
|
||||
isPublic: true
|
||||
---
|
||||
|
||||
|
||||
# Ensembles
|
||||
|
||||
## Notations
|
||||
|
||||
- **Esembles par extension**
|
||||
- $\lbrace x \in E \mid \mathscr{P}(x) \rbrace$ est l'ensemble des $x$ dans $E$ _tels que_ la propriété $\mathscr{P}(x)$ est respectée
|
||||
- Exemples :
|
||||
- $\left\lbrace x \in \mathbb{N} \mid \frac{x}{2} \in \mathbb{N} \right\rbrace$ : les nombres pairs
|
||||
- $\lbrace x \in \mathbb{R} \mid x^{2}=x+1 \rbrace$ : solutions de $x^{2}=x+1$ sur $\mathbb{R}$
|
||||
- $\left\lbrace x \in \mathbb{R} | \exists (n, k)\in \mathbb{Z}, x = \frac{n}{k} \right\rbrace$ ensemble des _rationnels_ : $\mathbb{Q}$
|
||||
|
||||
- $A \subset B$ : $A$ est _contenu_ dans $B$
|
||||
- $\forall x \in A, x \in B$
|
||||
- $A \subsetneq B$ : $A$ est _strictement mais différent de_ $B$
|
||||
- $\forall x \in A, x \in B$ et $\exists x \in A, x \not\in B$
|
||||
|
||||
- $A \cup B$ : $A$ _union_ $B$ : éléments qui sont dans $A$ _ou_ dans $B$
|
||||
- $\lbrace x | x \in A \text{ ou } x \in B \rbrace$
|
||||
- $A \cap B$ : $A$ _inter_ $B$ : éléments qui sont dans $A$ _et_ dans $B$
|
||||
- $\lbrace x | x \in A \text{ et } x \in B \rbrace$
|
||||
|
||||
|
||||
## Ensembles classiques
|
||||
- $\mathbb{N}$ : les entiers naturels : $\lbrace 0, 1, 2, 3, \dots \rbrace$
|
||||
- $\mathbb{Z}$ : les entiers _relatifs_ : $\lbrace \dots, -2, -1, 0, 1, 2, \dots \rbrace$
|
||||
- $\mathbb{Q}$ : les nombres _rationels_ (qui exprimables comme des fractions) : $\left\lbrace\dots \frac{1}{2}, \frac{1}{3}, \frac{137}{42}, 4, -\frac{1}{12}, \dots \right\rbrace$
|
||||
- $\mathbb{R}$ : les nombres _réels_ (tous les nombres classiques) : $\left\lbrace \dots, \frac{\sqrt{ 3 }}{2}, \pi, 42, \frac{73}{67}, \dots \right\rbrace$
|
||||
- $\mathbb{C}$ : les nombres _complexes_ (avec $i^{2}=-1$) : $\left\lbrace \dots -2, i+3, \sqrt{ 2 }i+\frac{1}{3}, i-\pi, 73i+42\dots \right\rbrace$
|
||||
|
||||
### Nombres complexes
|
||||
|
||||
#### Définition
|
||||
On remarque que l'équation $x^{2}=-1$ n'a pas de solutions sur $\mathbb{R}$.
|
||||
On créé un nombre $i$ solution de cette équation : $i^{2}=-1$
|
||||
Ce nombre n'est donc pas un réel : on l'appelle le nombre _imaginaire_.
|
||||
|
||||
l'ensemble des nombres _imaginaires_ (_imaginaires purs_), $\mathbb{I}$, est donc l'ensemble des $k\times i$ où $k \in \mathbb{R}$ : $\mathbb{I} = \lbrace k\times i \mid k \in \mathbb{R} \rbrace$
|
||||
|
||||
L'ensemble des nombres _complexes_ regroupe $\mathbb{R}$, $\mathbb{I}$, et tous les nombres "composites" de la forme $a+ib$ où $a$ et $b$ sont réels.
|
||||
Donc : $\mathbb{R} = \lbrace a+ib\mid(a,b)\in\mathbb{R}^{2} \rbrace$
|
||||
|
||||
**Note:** $\mathbb{R}\subset\mathbb{C}$ et $\mathbb{I}\subset \mathbb{C}$ mais bien sûr $\mathbb{C} \neq \mathbb{R} \cup \mathbb{I}$ puisque, par exemple $i + 1$ est dans $\mathbb{C}$ mais ni dans $\mathbb{R}$, ni dans $\mathbb{I}$.
|
||||
|
||||
#### Propriétés
|
118
gists/python list to markdown table.md
Normal file
118
gists/python list to markdown table.md
Normal file
@@ -0,0 +1,118 @@
|
||||
---
|
||||
gists:
|
||||
- id: 955b166f4a286ed427f667cb21d57bfd
|
||||
url: 'https://gist.github.com/955b166f4a286ed427f667cb21d57bfd'
|
||||
createdAt: '2023-03-08T15:40:39Z'
|
||||
updatedAt: '2023-03-08T15:40:39Z'
|
||||
filename: python list to markdown table.md
|
||||
isPublic: true
|
||||
---
|
||||
|
||||
Here is a function to convert a python list of lists into a markdown formatted table:
|
||||
|
||||
```python
|
||||
def make_markdown_table(array, align: str =None):
|
||||
"""
|
||||
Args:
|
||||
array: The array to make into a table. Mush be a rectangular array
|
||||
(constant width and height).
|
||||
align: The alignment of the cells : 'left', 'center' or 'right'.
|
||||
"""
|
||||
# make sure every elements are strings
|
||||
array = [[str(elt) for elt in line] for line in array]
|
||||
# get the width of each column
|
||||
widths = [max(len(line[i]) for line in array) for i in range(len(array[0]))]
|
||||
# make every width at least 3 colmuns, because the separator needs it
|
||||
widths = [max(w, 3) for w in widths]
|
||||
# center text according to the widths
|
||||
array = [[elt.center(w) for elt, w in zip(line, widths)] for line in array]
|
||||
|
||||
# separate the header and the body
|
||||
array_head, *array_body = array
|
||||
|
||||
header = '| ' + ' | '.join(array_head) + ' |'
|
||||
|
||||
# alignment of the cells
|
||||
align = str(align).lower() # make sure `align` is a lowercase string
|
||||
if align == 'none':
|
||||
# we are just setting the position of the : in the table.
|
||||
# here there are none
|
||||
border_left = '| '
|
||||
border_center = ' | '
|
||||
border_right = ' |'
|
||||
elif align == 'center':
|
||||
border_left = '|:'
|
||||
border_center = ':|:'
|
||||
border_right = ':|'
|
||||
elif align == 'left':
|
||||
border_left = '|:'
|
||||
border_center = ' |:'
|
||||
border_right = ' |'
|
||||
elif align == 'right':
|
||||
border_left = '| '
|
||||
border_center = ':| '
|
||||
border_right = ':|'
|
||||
else:
|
||||
raise ValueError("align must be 'left', 'right' or 'center'.")
|
||||
separator = border_left + border_center.join(['-'*w for w in widths]) + border_right
|
||||
|
||||
# body of the table
|
||||
body = [''] * len(array) # empty string list that we fill after
|
||||
for idx, line in enumerate(array):
|
||||
# for each line, change the body at the correct index
|
||||
body[idx] = '| ' + ' | '.join(line) + ' |'
|
||||
body = '\n'.join(body)
|
||||
|
||||
return header + '\n' + separator + '\n' + body
|
||||
|
||||
|
||||
T = [["hi", "hello", "How do you do ?"],
|
||||
[1, 1, 1],
|
||||
[2, 12345678, 2],
|
||||
['contents', 42, 73]]
|
||||
|
||||
print(make_markdown_table(T, align='left'))
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```python
|
||||
>>> T = [["hi", "hello", "How do you do ?"],
|
||||
... [1, 1, 1],
|
||||
... [2, 12345678, 2],
|
||||
... ['contents', 42, 73]]
|
||||
>>> print(make_markdown_table(T))
|
||||
| hi | hello | How do you do ? |
|
||||
| -------- | -------- | --------------- |
|
||||
| hi | hello | How do you do ? |
|
||||
| 1 | 1 | 1 |
|
||||
| 2 | 12345678 | 2 |
|
||||
| contents | 42 | 73 |
|
||||
|
||||
>>> print(make_markdown_table(T, align='left'))
|
||||
| hi | hello | How do you do ? |
|
||||
|:-------- |:-------- |:--------------- |
|
||||
| hi | hello | How do you do ? |
|
||||
| 1 | 1 | 1 |
|
||||
| 2 | 12345678 | 2 |
|
||||
| contents | 42 | 73 |
|
||||
|
||||
>>> print(make_markdown_table(T, align='center'))
|
||||
| hi | hello | How do you do ? |
|
||||
|:--------:|:--------:|:---------------:|
|
||||
| hi | hello | How do you do ? |
|
||||
| 1 | 1 | 1 |
|
||||
| 2 | 12345678 | 2 |
|
||||
| contents | 42 | 73 |
|
||||
|
||||
>>> print(make_markdown_table(T, align='right'))
|
||||
| hi | hello | How do you do ? |
|
||||
| --------:| --------:| ---------------:|
|
||||
| hi | hello | How do you do ? |
|
||||
| 1 | 1 | 1 |
|
||||
| 2 | 12345678 | 2 |
|
||||
| contents | 42 | 73 |
|
||||
|
||||
```
|
61
gists/vx.json
Normal file
61
gists/vx.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"created_time": "2022-09-27T07:23:41Z",
|
||||
"files": [
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2022-09-27T07:23:41Z",
|
||||
"id": "556",
|
||||
"modified_time": "2022-09-27T07:23:41Z",
|
||||
"name": "Contre, l'usage abusif, de la virgule, dans la notation, mathématique.md",
|
||||
"signature": "2828216226410571005",
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2022-09-27T07:23:41Z",
|
||||
"id": "557",
|
||||
"modified_time": "2022-09-27T07:23:41Z",
|
||||
"name": "cours analyse.md",
|
||||
"signature": "5695930812951864573",
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2022-09-27T07:23:41Z",
|
||||
"id": "558",
|
||||
"modified_time": "2022-09-27T07:23:41Z",
|
||||
"name": "formulaire d'analyse.md",
|
||||
"signature": "8779273090127537405",
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2022-09-27T07:23:41Z",
|
||||
"id": "559",
|
||||
"modified_time": "2022-09-27T07:23:41Z",
|
||||
"name": "my gists.md",
|
||||
"signature": "7239845219400852733",
|
||||
"tags": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachment_folder": "",
|
||||
"created_time": "2022-09-27T07:23:41Z",
|
||||
"id": "560",
|
||||
"modified_time": "2022-09-27T07:23:41Z",
|
||||
"name": "notions de base en maths.md",
|
||||
"signature": "1002191673422423293",
|
||||
"tags": [
|
||||
]
|
||||
}
|
||||
],
|
||||
"folders": [
|
||||
],
|
||||
"id": "555",
|
||||
"modified_time": "2022-09-27T07:23:41Z",
|
||||
"signature": "2180031070747141373",
|
||||
"version": 3
|
||||
}
|
Reference in New Issue
Block a user