Conic Sections#
Revised
19 Feb 2023
Imports & Environment#
Show code cell source
# %load imports.py
import numpy as np
import numpy.random as npr
import pandas as pd
import matplotlib as mpl
mpl.rcParams['lines.color'] = 'k'
mpl.rcParams['axes.prop_cycle'] = mpl.cycler('color',['k'])
from matplotlib import cm
from matplotlib.patches import Ellipse
import matplotlib.pyplot as plt
plt.style.use('ggplot');
from matplotlib.ticker import LinearLocator
import plotly
import plotly.express as px
import plotly.graph_objects as go
import sympy as sy
from sympy.geometry import Point, Line
from sympy import (diff,
dsolve,
Eq,
expand,
factor,
Function,
init_printing,
Integer,
Integral,
integrate,
latex,
limit,
Matrix,
Poly,
Rational,
solve,
Symbol,
symbols)
S =Symbol
ss=symbols
x,y,z,t,u,v=ss(names='x y z t u v')
init_printing(use_unicode=True)
import math
import numexpr
from datetime import datetime as d
import locale as l
import platform as p
import sys as s
pad = 20
print(f"{'Executed'.upper():<{pad}}: {d.now()}")
print()
print(f"{'Platform' :<{pad}}: "
f"{p.mac_ver()[0]} | "
f"{p.system()} | "
f"{p.release()} | "
f"{p.machine()}")
print(f"{'' :<{pad}}: {l.getpreferredencoding()}")
print()
print(f"{'Python' :<{pad}}: {s.version}")
print(f"{'' :<{pad}}: {s.version_info}")
print(f"{'' :<{pad}}: {p.python_implementation()}")
print()
print(f"{'Matplotlib' :<{pad}}: {mpl.__version__}")
print(f"{'Numexpr' :<{pad}}: {numexpr.__version__}")
print(f"{'NumPy' :<{pad}}: {np.__version__}")
print(f"{'Pandas' :<{pad}}: {pd.__version__}")
print(f"{'Plotly' :<{pad}}: {plotly.__version__}")
print(f"{'SymPy' :<{pad}}: {sy.__version__}")
# print()
# from pprint import PrettyPrinter
# pp = PrettyPrinter(indent=2)
# pp.pprint([name for name in dir()
# if name[0] != '_'
# and name not in ['In', 'Out', 'exit', 'get_ipython', 'quit']])
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 46
43 init_printing(use_unicode=True)
45 import math
---> 46 import numexpr
48 from datetime import datetime as d
49 import locale as l
ModuleNotFoundError: No module named 'numexpr'
Auxiliary code#
x=np.linspace(-9,9,400)
y=np.linspace(-9,9,400)
x,y=np.meshgrid(x,y)
def axes ():
plt.axhline(0,alpha=0.1)
plt.axvline(0,alpha=0.1)
Linear Equation#
linear in
linear in two variables
Standard Form of a Line
Point-Slope Form
Slope-Intercept Form
General quadratic in a single variable#
General form of a quadratic equation in a single variable
General quadratic in two variables#
General form of a quadratic equation in two variables
with cross terms
without cross terms
Conics#
Parabola
Ellipse
Hyperbola
Parabola#
Standard Form of a Parabola#
Start with the general quadratic in two variables
or
Complete the square
where
Standard Form of a Parabola
as a function
find the vertex via differentiation to see where the graph has a horizontal tangent line
complete the square in the squared variable to find the vertex
plug the vertex into the equation
factor the equation to find any roots
a parabola has an axis of symmetry through its vertex; therefore, any point on one side of the parabola is informative of a point on the other side
when the squared variable is y, then the graph is a shifted and stretched version of
in this case, the parabola always has an x-intercept and the roots of the parabola are y-intercepts
[EXAMPLE]
vertex
y-intercept
roots (x-intercepts)
by symmetry
Show code cell source
s=9
x=np.linspace(-s,s,1001);
y=2*x**2-4*x-6
plt.axes().set_aspect(1);
plt.xlim((-s,s));
plt.xticks(np.arange(-s,s+1,1));
plt.ylim((-s,s));
plt.yticks(np.arange(-s,s+1,1));
plt.plot(x,y);
plt.scatter(0,0,color='black');
plt.axvline(x=1,color='black');
plt.scatter( 1,-8);
plt.scatter( 0,-6);
plt.scatter( 2,-6);
plt.scatter(-1, 0);
plt.scatter( 3, 0);
[EXAMPLE]
vertex
x-intercept
roots (y-intercepts)
by symmetry
Show code cell source
s=6
y=np.linspace(-s,s,1001);
x=y**2-4*y+5
plt.axes().set_aspect(1);
plt.xlim((-s,s));
plt.xticks(np.arange(-s,s+1,1));
plt.ylim((-s,s));
plt.yticks(np.arange(-s,s+1,1));
plt.plot(x,y);
plt.scatter(0,0,color='black');
plt.axhline(y=2,color='black');
plt.scatter(1,2);
plt.scatter(5,0);
plt.scatter(5,4);
focus
directrix
Example in standard position#
Non Standard Form of a Parabola#
Start with the general quadratic in two variables
Example in non standard position#
Ellipse#
Standard Form of an Ellipse#
Start with the general quadratic in two variables
Complete the square in each variable separately to transform the general equation into the standard form of an ellipse.
Standard Form of an Ellipse
an ellipse centered at the origin
given the center of an ellipse
plug the x-coordinate of the center of the ellipse into the equation of the ellipse to find the y-coordinates of two points on the ellipse
plut the y-coordinate of the center of the ellipse into the equation of the ellipse to find the x-coordinates of two points on the ellipse
if
Unit Circle (radius
center
[CASE]
Point (or Circle of radius
[EXAMPLE]
the only way for two square values to sum to zero is for each square itself to be equal to zero
[CASE]
DNE (or Circle with negative radius
[EXAMPLE]
two square values cannot sum to a negative number
[EXAMPLE]
center
Show code cell source
h,k,a,b=0,3,1,2
fig,ax=plt.subplots(subplot_kw={'aspect':'equal'});
ax.add_artist(
Ellipse(xy =(h,k),
width =2*a,
height=2*b)
);
plt.scatter(0,0,color='black');
ax.set_xlim(h-a-1,h+a+1);
ax.set_ylim(k-b-1,k+b+1);
plt.scatter( 0,1);
plt.scatter( 0,5);
plt.scatter(-1,3);
plt.scatter( 1,3);
[EXAMPLE]
Show code cell source
h,k,a,b=3,-1,2,3
fig,ax=plt.subplots(subplot_kw={'aspect':'equal'});
ax.add_artist(
Ellipse(xy =(h,k),
width =2*a,
height=2*b)
);
plt.scatter(0,0,color='black');
ax.set_xlim(h-a-1,h+a+1);
ax.set_ylim(k-b-1,k+b+1);
# plt.scatter();
# plt.scatter();
# plt.scatter();
# plt.scatter();
Nonstandard ellipse#
Start with the general quadratic in two variables
Hyperbola#
Start with the general quadratic in two variables
Standard Forms of a Hyperbola
shifted to the right
shifted up
Hyperbolas are not single, connected curves; but two symmetric branches. The point halfway beween them is
The graph of the hyperbola will approach the asymptotes as the graph goes to infinity.
Finding the equations of the asymptotes
standard form
set the left hand side equal to zero
simplify the equation via factoring or square roots
equations of two lines
Find the center
Plugin the x and y coordinates of the center into the equation, separately, and solve for the other coordinate
One of these coordinates will yield a pair of points; the other will not have solutions
These points determine whether the hyperbola opens horizontally or vertically
First, graph the asymptotes
[SPECIAL CASE]
The graph is just a pair of crossed lines
[EXAMPLE]
eccentricity
foci
directrices
asymptotes
Show code cell source
a = b = 1
# eccentricity
e = np.sqrt(1 + b**2/a**2)
# foci
plt.plot(a*e,0,'.',-a*e,0,'.');
# directrices
plt.axvline( a/e);
plt.axvline(-a/e);
# asymptotes
plt.plot(x[0,:], b/a*x[0,:],'--');
plt.plot(x[0,:],-b/a*x[0,:],'--');
eq = x**2/a**2 - y**2/b**2
axes()
plt.contour(x,y,eq,[1],colors='k',alpha=0.1);
Show code cell source
a = b = 1
# eccentricity
e = np.sqrt(1 + b**2/a**2)
# foci
plt.plot(0,a*e,'.',0,-a*e,'.');
# directrices
plt.axhline( a/e);
plt.axhline(-a/e);
# asymptotes
plt.plot(x[0,:], b/a*x[0,:],'--');
plt.plot(x[0,:],-b/a*x[0,:],'--');
eq = y**2/b**2 - x**2/a**2
axes()
plt.contour(x,y,eq,[1],colors='k',alpha=0.1);
[EXAMPLE]
Determine the center
Determine the intercepts
Determine the equations of the asymptotes
Show code cell source
a,b,h,k=4,2,0,0
# eccentricity
e = np.sqrt(1 + b**2/a**2)
# foci
plt.plot(a*e,0,'.',-a*e,0,'.');
# directrices
plt.axvline( a/e);
plt.axvline(-a/e);
# asymptotes
plt.plot(x[0,:], b/a*x[0,:],'--');
plt.plot(x[0,:],-b/a*x[0,:],'--');
eq = x**2/a**2 - y**2/b**2
axes()
plt.contour(x,y,eq,[1],colors='k',alpha=0.1);
[EXAMPLE]
Determine the center
Determine the intercepts
Show code cell source
a,b,h,k=1,1,-1,3
# eccentricity
e = np.sqrt(1 + b**2/a**2)
# foci
plt.plot(0,a*e,'.',0,-a*e,'.');
# directrices
plt.axhline( a/e);
plt.axhline(-a/e);
# asymptotes
plt.plot(x[0,:], b/a*x[0,:],'--');
plt.plot(x[0,:],-b/a*x[0,:],'--');
eq = (y-k)**2/b**2 - (x-h)**2/a**2
axes()
plt.contour(x,y,eq,[1],colors='k',alpha=0.1);
Nonstandard hyperbola#
The general quadratic in two variables
Resources#
[P] Mas, Modesto. (21 Apr 2016). “Drawing conics in matplotlib”.