lipschitz.py

#
# Plot of a Lipschitz condition for a stupid system :-)
# Vincent Legat - 2018
# Ecole Polytechnique de Louvain
#


import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['toolbar'] = 'None'
plt.rcParams['figure.facecolor'] = 'silver'

from numpy import *

#
# -1- Plot de la zone garantie de convergence
#

plt.figure("Lispchitz criterium")
x,y = meshgrid(linspace(-2,2,1000),linspace(-2,2,1000))

dfdx = abs(x)+0.5
dfdy = abs(x/4) + abs(-y+1)
gain = maximum(dfdx,dfdy)
plt.contourf(x,y,gain,arange(0,1.1,0.1),cmap=plt.cm.jet_r)
plt.contour(x,y,gain,arange(0,1.1,0.1),colors='black',linewidths=0.5)

ax = plt.gca()
ax.yaxis.grid(color='gray',linestyle='dashed')
ax.xaxis.grid(color='gray',linestyle='dashed')
plt.xticks(arange(-2,3,1))
plt.yticks(arange(-2,3,1))

plt.show()