import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display,Math
display(Math('4p(y-k) = (x-h)^2'))
display(Math('y = \\frac{1}{4p}(x-h)^2 + k'))
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()
plt.plot(y,x)
plt.grid()
plt.axis('square')
plt.show()
display(Math('\\text Vertex: (h,k)'))
display(Math('\\text Focus: (h,k + p)'))
display(Math('\\text Directrix: y = k - p'))
Exercise
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()