from IPython.display import HTML
from ipywidgets import interact
%matplotlib inline
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
The raw code for this IPython notebook is by default hidden for easier reading.
To toggle on/off the raw code, click <a href="javascript:code_toggle()">here</a>.''')
HTML("""
<p><a href="https://commons.wikimedia.org/wiki/File:Cube_Watermelons_for_Sale_in_Munich,_Germany_Market.jpg#/media/File:Cube_Watermelons_for_Sale_in_Munich,_Germany_Market.jpg"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Cube_Watermelons_for_Sale_in_Munich%2C_Germany_Market.jpg/1200px-Cube_Watermelons_for_Sale_in_Munich%2C_Germany_Market.jpg" alt="Cube Watermelons for Sale in Munich, Germany Market.jpg" style="width: 50vw"></a><br>By Francisco Antunes - <a rel="nofollow" class="external free" href="https://www.flickr.com/photos/francisco-antunes/3815031014/">https://www.flickr.com/photos/francisco-antunes/3815031014/</a>, <a href="https://creativecommons.org/licenses/by/2.0" title="Creative Commons Attribution 2.0">CC BY 2.0</a>, <a href="https://commons.wikimedia.org/w/index.php?curid=70106531">Link</a></p>
""")
By Francisco Antunes - https://www.flickr.com/photos/francisco-antunes/3815031014/, CC BY 2.0, Link
Pour un espace vectoriel normé donné $(E, ||.||)$, on définit la boule unité par $B(0,1) = \{x \in E, ||x|| <1 \}.$ L'ensemble qu'on obtient dépend bien sûr de la norme sur $E$.
Dans le cas du plan $\mathbb{R}^2$, on utilise usuellement la norme euclidienne donnée par $$\|(x_1,x_2)\|_2 = \sqrt{|x_1|^2+|x_2|^2}$$, et la boule qu'on obtient a effectivement une tête de boule:
HTML("""
<video width="640" controls>
<source src="Norme2.mp4" type="video/mp4">
</video>
""")
On peut aussi munir $\mathbb{R}^2$ de la norme 1: $$\|(x_1,x_2)\|_1 = |x_1|+|x_2|$$ ou de la norme infini: $$\|(x_1,x_2)\|_\infty = \max\{|x_1|^2+|x_2|^2\}$$
Les boules correspondantes n'ont pas la même tête !
HTML("""
<video width="640" controls>
<source src="Norme1.mp4" type="video/mp4">
</video>
""")
HTML("""
<video width="640" controls>
<source src="NormeInf.mp4" type="video/mp4">
</video>
""")
Toutefois, ces normes ont quand même un lien entre elles: elles sont équivalentes.
Deux normes $\|.\|_a$ et $\|.\|_b$ sur $E$ sont équivalentes s'il existe des constantes positives $c,\ C$ telles que pour tout $x$, $c\|x\|_a \leq \|x\|_b \leq C\|x\|_a)$. L'équivalence des normes peut se réécrire en termes d'inclusion de boules: l'inégalité précédente se réécrit $$B_a(0,\frac1C) \subset B_b(0,1) \subset B_a(0, \frac1c) $$
En l'occurrence, on a $$\dfrac12 ||x||_1 \leq ||x||_\infty \leq ||x||_2 \leq \sqrt{2} ||x||_\infty\leq \sqrt{2} ||x||_1$$ donc $$||x||_1 \leq \frac{1}{\sqrt{2}} \Rightarrow ||x||_\infty\leq \frac{1}{\sqrt{2}}\Rightarrow ||x||_2 \leq 1 \Rightarrow ||x||_\infty \leq 1 \Rightarrow ||x||_1 \leq 2$$ c'est-à-dire $$B_1(0, \frac{1}{\sqrt{2}}) \subset B_\infty(0, \frac{1}{\sqrt{2}})\subset B_2(0,1) \subset B_\infty(0,1)\subset B_1(0,2):$$
HTML("""
<video width="640" controls>
<source src="inclusionBoules.mp4" type="video/mp4">
</video>
""")
En fait, pour tout $p \geq 1$, on peut définir une norme sur $\mathbb{R}^2$ par $$ \|x\|_p = (|x_1|^p + |x_2|^p)^{\frac1p} $$ Les boules unités associées passent continûment du losange de la norme 1, à la sphère usuelle, et tendent à se rapprocher du carré de la norme infinie quand $p$ devient grand:
import ipywidgets as widgets
from IPython.display import display
import numpy as np
import matplotlib.pyplot as plt
from math import pi
p_min = 1 # the minimial value of the parameter a
p_max = 30 # the maximal value of the parameter a
p_init = 2 # the value of the parameter a to be used initially, when the graph is created
x = np.linspace(-1, 1, 500)
#fig,ax = plt.subplots(1,figsize=(6,6))
def update_plot(p):
fig = plt.figure()
ax=fig.gca()
ax.clear()
plt.xlim(-1.5, 1.5)
plt.ylim(-1.5, 1.5)
plt.plot(x, (1-abs(x)**p)**(1/p), 'r')
plt.plot(x, -(1-abs(x)**p)**(1/p), 'r')
plt.show()
#plt.title("Boule unité pour la norme p")
interact ( update_plot, p = (1,30,0.2) )
#p=widgets.FloatSlider(min=p_min, max=p_max,value=p_init,description="p")
#widgets.interactive(update_plot, p=p)
interactive(children=(FloatSlider(value=15.0, description='p', max=30.0, min=1.0, step=0.2), Output()), _dom_c…
<function __main__.update_plot(p)>
Remarquons que quand $p$ est plus petit que 1, on n'obtient pas une norme, car l'inégalité triangulaire n'est plus vérifiée. Par exemple pour $p=\frac12$, en prenant $e_1=(1,0)$, $e_2=(0,1)$, on a $$\|e_1+e_2\|_{\frac12} = (\sqrt{1}+\sqrt{1})^2 = 4$$ et $$\|e_1\|_\frac12+\|e_2\|_\frac12 = (\sqrt{0}+\sqrt{1})^2+ (\sqrt{1}+\sqrt{0})^2 =2 $$ donc $\|e_1+e_2\|_{\frac12} > \|e_1\|_\frac12+\|e_2\|_\frac12$. Ceci se traduit par des boules concaves:
import ipywidgets as widgets
from IPython.display import display
import numpy as np
import matplotlib.pyplot as plt
from math import pi
p_min = 0.1 # the minimial value of the parameter a
p_max = 1 # the maximal value of the parameter a
p_init = 0.5 # the value of the parameter a to be used initially, when the graph is created
x = np.linspace(-1, 1, 500)
#fig,ax = plt.subplots(1,figsize=(6,6))
def update_plot(p):
fig = plt.figure()
ax=fig.gca()
ax.clear()
plt.xlim(-1.5, 1.5)
plt.ylim(-1.5, 1.5)
plt.plot(x, (1-abs(x)**p)**(1/p), 'r')
plt.plot(x, -(1-abs(x)**p)**(1/p), 'r')
plt.show()
#plt.title("Boule unité pour la norme p")
interact ( update_plot, p = (0.1,1,0.02) )
#p=widgets.FloatSlider(min=p_min, max=p_max,value=p_init,description="p")
#widgets.interactive(update_plot, p=p)
interactive(children=(FloatSlider(value=0.54, description='p', max=1.0, min=0.1, step=0.02), Output()), _dom_c…
<function __main__.update_plot(p)>
Dans $\mathbb{R}^3$, on peut de même définir, pour tout $p\geq 1$, une norme p donnée par $$\|x\|_p = (|x_1|^p + |x_2|^p + |x_3|^p)^{\frac1p} $$. Les plus usuelles sont la norme 1, la norme 2 (ou euclidienne), et la norme infinie, qui donnent des boules comme ci-dessous:
HTML("""
<video width="640" controls>
<source src="Norme1dim3.mp4" type="video/mp4">
</video>
""")
HTML("""
<video width="640" controls>
<source src="Norme2dim3.mp4" type="video/mp4">
</video>
""")
HTML("""
<video width="640" controls>
<source src="NormeInfdim3.mp4" type="video/mp4">
</video>
""")
On peut, comme précédemment, faire varier $p$:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.widgets import Slider # import the Slider widget
import ipywidgets as widgets
from IPython.display import display
import numpy as np
p_min = 1 # the minimial value of the parameter a
p_max = 5 # the maximal value of the parameter a
p_init = 2
n=10
def update(p):
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.clear()
x=[]
y=[]
for i in np.linspace(-1,1,2*n):
for j in np.linspace(-(1-np.abs(i)**p)**(1/p), (1-np.abs(i)**p)**(1/p),n):
x=x+[i]
y=y+[j]
x=np.array(x)
y=np.array(y)
z1=(np.abs(1-np.abs(x)**p-np.abs(y)**p))**(1/p)
z2=-z1
ax.plot_trisurf(x, y, z1, linewidth=0.2, antialiased=True, color='b')
ax.plot_trisurf(x, y, z2, linewidth=0.2, antialiased=True, color='b')
fig.canvas.draw_idle()
plt.show()
#p=widgets.FloatSlider(min=p_min, max=p_max,value=p_init,description="p")
#widgets.interactive(update, p=p)
interact ( update, p = (1,10,1) )
interactive(children=(IntSlider(value=5, description='p', max=10, min=1), Output()), _dom_classes=('widget-int…
<function __main__.update(p)>
et on a, comme précédemment, l'équivalence des normes, traduite en inclusion de boules:
HTML("""
<video width="640" controls>
<source src="Inclusion.mp4" type="video/mp4">
</video>
""")