\chapter{Bonus: B\'ezout's theorem}
In this chapter we discuss B\'ezout's theorem.
It makes precise the idea that two degree $d$ and $e$
curves in $\CP^2$ should intersect at ``exactly'' $de$ points.
(We work in projective space so e.g.\ any two lines intersect.)

\section{Non-radical ideals}
\prototype{Tangent to the parabola.}
We need to account for multiplicities.
So we will whenever possible work with homogeneous ideals $I$,
rather than varieties $V$,
because we want to allow the possibility that $I$ is not radical.
Let's see how we might do so.

For a first example, suppose we intersect $y=x^2$ with the line $y=1$;
or more accurately, in projective coordinates of $\CP^2$,
the parabola $zy=x^2$ and $y=z$.
The intersection of the ideals is
\[ (zy-x^2, y-z) = (x^2-z^2, y-z) \subseteq \CC[x,y,z]. \]
So this corresponds to having two points;
this gives two intersection points: $(1:1:1)$ and $(-1:1:1)$.
Here is a picture of the two varieties in the affine $z=1$ chart:
\begin{center}
	\begin{asy}
		import graph;
		size(4cm);
		real f(real x) { return x*x-1; }
		graph.xaxis("$\mathcal V(y-z)$", red);
		draw(graph(f,-2,2,operator ..), blue, Arrows);
		label("$\mathcal V(zy-x^2)$", (1.4, f(1.4)), dir(15), blue);
		label("$\mathbb{CP}^2$", (2,3), dir(45));
		dotfactor *= 1.5;
		dot(dir(0), heavygreen);
		dot(dir(180), heavygreen);
	\end{asy}
\end{center}
That's fine, but now suppose we intersect $zy=x^2$ with the line $x=0$ instead.
Then we instead get a ``double point'':
\begin{center}
	\begin{asy}
		import graph;
		size(4cm);
		real f(real x) { return x*x; }
		graph.xaxis("$\mathcal V(y)$", red);
		draw(graph(f,-2,2,operator ..), blue, Arrows);
		label("$\mathcal V(zy-x^2)$", (1.4, f(1.4)), dir(15), blue);
		label("$\mathbb{CP}^2$", (2,3), dir(45));
		dotfactor *= 1.5;
		dot(origin, heavygreen);
	\end{asy}
\end{center}
The corresponding ideal is this time
\[ (zy-x^2, y) = (x^2,y) \subseteq \CC[x,y,z]. \]
This ideal is \emph{not} radical,
and when we take $\sqrt{(x^2,y)} = (x,y)$ we get the ideal
which corresponds to a single projective point $(0:0:1)$ of $\CP^2$.
This is why we work with ideals rather than varieties:
we need to tell the difference between $(x^2,y)$ and $(x,y)$.

\section{Hilbert functions of finitely many points}
\prototype{The Hilbert function attached to the double point $(x^2,y)$
	is eventually the constant $2$.}
\begin{definition}
	Given a nonempty projective variety $V$, there is a unique
	radical ideal $I$ such that $V = \Vp(I)$.
	In this chapter we denote it by $\II(V)$.
	For an empty variety we set $\II(\varnothing) = (1)$,
	rather than choosing the irrelevant ideal.
\end{definition}
\begin{definition}
	Let $I \subseteq \CC[x_0, \dots, x_n]$ be homogeneous.
	We define the \vocab{Hilbert function} of $I$,
	denoted $h_I : \ZZ_{\ge 0} \to \ZZ_{\ge 0}$ by
	\[ h_I(d) = \dim_{\CC} \left( \CC[x_0, \dots, x_n]/I \right)^d \]
	i.e.\ $h_I(d)$ is the dimension of the $d$th graded part of
	$\CC[x_0, \dots, x_n] / I$.
\end{definition}
\begin{definition}
	If $V$ is a projective variety, we set $h_V = h_{\II(V)}$,
	where $I$ is the \emph{radical} ideal satisfying $V = \Vp(I)$.
	If $V = \varnothing$, we choose $I = (1)$.
\end{definition}
\begin{example}[Examples of Hilbert functions in zero dimensions]
	\label{ex:hilbert_zero}
	For concreteness, let us use $\CP^2$.
	\begin{enumerate}[(a)]
		\ii If $V$ is the single point $(0:0:1)$,
		with ideal $\II(V) = (x,y)$,
		then
		\[ \CC[x,y,z] / (x,y) \cong \CC[z]
		\cong \CC \oplus z\CC \oplus z^2\CC \oplus z^3\CC \dots \]
		which has dimension $1$ in all degrees.
		Consequently, we have \[ h_I(d) \equiv 1. \]
		\ii Now suppose we use the ``double point'' ideal $I = (x^2,y)$.
		This time, we have
		\begin{align*}
			\CC[x,y,z] / (x^2,y)
			&\cong \CC[z] \oplus x\CC[z] \\
			&\cong \CC \oplus (x\CC \oplus z\CC) \oplus (xz\CC \oplus z^2\CC)
			\oplus (xz^2\CC \oplus z^3\CC) \oplus\dots.
		\end{align*}
		From this we deduce that
		\[
			h_I(d) =
			\begin{cases}
				2 & d = 1, 2, 3, \dots \\
				1 & d = 0.
			\end{cases}
		\]
		\ii Let's now take the variety $V = \{(1:1:1), (-1:1:1)\}$
		consisting of two points, with $\II(V) = (x^2-z^2, y-z)$. Then
		\begin{align*}
			\CC[x,y,z] / (x^2-z^2,y-z)
			&\cong \CC[x,z] / (x^2-z^2) \\
			&\cong \CC[z] \oplus x\CC[z].
		\end{align*}
		So this example has the same Hilbert function as the previous one.
	\end{enumerate}
\end{example}
\begin{abuse}
	I'm abusing the isomorphism symbol
	$\CC[z] \cong \CC \oplus z\CC \oplus z^2\CC$ and similarly
	in other examples.
	This is an isomorphism only on the level of $\CC$-vector spaces.
	However, in computing Hilbert functions of other examples
	I will continue using this abuse of notation.
\end{abuse}
\begin{example}
	[Hilbert functions for empty varieties]
	Suppose $I \subsetneq \CC[x_0, \dots, x_n]$
	is an ideal, possibly not radical
	but such that \[ \Vp(I) = \varnothing \]
	hence $\sqrt I = (x_0, \dots, x_n)$ is the irrelevant ideal.
	Thus there are integers $d_i$ for $i=0,\dots,n$ such that
	$x_i^{d_i} \in I$ for every $i$; consequently, $h_I(d) = 0$
	for any $d > d_0 + \dots + d_n$.
	We summarize this by saying that
	\[ h_I(d) = 0 \text{ for all $d \gg 0$}. \]
\end{example}
Here the notation $d\gg 0$ means ``all sufficiently large $d$''.

From these examples we see that if $I$ is an ideal,
then the Hilbert function appears to eventually be constant,
with the desired constant equal to the size of $\Vp(I)$,
``with multiplicity'' in the case that $I$ is not radical.

Let's prove this.
Before proceeding we briefly remind the reader of short exact sequences:
a sequence of maps of $0 \to V \injto W \surjto X \to 0$
is one such that the $\img(V \injto W) = \ker(W \surjto X)$
(and of course the maps $V \injto W$ and $W \surjto X$ are
injective and surjective).
If $V$, $W$, $X$ are finite-dimensional vector spaces over $\CC$
this implies that $\dim W = \dim V + \dim X$.

\begin{proposition}
	[Hilbert functions of $I \cap J$ and $I+J$]
	Let $I$ and $J$ be homogeneous ideals in $\CC[x_0, \dots, x_n]$.
	Then \[ h_{I \cap J} + h_{I+J} = h_I + h_J. \]
\end{proposition}
\begin{proof}
	Consider any $d \ge 0$.
	Let $S = \CC[x_0, \dots, x_n]$ for brevity.
	Then
	\begin{center}
	\begin{tikzcd}
		0 \ar[r]
			& \left[ S / (I \cap J) \right]^d \ar[r, hook]
			& \left[ S / I \right]^d \oplus \left[ S / J \right]^d \ar[r, two heads]
			& \left[ S / (I+J) \right]^d \ar[r] & 0 \\
		& f \ar[r, mapsto] & (f,f) \\
		&& (f,g) \ar[r, mapsto] & f-g
	\end{tikzcd}
	\end{center}
	is a short exact sequence of vector spaces.
	Therefore, for every $d \ge 0$ we have that
	\[
		\dim \left[ S / I \right]^d \oplus \left[ S / J \right]^d
		= \dim \left[ S / (I \cap J) \right]^d
		+ \dim \left[ S / (I+J) \right]^d
	\]
	which gives the conclusion.
\end{proof}
\begin{example}
	[Hilbert function of two points in $\CP^1$]
	In $\CP^1$ with coordinate ring $\CC[s,t]$,
	consider $I = (s)$ the ideal corresponding to the point $(0:1)$
	and $J = (t)$ the ideal corresponding to the point $(1:0)$.
	Then $I \cap J = (st)$ is the ideal corresponding
	to the disjoint union of these two points,
	while $I+J = (s,t)$ is the irrelevant ideal.
	Consequently $h_{I+J}(d) = 0$ for $d \gg 0$.
	Therefore, we get
	\[ h_{I \cap J}(d) = h_I(d) + h_J(d) \text{ for $d \gg 0$} \]
	so the Hilbert function of a two-point projective variety
	is the constant $2$ for $d \gg 0$.
\end{example}

This example illustrates the content of the main result:
\begin{theorem}
	[Hilbert functions of zero-dimensional varieties]
	Let $V$ be a projective variety consisting of $m$ points
	(where $m \ge 0$ is an integer).
	Then \[ h_V(d) = m \text{ for $d \gg 0$}. \]
\end{theorem}
\begin{proof}
	We already did $m = 0$, so assume $m \ge 1$.
	Let $I = \II(V)$ and for $k=1,\dots,m$
	let $I_k = \II(\text{$k$th point of $V$})$.
	\begin{exercise}
		Show that $h_{I_k} (d) = 1$ for every $d$.
		(Modify \Cref{ex:hilbert_zero}(a).)
		\label{ques:hilbert_always_one}
	\end{exercise}

	Hence we can proceed by induction on $m \ge 2$,
	with the base case $m=1$ already done above.
	For the inductive step,
	we use the projective analogues of \Cref{thm:many_aff_variety}.
	We know that $h_{I_1 \cap \dots \cap I_{m-1}}(d) = m-1$ for $d \gg 0$
	(this is the first $m-1$ points;
	note that $I_1 \cap \dots \cap I_{m-1}$ is radical).
	To add in the $m$th point we note that
	\[
		h_{I_1 \cap \dots \cap I_m}(d)
		= h_{I_1 \cap \dots I_{m-1}}(d) + h_{I_m}(d)
		- h_J(d)
	\]
	where $J = (I_1 \cap \dots \cap I_{m-1}) + I_m$.
	The ideal $J$ may not be radical, but satisfies $\Vp(J) = \varnothing$
	by an earlier example, hence $h_J = 0$ for $d \gg 0$.
	This completes the proof.
\end{proof}
In exactly the same way we can prove that:
\begin{corollary}[$h_I$ eventually constant when $\dim \Vp(I) = 0$]
	Let $I$ be an ideal, not necessarily radical,
	such that $\Vp(I)$ consists of finitely many points.
	Then the Hilbert $h_I$ is eventually constant.
\end{corollary}
\begin{proof}
	Induction on the number of points, $m \ge 1$.
	The base case $m = 1$ was essentially done in \Cref{ex:hilbert_zero}(b)
	and \Cref{ques:hilbert_always_one}.
	The inductive step is literally the same as in the proof above,
	except no fuss about radical ideals.
\end{proof}

\section{Hilbert polynomials}
So far we have only talked about Hilbert functions
of zero-dimensional varieties, and showed that
they are eventually constant.
Let's look at some more examples.
\begin{example}
	[Hilbert function of $\CP^n$]
	The Hilbert function of $\CP^n$ is
	\[ h_{\CP^n}(d) = \binom{d+n}{n}
	= \frac{1}{n!} (d+n)(d+n-1) \dots (d+1) \]
	by a ``balls and urns'' argument.
	This is a polynomial of degree $n$.
\end{example}
\begin{example}
	[Hilbert function of the parabola]
	Consider the parabola $zy-x^2$ in $\CP^2$
	with coordinates $\CC[x,y,z]$.
	Then
	\[ \CC[x,y,z] / (zy-x^2) \cong \CC[y,z] \oplus x\CC[y,z]. \]
	A combinatorial computation gives that
	\begin{align*}
		h_{(zy-x^2)}(0) &= 1 & \text{Basis $1$} \\
		h_{(zy-x^2)}(1) &= 3 & \text{Basis $x,y,z$} \\
		h_{(zy-x^2)}(2) &= 5 & \text{Basis $xy$, $xz$, $y^2$, $yz$, $z^2$}.
	\end{align*}
	We thus in fact see that $h_{(zy-x^2)}(d) = 2d-1$.
\end{example}

In fact, this behavior of ``eventually polynomial'' always works.
\begin{theorem}
	[Hilbert polynomial]
	Let $I \subseteq \CC[x_0, \dots, x_n]$ be a homogeneous ideal,
	not necessarily radical. Then
	\begin{enumerate}[(a)]
		\ii There exists a polynomial $\chi_I$ such that
		$h_I(d) = \chi_I(d)$ for all $d \gg 0$.
		\ii $\deg \chi_I = \dim\Vp(I)$ (if $\Vp(I) = \varnothing$
		then $\chi_I = 0$).
		\ii The polynomial $m! \cdot \chi_I$ has integer coefficients.
	\end{enumerate}
\end{theorem}
\begin{proof}
	The base case was addressed in the previous section.

	For the inductive step, consider $\Vp(I)$ with dimension $m$.
	Consider a hyperplane $H$ such that no irreducible
	component of $\Vp(I)$ is contained inside $H$
	(we quote this fact without proof, as it is geometrically obvious,
	but the last time I tried to write the proof I messed up).
	For simplicity, assume WLOG that $H = \Vp(x_0)$.

	Let $S = \CC[x_0, \dots, x_n]$ again.
	Now, consider the short exact sequence
	\begin{center}
	\begin{tikzcd}
		0 \ar[r]
			& \left[ S/I \right]^{d-1} \ar[r, hook]
			& \left[ S / I \right]^d \ar[r, two heads]
			& \left[ S / (I+(f)) \right]^d \ar[r] & 0 \\
		& f \ar[r, mapsto] & f \cdot x_0 \\
		&& f \ar[r, mapsto] & f.
	\end{tikzcd}
	\end{center}
	(The injectivity of the first map follows from the assumption
	about irreducible components of $\Vp(I)$.)
	Now exactness implies that
	\[ h_I(d) - h_I(d-1) = h_{I + (x_0)}(d). \]
	The last term geometrically corresponds to $\Vp(I) \cap H$;
	it has dimension $m-1$, so by the inductive hypothesis
	we know that
	\[ h_I(d) - h_I(d-1)
		= \frac{c_0 d^{m-1} + c_1 d^{m-2} + \dots + c_{m-1}}{(m-1)!}
		\qquad d \gg 0 \]
	for some integers $c_0$, \dots, $c_{m-1}$.
	Then we are done by the theory of
	\textbf{finite differences} of polynomials.
\end{proof}

\section{B\'ezout's theorem}

\begin{definition}
	We call $\chi_I$ the \vocab{Hilbert polynomial} of $I$.
	If $\chi_I$ is nonzero, we call the leading coefficient of
	$m! \chi_I$ the \vocab{degree} of $I$, which is an integer,
	denoted $\deg I$.

	Of course for projective varieties $V$ we let $h_V = h_{\II(V)}$.
\end{definition}

\begin{example}[Examples of degrees]
	\listhack
	\begin{enumerate}[(a)]
		\ii If $V$ is a finite set of $n \ge 1$ points, it has degree $n$.
		\ii If $I$ corresponds to a double point, it has degree $2$.
		\ii $\CP^n$ has degree $1$.
		\ii The parabola has degree $2$.
	\end{enumerate}
\end{example}

Now, you might guess that if $f$ is a homogeneous quadratic polynomial
then the degree of the principal ideal $(f)$ is $2$, and so on.
(Thus for example we expect a circle to have degree $2$.)
This is true:

\begin{theorem}
	[B\'ezout's theorem]
	Let $I$ be a homogeneous ideal of $\CC[x_0, \dots, x_n]$,
	such that $\dim \Vp(I) \ge 1$.
	Let $f \in \CC[x_0, \dots, x_n]$ be a homogeneous polynomial of degree $k$
	which does not vanish on any irreducible component of $\Vp(I)$.
	Then
	\[ \deg\left( I + (f) \right) = k \deg I. \]
\end{theorem}
\begin{proof}
	Let $S = \CC[x_0, \dots, x_n]$ again.
	This time the exact sequence is
	\begin{center}
	\begin{tikzcd}
		0 \ar[r]
			& \left[ S/I \right]^{d-k} \ar[r, hook]
			& \left[ S / I \right]^d \ar[r, two heads]
			& \left[ S / (I+(f)) \right]^d \ar[r] & 0.
	\end{tikzcd}
	\end{center}
	We leave this olympiad-esque exercise as \Cref{prob:bezout}.
\end{proof}

\section{Applications}
First, we show that the notion of degree is what we expect.
\begin{corollary}
	[Hypersurfaces: the degree deserves its name]
	Let $V$ be a hypersurface, i.e. $\II(V) = (f)$
	for $f$ a homogeneous polynomial of degree $k$.
	Then $\deg V = k$.
\end{corollary}
\begin{proof}
	Recall $\deg(0) = \deg \CP^n = 1$.
	Take $I = (0)$ in B\'ezout's theorem.
\end{proof}

The common special case in $\CP^2$ is:
\begin{corollary}[B\'ezout's theorem for curves]
	For any two curves $X$ and $Y$ in $\CP^2$ without
	a common irreducible component,
	\[ \left\lvert X \cap Y \right\rvert
		\le \deg X \cdot \deg Y. \]
\end{corollary}

Now, we use this to prove Pascal's theorem.
\begin{theorem}
	[Pascal's theorem]
	Let $A$, $B$, $C$, $D$, $E$, $F$ be six
	distinct points which lie on a conic $\mathscr C$ in $\CP^2$.
	Then the points $AB \cap DE$, $BC \cap EF$, $CD \cap FA$ are collinear.
\end{theorem}
\begin{proof}
	Let $X$ be the variety equal to the union of the
	three lines $AB$, $CD$, $EF$, hence $X = \Vp(f)$
	for some cubic polynomial $f$ (which is the product of three linear ones).
	Similarly, let $Y = \Vp(g)$ be the variety
	equal to the union of the three lines $BC$, $DE$, $FA$.

	\begin{center}
		\begin{asy}
			filldraw(unitcircle, opacity(0.2)+lightcyan, blue);
			pair A = dir(110);
			pair B = dir(210);
			pair C = dir(40);
			pair D = dir(270);
			pair E = dir(130);
			pair F = dir(-30);

			pair P = extension(A, B, D, E);
			pair X = extension(B, C, E, F);
			pair Q = extension(C, D, F, A);

			draw(A--B--C--D--E--F--cycle);
			draw(P--Q, red+dashed);

			dot("$A$", A, dir(A));
			dot("$B$", B, dir(B));
			dot("$C$", C, dir(C));
			dot("$D$", D, dir(D));
			dot("$E$", E, dir(E));
			dot("$F$", F, dir(F));
			dot(P);
			dot(X);
			dot(Q);

			/* Source generated by TSQ */
		\end{asy}
	\end{center}

	Now let $P$ be an arbitrary point on the conic on $\mathscr C$,
	distinct from the six points $A$, $B$, $C$, $D$, $E$, $F$.
	Consider the projective variety
	\[ V = \Vp(\alpha f + \beta g) \]
	where the constants $\alpha$ and $\beta$ are chosen such that $P \in V$.
	\begin{ques}
		Show that $V$ also contains the six points $A$, $B$, $C$, $D$, $E$, $F$
		as well as the three points $AB \cap DE$, $BC \cap EF$, $CD \cap FA$
		regardless of which $\alpha$ and $\beta$ are chosen.
	\end{ques}

	Now, note that $|V \cap \mathscr C| \ge 7$.
	But $\deg V = 3$ and $\deg \mathscr C = 2$.
	This contradicts B\'ezout's theorem unless $V$ and $\mathscr C$
	share an irreducible component.
	This can only happen if $V$ is the union of a line and conic,
	for degree reasons; i.e.\ we must have that
	\[ V = \mathscr C \cup \text{line}. \]
	Finally note that the three intersection points $AB \cap DE$,
	$BC \cap EF$ and $CD \cap FA$ do not lie on $\mathscr C$,
	so they must lie on this line.
\end{proof}


\section\problemhead
\begin{problem}
	\label{prob:bezout}
	Complete the proof of B\'ezout's theorem from before.
	\begin{sol}
		From the exactness,
		$h_I(d) = h_I(d-k) + h_{I+(f)}(d)$,
		and it follows that
		\[ \chi_{I+(f)}(d) = \chi_I(d) - \chi_I(d-k). \]
		Let $m = \dim \Vp(I) \ge 1$.
		Now $\dim \Vp(I+(f)) = m-1$, so
		and $c_{\text{new}} = \deg I+(f)$ then we have
		\[
			\frac{\deg (I+(f)) d^{m-1} + \dots}{(m-1)!}
			=
			\frac{1}{m!}
			\left( \deg I (d^m - (d-k)^m)
			+ \text{lower order terms} \right)
		\]
		from which we read off
		\[ \deg (I+(f)) = \frac{(m-1)!}{m!} \cdot k \binom m1 \deg I
			= k \deg I \]
		as needed.
	\end{sol}
\end{problem}

\begin{problem}
	[USA TST 2016/6]
	\yod
	Let $ABC$ be an acute scalene triangle
	and let $P$ be a point in its interior.
	Let $A_1$, $B_1$, $C_1$ be projections of $P$ onto
	triangle sides $BC$, $CA$, $AB$, respectively.
	Find the locus of points $P$ such that $AA_1$, $BB_1$, $CC_1$
	are concurrent and $\angle PAB + \angle PBC + \angle PCA = 90^{\circ}$.
	\begin{hint}
		You will need to know about complex numbers
		in Euclidean geometry to solve this problem.
	\end{hint}
	\begin{sol}
	In complex numbers with $ABC$ the unit circle,
	it is equivalent to solving the two cubic equations
	\begin{align*}
		(p-a)(p-b)(p-c) &= (abc)^2 (q -1/a)(q - 1/b)(q - 1/c) \\
		0 &= \prod_{\text{cyc}} (p+c-b-bcq) + \prod_{\text{cyc}} (p+b-c-bcq)
	\end{align*}
	in $p$ and $q = \overline p$.
	Viewing this as two cubic curves in $(p,q) \in \mathbb C^2$,
	by B\'{e}zout's theorem it follows there are at most nine solutions
	(unless both curves are not irreducible,
	but one can check the first one cannot be factored).
	Moreover it is easy to name nine solutions (for $ABC$ scalene):
	the three vertices, the three excenters, and $I$, $O$, $H$.
	Hence the answer is just those three triangle centers $I$, $O$ and $H$.
	\end{sol}
\end{problem}
