In [1]:
# Use this format in all notebooks
%matplotlib inline
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
kwargs = {'linewidth' : 2.5}
font = {'weight' : 'normal',
        'size'   : 16}
matplotlib.rc('font', **font)
In [2]:
xs = np.linspace(-2, 2, 1000)
ys = xs**2
plt.figure(1, figsize=(6, 6))
plt.title('Epigraph of a convex function')
plt.plot(xs, ys, **kwargs)
plt.ylim(0, 4)
plt.fill_between(xs, ys+10, ys, color='#eeeeee')
plt.savefig('figures/lecture1-epigraph.pdf')
In [3]:
plt.figure(2, figsize=(6, 6))
plt.title('First-order Taylor approximation')
plt.plot(xs, ys, **kwargs)
plt.plot(xs, xs - 0.25, **kwargs)
plt.savefig('figures/lecture1-taylor.pdf')