In [1]:
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display,Math
In [2]:
display(Math('4p(y-k) = (x-h)^2'))
display(Math('y = \\frac{1}{4p}(x-h)^2 + k'))
$\displaystyle 4p(y-k) = (x-h)^2$
$\displaystyle y = \frac{1}{4p}(x-h)^2 + k$
In [3]:
a = 1 #1/4y
h = 1
k = -2
n = 100

x = np.linspace(h-5,h+5,n)
y = a*(x-h)**2 + k

plt.plot(x,y)
plt.grid()
plt.axis('square')
plt.show()
In [4]:
plt.plot(y,x)
plt.grid()
plt.axis('square')
plt.show()
In [5]:
display(Math('\\text Vertex: (h,k)'))
display(Math('\\text Focus: (h,k + p)'))
display(Math('\\text Directrix: y = k - p'))
$\displaystyle \text Vertex: (h,k)$
$\displaystyle \text Focus: (h,k + p)$
$\displaystyle \text Directrix: y = k - p$

Exercise

In [6]:
a = 1 #1/4p = a, a = a4p, 1/4a
p = 1/4*a
h = 1
k = -2
n = 100

x = np.linspace(h-2,h+2,n)
y = a*(x-h)**2 + k

plt.plot(x,y)

plt.plot(h,k,'ro',label='Vertex')
plt.plot(h,k+p,'go',label='Focus')

d = k-p
plt.plot(x[[0,-1]],[d,d],label='Directrix')

plt.grid()
plt.legend()
#plt.axis('square')
plt.show()