Section 15.4 Points on Quadratic Curves

Subsection 15.4.1 Transforming conic sections
Although it's being removed from the curriculum nowadays, students in high school mathematics or first-year college calculus often learn how to use matrices to transform one conic section to another of the same type.Example 15.4.2.
We can get from the circle
xxxxxxxxxx
var('x,y')
layout=[['a','b'],['c','d'],['output']]) (
def _(a=1,b=1,c=1,d=3,output=11):
viewsize=ceil(math.sqrt(output)+1)
g(x,y)=a*x^2+(b+c)*x*y+d*y^2
plot1 = implicit_plot(g-output, (x,-viewsize,viewsize), (y,-viewsize,viewsize), plot_points = 200)
grid_pts = [[i,j] for i in [-viewsize..viewsize] for j in [-viewsize..viewsize]]
plot_grid_pts = points(grid_pts,rgbcolor=(0,0,0),pointsize=2)
lattice_pts = [coords for coords in grid_pts if (a*coords[0]^2 + (b+c)*coords[0]*coords[1] + d*coords[1]^2 == output)]
plot_lattice_pts = points(lattice_pts, rgbcolor = (0,0,1),pointsize=20)
show(plot1+plot_grid_pts+plot_lattice_pts, figsize = [5,5], xmin = -viewsize, xmax = viewsize, ymin = -viewsize, ymax = viewsize, aspect_ratio=1)
pretty_print(html("Integer lattice points on $%sx^2+%sxy+%sy^2=%s$"%(a,b+c,d,output)))
Subsection 15.4.2 More conic sections
Let's trace back to looking for integer points on a given curve. Assuming that ellipses are doable by simply counting, what is next? The parabola comes to mind. A straightforward parabola could look likeExample 15.4.3.
If
Example 15.4.4.
If

xxxxxxxxxx
def _(m=1,n=2):
viewsize=3*n
f(x)=(m/n)*x^2
plot1 = plot(f,-viewsize,viewsize)
grid_pts = [[i,j] for i in [-viewsize..viewsize] for j in [0..viewsize^2*(m/n)]]
plot_grid_pts = points(grid_pts,rgbcolor=(0,0,0),pointsize=2)
lattice_pts = [coords for coords in grid_pts if (m*coords[0]^2==n*coords[1])]
plot_lattice_pts = points(lattice_pts, rgbcolor = (0,0,1),pointsize=20)
show(plot1+plot_grid_pts+plot_lattice_pts, figsize = [5,5], xmin = -viewsize, xmax = viewsize, ymin = -1, ymax = (m/n)*viewsize^2)
