High School Mathematics — Contents High School Mathematics / Chapter 4

Chapter 4Coordinate Geometry

One of the greatest ideas Descartes discovered was this: “a point in the plane can be represented by a pair of two numbers, the $x$-coordinate and the $y$-coordinate.” The moment we notice this, problems about figures can be turned into problems about numbers and expressions. Whether triangles overlap, whether two lines intersect, whether a point lies inside a given figure—all such questions about “figures” can be translated into calculations that use numbers, namely coordinates. This field of “investigating figures by using coordinates” is called coordinate geometry (or analytic geometry). Up through Chapter 3, we dealt with angles and side lengths themselves (trigonometric ratios, the law of sines, and the law of cosines). From this chapter on, the “coordinates” of points take center stage.

This chapter covers the four most basic tools of coordinate geometry. (1) The coordinates of the points (internal and external division points) that divide two points on a number line in a given ratio. (2) The formulas obtained when this is extended to the plane ($xy$-coordinates), and the coordinates of the centroid of a triangle. (3) The formula for the distance from a point to a line. In particular, in the course of deriving the formula in (3), we make early use of a tool we have not yet formally studied, namely “vectors” (their full definition and properties are studied in Chapter 7). Moreover, the “normal vector” that appears in the derivation is actually the same thing as the gradient vector ($\grad f$) studied in university mathematics, and at the end of this chapter we also touch on the bridge between the two.

What you will learn in this chapter
  • The coordinate formulas for the points that divide two points $A(a)$, $B(b)$ on a number line internally and externally in the ratio $m:n$, and their proofs using proportions
  • How to extend the ideas of internal and external division to two points in the $xy$-plane (why the same formula can be used as it is for the $x$-coordinate and the $y$-coordinate separately)
  • The coordinate formula for the centroid of a triangle, and two proofs that pass through a midpoint
  • The minimal toolkit of vectors ($\overrightarrow{PQ}$, magnitude, sum, scalar multiplication), and a proof of the criterion “if the inner product (also called the dot product) is 0, the vectors are perpendicular”
  • A proof that a normal vector of the line $ax+by+c=0$ is $\vec n=(a,b)$
  • A complete derivation of the formula $d=\dfrac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}}$ for the distance from a point to a line (keeping the absolute value correctly to the very end)
  • A preview of university mathematics: the fact that the partial derivative $\pdiff{f}{x}$ and the gradient vector $\grad f$ are what the normal vector really is
Prerequisites: Proportions from junior high school mathematics ($a:b=c:d\iff ad=bc$) and the basic handling of the coordinate plane. The general form $ax+by+c=0$ of the equation of a line (briefly reviewed in Section 4.3).
Source notes: Yasuhide Mochizuki, Mathematics Notes: High School Mathematics (handwritten lecture notes, in Japanese), pp. 11–12.
Note: The first half of Section 4.2 (the actual derivation of the formulas for internal and external division points in the plane) and the minimal toolkit of vectors at the beginning of Section 4.3 are not in pp. 11–12 of the original notes; we added them as a bridge so that the centroid formula in (3) and the distance formula in (4) can be understood without strain.

4.1 Internal and External Division Points on the Number Line

Let us begin with the simplest case, that is, a number line (a single coordinate axis). Using only the proportion we learned in junior high school mathematics ($a:b=c:d$ means “$a$ is to $b$ as $c$ is to $d$,” and then $ad=bc$ holds (the product of the outer terms = the product of the inner terms, the so-called “product of the extremes equals the product of the means”)), we can derive the coordinate formulas.

Definition 4.1: Internal division point

For two points $A(a)$, $B(b)$ on a number line (suppose $a\lt b$), consider a point $P(x)$ on the segment $AB$ satisfying

$$ AP:PB = m:n \qquad (m\gt0,\ n\gt0) $$

In this case we say that $P$ internally divides the segment $AB$ in the ratio $m:n$, and $P$ is called the internal division point of the segment $AB$. In particular, the internal division point for $m=n$ ($1:1$) is called the midpoint of the segment $AB$.

Construction of an internal division point m n A(a) P(x) B(b)
Figure 4.1: Construction of the internal division point $P$. Take a point $P$ on the segment $AB$ such that $AP:PB=m:n$.

Formula 4.1: Internal division point on the number line

The coordinate of the point $P(x)$ that divides two points $A(a)$, $B(b)$ on a number line internally in the ratio $m:n$ is given by

$$ \begin{equation} x=\frac{na+mb}{m+n} \label{eq:4-internal-1d} \end{equation} $$

Proof of Formula 4.1

Since $P$ lies on the segment $AB$ and $a\lt x\lt b$, both $AP=x-a$ and $PB=b-x$ are positive numbers (the difference of the coordinates is exactly the length). By definition, $AP:PB=m:n$, so

$$ m:n = AP:PB = (x-a):(b-x) $$

Applying the relation $ad=bc$ between the outer and inner terms to the proportion $m:n=(x-a):(b-x)$ (assigning $m,n,(x-a),(b-x)$ to $a,b,c,d$ in this order), we obtain

$$ n(x-a) = m(b-x) $$

Expanding both sides (using the distributive law $n(x-a)=nx-na$, $m(b-x)=mb-mx$), we get

$$ nx-na = mb-mx $$

Moving the terms containing $x$ to the left-hand side and the constant terms to the right-hand side, we get

$$ nx+mx = na+mb $$

Factoring $x$ out of the left-hand side, we get

$$ (n+m)x = na+mb $$

Dividing both sides by $m+n$ (since $m,n\gt0$, we have $m+n\neq0$), we get

$$ x = \frac{na+mb}{m+n} \qquad \therefore\ P\left(\frac{na+mb}{m+n}\right) $$

∎

Next, let us apply the same idea to a point taken outside the segment.

Definition 4.2: External division point

For two points $A(a)$, $B(b)$ on a number line (suppose $a\lt b$), consider a point $Q(x)$ on the line $AB$ (outside the segment $AB$) satisfying

$$ QA:QB = m:n \qquad (m\gt0,\ n\gt0,\ m\neq n) $$

In this case we say that $Q$ externally divides the segment $AB$ in the ratio $m:n$, and $Q$ is called the external division point of the segment $AB$.

Intuition: Which side does the external division point fall on?

When $m\gt n$ (the ratio is such that $A$ is “farther” from $Q$), $Q$ lies even farther out than $B$ (on the extension of the segment $AB$ in the direction of $B$). Conversely, when $m\lt n$, $Q$ lies even farther out than $A$ (on the extension in the direction of $A$). Figure 4.2 shows the case $m\gt n$ ($A,B,Q$ lie in this order).

Construction of an external division point m n A(a) B(b) Q(x)
Figure 4.2: Construction of the external division point $Q$ (the case $m\gt n$). The points $A,B,Q$ lie in this order, and $QA:QB=m:n$.

Formula 4.2: External division point on the number line

The coordinate of the point $Q(x)$ that divides two points $A(a)$, $B(b)$ on a number line externally in the ratio $m:n$ ($m\neq n$) is given by

$$ \begin{equation} x=\frac{-na+mb}{m-n} \label{eq:4-external-1d} \end{equation} $$

Proof of Formula 4.2

As in Figure 4.2, we prove the case $m\gt n$ (the case $m\lt n$ is similar). Then $A,B,Q$ lie in this order, so $QA=x-a$ and $QB=x-b$ are both positive numbers. By definition, $QA:QB=m:n$, so

$$ m:n = QA:QB = (x-a):(x-b) $$

Using the relation between the outer and inner terms, we get

$$ m(x-b) = n(x-a) $$

Expanding both sides, we get

$$ mx-mb = nx-na $$

Moving the terms containing $x$ to the left-hand side and the constant terms to the right-hand side, we get

$$ mx-nx = mb-na $$

Factoring $x$ out of the left-hand side, we get

$$ (m-n)x = -na+mb $$

Now, since $m\neq n$ we have $m-n\neq0$, so we may divide both sides by $m-n$.

$$ x = \frac{-na+mb}{m-n} \qquad \therefore\ Q\left(\frac{-na+mb}{m-n}\right) $$

∎

Caution: Why is the external division point undefined when $m=n$?

The denominator of Formula 4.2 is $m-n$, so when $m=n$ we would be dividing by $0$. This is not a mere accident of the calculation. To divide externally with $m=n$ ($1:1$) means to look for a point such that “the distance from $Q$ to $A$ equals the distance from $Q$ to $B$, and moreover $Q$ lies outside the segment $AB$.” But the only point (on a number line) that is equidistant from the points $A,B$ is the midpoint of the points $A,B$, and that is a point inside the segment, not outside. Since no equidistant point exists outside, the external division point for $m=n$ cannot be defined (we check this in Exercise 4.6).

Example 4.1: Computing an internal division point

Find the coordinate of the point $P$ that divides the two points $A(-3)$, $B(9)$ on a number line internally in the ratio $2:1$.

Solution. Applying Formula 4.1 (Eq. \eqref{eq:4-internal-1d}) with $a=-3$, $b=9$, $m=2$, $n=1$, we get

$$ x = \frac{na+mb}{m+n} = \frac{1\times(-3)+2\times9}{2+1} = \frac{-3+18}{3} = \frac{15}{3} = 5 $$

Therefore the point is $P(5)$.

Example 4.2: Computing an external division point

Find the coordinate of the point $Q$ that divides the two points $A(-3)$, $B(9)$ on a number line externally in the ratio $3:1$.

Solution. Applying Formula 4.2 (Eq. \eqref{eq:4-external-1d}) with $a=-3$, $b=9$, $m=3$, $n=1$ (the formula can be used because $m\neq n$), we get

$$ x = \frac{-na+mb}{m-n} = \frac{-1\times(-3)+3\times9}{3-1} = \frac{3+27}{2} = \frac{30}{2} = 15 $$

Therefore the point is $Q(15)$. Since $m=3\gt n=1$, as in the Intuition box (see the main text), $Q$ lies even farther to the right than $B(9)$ ($15\gt9$).

4.2 Internal and External Division Points in the Plane and the Centroid of a Triangle

In Section 4.1 we considered internal and external division points on the number line, a “single axis.” A point in the $xy$-plane has two coordinates (the $x$-coordinate and the $y$-coordinate), but in fact the same formula can be used as it is, independently, for the $x$-coordinate and for the $y$-coordinate. This is because the only tools used in the proof in Section 4.1 were “proportions” and “the fact that a difference of coordinates is a length,” and these hold in exactly the same form in the world of $x$-coordinates alone and in the world of $y$-coordinates alone.

Why can the same formula be used independently for the $x$-coordinate and the $y$-coordinate?

Let $P(x,y)$ be the point that divides two points $A(x_1,y_1)$ and $B(x_2,y_2)$ in the plane internally in the ratio $m:n$. Since $P$ lies on segment $AB$, the distance along the segment from $A$ to $P$ is exactly $\dfrac{m}{m+n}$ times the length of the whole segment $AB$ (because $AP:PB=m:n$ gives $AP:AB=m:(m+n)$). So let $s=\dfrac{m}{m+n}$; then

$$ P = A+s\,(B-A) = (1-s)A+sB $$

holds (this means “the point reached by starting at $A$ and moving in the direction of $B$ by $s$ times the whole displacement,” and it is a relation that holds simultaneously for both the $x$-coordinate and the $y$-coordinate). The “sum of points” and the “scalar multiple of a point” used here are merely shorthand for computing the $x$-coordinate and the $y$-coordinate independently (a compact way of writing $x=(1-s)x_1+sx_2$ and $y=(1-s)y_1+sy_2$ together); their formal treatment is justified by the minimal vector tools introduced at the beginning of Section 4.3, and as a special case of the vectors studied in Chapter 7. Noting that $1-s=\dfrac{n}{m+n}$ and writing the relation out coordinate by coordinate, we obtain

$$ x = (1-s)x_1+sx_2 = \frac{n}{m+n}x_1+\frac{m}{m+n}x_2 = \frac{nx_1+mx_2}{m+n} $$

and the same formula holds for the $y$-coordinate as well:

$$ y = \frac{ny_1+my_2}{m+n} $$

Note that both have exactly the same form as Formula 4.1 in Section 4.1 (with $a,b$ merely replaced by $x_1,x_2$ or $y_1,y_2$).

∎

Let us also check this with a figure. Let $A',P',B'$ be the feet of the perpendiculars dropped from $A,P,B$ to the $x$-axis. Then the ratio $A'P':P'B'$ is exactly the same $m:n$ as the original ratio $AP:PB$ (and likewise for the feet of the perpendiculars to the $y$-axis). This is because dropping a perpendicular is nothing other than the operation of “extracting only the $x$-coordinate (ignoring the $y$-coordinate),” and a point that divides a segment in the ratio $m:n$ divides it in the ratio $m:n$ even when we look at its $x$-coordinate alone.

An internal division point in the plane and the ratios for each coordinate x y A(x₁,y₁) B(x₂,y₂) P(x,y) A' P' B' m n A'' P'' B'' m n
Figure 4.3: An internal division point in the plane. The feet of the perpendiculars dropped from $A,P,B$ to the $x$-axis and the $y$-axis, $A',P',B'$ (for the $x$-coordinate) and $A'',P'',B''$ (for the $y$-coordinate), both divide the segment in the same ratio $m:n$.

Formula 4.3: Internal and external division points in the plane

The coordinates of the point $P$ that divides two points $A(x_1,y_1)$ and $B(x_2,y_2)$ in the plane internally in the ratio $m:n$, and of the point $Q$ that divides them externally in the same ratio ($m\neq n$), are, respectively,

$$ \begin{equation} P\left(\frac{nx_1+mx_2}{m+n},\ \frac{ny_1+my_2}{m+n}\right),\qquad Q\left(\frac{-nx_1+mx_2}{m-n},\ \frac{-ny_1+my_2}{m-n}\right) \label{eq:4-plane-internal-external} \end{equation} $$

(it suffices to apply Formula 4.1 and Formula 4.2 as they are to each of the $x$-coordinate and the $y$-coordinate). In particular, the midpoint (the internal division point in the ratio $1:1$) is $M\left(\dfrac{x_1+x_2}{2},\dfrac{y_1+y_2}{2}\right)$.

Using this planar version of the internal division formula, we can derive (3) the coordinate formula for the centroid of a triangle. The definition of the centroid itself, and the property that “the centroid divides each median in the ratio $2:1$,” were studied in Chapter 2, Section 2.2 (The Five Centers of a Triangle (1) — Centroid, Median Theorem, and Orthocenter), so here we use that property to compute the coordinates.

The centroid of a triangle x y O B C A M N G
Figure 4.4: The centroid $G$ of triangle $ABC$. $M$ is the midpoint of side $BC$ and $N$ is the midpoint of side $CA$. The intersection of the medians $AM$ and $BN$ is the centroid $G$, and $AG:GM=BG:GN=2:1$.

Formula 4.4: Coordinates of the centroid of a triangle

The coordinates of the centroid of the triangle with vertices at the three points $A(x_1,y_1)$, $B(x_2,y_2)$, $C(x_3,y_3)$ are

$$ \begin{equation} G\left(\frac{x_1+x_2+x_3}{3},\ \frac{y_1+y_2+y_3}{3}\right) \label{eq:4-centroid} \end{equation} $$

where $G$ is the centroid of $\triangle ABC$.

Proof of Formula 4.4

Let $M$ be the midpoint of side $BC$ and $N$ the midpoint of side $CA$. By the midpoint formula in Formula 4.3, we have

$$ M\left(\frac{x_2+x_3}{2},\frac{y_2+y_3}{2}\right),\qquad N\left(\frac{x_3+x_1}{2},\frac{y_3+y_1}{2}\right) $$

The centroid $G$ lies on the median $AM$ and is the point that divides it internally in the ratio $AG:GM=2:1$ (a property from Chapter 2), so it suffices to compute the coordinates of this internal division point by Formula 4.3 with $A(x_1,y_1)$, $M\left(\frac{x_2+x_3}{2},\frac{y_2+y_3}{2}\right)$, and $m:n=2:1$. Noting that in the part of Formula 4.3 corresponding to the numerator $nx_1+mx_2$, the coefficient of the $1$st point ($A$) is $n=1$ and the coefficient of the $2$nd point ($M$) is $m=2$, we have

$$ G\left(\frac{1\times x_1+\dfrac{x_2+x_3}{2}\times2}{2+1},\ \frac{1\times y_1+\dfrac{y_2+y_3}{2}\times2}{2+1}\right) $$

Here the second term of the numerator simplifies to $\dfrac{x_2+x_3}{2}\times2=x_2+x_3$ (multiplying by $2$ cancels the $2$ in the denominator), so we obtain

$$ G\left(\frac{x_1+(x_2+x_3)}{3},\ \frac{y_1+(y_2+y_3)}{3}\right) = \left(\frac{x_1+x_2+x_3}{3},\ \frac{y_1+y_2+y_3}{3}\right) $$

Computing with the median $BN$ instead (as the point that divides it internally in the ratio $BG:GN=2:1$) gives the same result, as can be verified in Exercise 4.3.

∎

Intuition: The centroid as the “average” of the coordinates

The right-hand side of Formula 4.4 is the average of the $x$-coordinates and the average of the $y$-coordinates of the three vertices. That the centroid is found as “the simple average of the coordinates of the three vertices” is easy to remember and is also physically natural (it agrees with the center of mass—the point where the system balances—when weights of equal mass are placed at three points).

Example 4.3: Computing internal and external division points in the plane

Find the coordinates of the point that divides the two points $A(-3,2)$ and $B(5,-4)$ internally in the ratio $3:1$ and of the point that divides them externally in the same ratio.

Solution. In Formula 4.3 (Eq. \eqref{eq:4-plane-internal-external}), take $x_1=-3,y_1=2,x_2=5,y_2=-4$ and $m=3,n=1$. The internal division point $P$ is

$$ P\left(\frac{1\times(-3)+3\times5}{3+1},\ \frac{1\times2+3\times(-4)}{3+1}\right) = \left(\frac{-3+15}{4},\ \frac{2-12}{4}\right) = \left(\frac{12}{4},\ \frac{-10}{4}\right) = \left(3,\ -\frac{5}{2}\right) $$

and the external division point $Q$ (which is defined because $m\neq n$) is

$$ Q\left(\frac{-1\times(-3)+3\times5}{3-1},\ \frac{-1\times2+3\times(-4)}{3-1}\right) = \left(\frac{3+15}{2},\ \frac{-2-12}{2}\right) = \left(\frac{18}{2},\ \frac{-14}{2}\right) = (9,\ -7) $$

Hence $P\left(3,-\dfrac{5}{2}\right)$ and $Q(9,-7)$.

Example 4.4: Computing a centroid (a check by two methods)

Find the coordinates of the centroid $G$ of the triangle with vertices at the three points $A(1,8)$, $B(-2,-1)$, $C(7,2)$ in two ways, (i) by Formula 4.4 and (ii) by internal division in the ratio $2:1$ through the midpoint $M$ of side $BC$, and verify that the results agree.

Solution. (i) By Formula 4.4 (Eq. \eqref{eq:4-centroid}),

$$ G\left(\frac{1+(-2)+7}{3},\ \frac{8+(-1)+2}{3}\right) = \left(\frac{6}{3},\ \frac{9}{3}\right) = (2,\ 3) $$

(ii) The midpoint of side $BC$ is $M\left(\dfrac{-2+7}{2},\dfrac{-1+2}{2}\right)=\left(\dfrac{5}{2},\dfrac{1}{2}\right)$. Since $G$ is the point that divides the median $AM$ internally in the ratio $AG:GM=2:1$, Formula 4.3 (with $m=2,n=1$) gives

$$ G\left(\frac{1\times1+2\times\frac{5}{2}}{2+1},\ \frac{1\times8+2\times\frac{1}{2}}{2+1}\right) = \left(\frac{1+5}{3},\ \frac{8+1}{3}\right) = \left(\frac{6}{3},\ \frac{9}{3}\right) = (2,\ 3) $$

Both (i) and (ii) give $G(2,3)$, so the results agree.

4.3 Distance from a Point to a Line

You are probably familiar with the equation of a line written in the form $y=(\text{slope})x+(\text{intercept})$ (the slope-intercept form). This form, however, has a weakness: it cannot represent a line parallel to the $y$-axis (whose slope cannot be defined). So we use the general form, in which a linear expression in $x,y$ equals $0$:

$$ ax+by+c=0 \qquad ((a,b)\neq(0,0)) $$

When $b\neq0$, this can be rearranged as $y=-\dfrac{a}{b}x-\dfrac{c}{b}$, a line with slope $-\frac{a}{b}$, and when $b=0$ ($a\neq0$) it becomes $x=-\dfrac{c}{a}$ (a line parallel to the $y$-axis). The condition $(a,b)\neq(0,0)$ is there to avoid the case $a=b=0$, in which the equation would become $c=0$, an “expression that is not a line.” In this section we derive the formula for the distance $d$ between a point $P(x_1,y_1)$ and a line $\ell:ax+by+c=0$, using a tool called the vector.

Math Note: The minimal vector tools used in this section (the full definitions are in Chapter 7)

The formal definition and properties of vectors are the subject of Chapter 7; here we preview only as much as we need to derive the distance from a point to a line.

Finally, we prepare a way to decide from components alone whether two vectors are perpendicular. For $\vec u=(u_1,u_2)$ and $\vec v=(v_1,v_2)$ (neither of them equal to $\vec 0$), the quantity $u_1v_1+u_2v_2$ is called the inner product of $\vec u$ and $\vec v$, and is written $\vec u\cdot\vec v$.

Why can we tell that vectors are perpendicular when their inner product is 0?

Consider two vectors with the origin $O$ as their starting point, $\vec u=\overrightarrow{OA}=(u_1,u_2)$ and $\vec v=\overrightarrow{OB}=(v_1,v_2)$. In $\triangle OAB$, the vector corresponding to the side $AB$ is $\overrightarrow{AB}=\vec v-\vec u=(v_1-u_1,v_2-u_2)$, so

$$ AB^2 = (v_1-u_1)^2+(v_2-u_2)^2 = (u_1^2+u_2^2)+(v_1^2+v_2^2)-2(u_1v_1+u_2v_2) = OA^2+OB^2-2(\vec u\cdot\vec v) $$

(we expanded the squares and sorted the result into the parts $u_1^2+u_2^2=OA^2$ and $v_1^2+v_2^2=OB^2$, and the cross terms $-2u_1v_1-2u_2v_2=-2(\vec u\cdot\vec v)$). By the converse of the Pythagorean theorem (a triangle whose side lengths satisfy $AB^2=OA^2+OB^2$ is a right triangle with $\angle AOB=90°$), $\angle AOB=90°$, that is, $\vec u\perp\vec v$, is equivalent to $AB^2=OA^2+OB^2$. Comparing with the equation above, this is exactly the case $\vec u\cdot\vec v=0$. Therefore,

$$ \vec u\perp\vec v \iff \vec u\cdot\vec v=u_1v_1+u_2v_2=0 $$

∎

From this criterion we make one more tool. Let us find all vectors $\vec v=(v_1,v_2)$ perpendicular to a fixed vector $\vec d=(d_1,d_2)\neq\vec0$. The pairs $(v_1,v_2)$ satisfying $d_1v_1+d_2v_2=0$ are limited to those of the form $\vec v=t(d_2,-d_1)$ with $t$ a real number (if $d_1\neq0$, we can write $v_1=-\frac{d_2}{d_1}v_2$, so $\vec v=\frac{v_2}{d_1}(-d_2,d_1)=-\frac{v_2}{d_1}(d_2,-d_1)$; if $d_1=0$, then $d_2\neq0$ and $v_2=0$, so $\vec v=v_1(1,0)$, which is a real multiple of $(d_2,-d_1)=(d_2,0)$). In other words, vectors that are perpendicular to a given vector are real multiples of one another (that is, parallel).

Definition 4.3: Normal vector

A vector other than $\vec0$ that is perpendicular to a direction vector of a line $\ell$ (a vector formed by joining two distinct points on $\ell$) is called a normal vector of the line $\ell$.

Formula 4.5: A normal vector of the line $ax+by+c=0$

For the line $\ell:ax+by+c=0$, the vector

$$ \vec n=(a,b) $$

is one of its normal vectors.

Proof of Formula 4.5

Let $P_1(x_1,y_1)$ and $P_2(x_2,y_2)$ be two distinct points on $\ell$. Both satisfy the equation of $\ell$, so

$$ ax_1+by_1+c=0,\qquad ax_2+by_2+c=0 $$

hold. Subtracting the equations side by side (subtracting the first equation from the second), the constant term $c$ cancels, and we get

$$ a(x_2-x_1)+b(y_2-y_1)=0 $$

The vector $\overrightarrow{P_1P_2}=(x_2-x_1,y_2-y_1)$ is a direction vector of $\ell$, and the equation above has exactly the form $\vec n\cdot\overrightarrow{P_1P_2}=0$ (the inner product with $\vec n=(a,b)$ is $0$). By the criterion we proved earlier, this means $\vec n\perp\overrightarrow{P_1P_2}$. Therefore $\vec n=(a,b)$ is a normal vector of $\ell$.

∎

Caution: The normal vector is really the gradient vector

Let us regard the left-hand side of the equation of the line $\ell:ax+by+c=0$ as a function of two variables, $f(x,y)=ax+by+c$. In university calculus, the result of differentiating $f$ regarding it as a function of $x$ alone (treating $y$ as if it were a constant) is called the partial derivative, and is written $\pdiff{f}{x}$ (read “partial f over partial x,” meaning “the partial derivative of $f$ with respect to $x$”). Partially differentiating $f=ax+by+c$ with respect to $x$ (the part $by+c$ does not contain $x$, so it vanishes as a constant, and only $a$, the derivative of $ax$ with respect to $x$, remains) gives $\pdiff{f}{x}=a$, and similarly $\pdiff{f}{y}=b$. The pair formed from these two,

$$ \grad f = \left(\pdiff{f}{x},\ \pdiff{f}{y}\right) = (a,b) $$

is called the gradient vector (or simply the gradient) of $f$. The gradient $\grad f$ is often written $\nabla f$, using the symbol $\nabla$ (nabla) (the label on the arrow in Figure 4.6 uses this notation $\nabla f$). Formula 4.5 says precisely that “a normal vector of the line $ax+by+c=0$ equals $\grad f$.” Partial derivatives and gradient vectors are treated properly in university mathematics (in the chapter Scalar Fields, Vector Fields, and the Gradient), but the fact that “the vector pointing in the direction in which a function increases most steeply is perpendicular to the contour lines of that function (the lines or curves on which $f=$ constant)” can be checked intuitively in Figure 4.6.

Parallel lines as contour lines, and the gradient vector ℓ ∇f=(a,b) direction of increasing f
Figure 4.6: The line $\ell:ax+by+c=0$ (solid) and the lines parallel to it (the “contour lines” on which $f=ax+by+c$ takes other values, dashed). The normal vector $\vec n=(a,b)=\grad f$ is perpendicular to every one of the parallel lines and points in the direction in which the value of $f$ increases most steeply.

Now that the preparation is complete, let us find the distance from a point to a line.

Distance from a point to a line x y O ℓ P(x₁,y₁) H
Figure 4.5: The distance between a point $P(x_1,y_1)$ and a line $\ell$. $H$ is the foot of the perpendicular from $P$ to $\ell$. $d=|\overrightarrow{PH}|$. (In the figure in the original notes, the arrow is drawn pointing from $H$ to $P$, but in this book we have made the direction of the arrow match the direction of the vector $\overrightarrow{PH}$ (starting point $P$, endpoint $H$).)

Proof of Formula 4.6 (distance from a point to a line)

Consider the line $\ell:ax+by+c=0$ and a point $P(x_1,y_1)$. Let $H$ be the foot of the perpendicular from $P$ to $\ell$. Then the distance $d$ between the point $P$ and the line $\ell$ is given by the magnitude of the vector $\overrightarrow{PH}$:

$$ d = |\overrightarrow{PH}| $$

Now let $\vec n=(a,b)$; by Formula 4.5, $\vec n$ is a normal vector of $\ell$. The vector $\overrightarrow{PH}$ is perpendicular to a direction vector of $\ell$ (because $H$ is the foot of the perpendicular), and $\vec n$ is also perpendicular to that direction vector of $\ell$, so both are perpendicular to the same vector. As we verified in the vector tools (at the beginning of this section), vectors that are perpendicular to a given vector are real multiples of one another, so there must exist a real number $t$ satisfying

$$ \overrightarrow{PH}=t\,\vec n $$

Also, from the relation for the sum of vectors, $\overrightarrow{OP}+\overrightarrow{PH}=\overrightarrow{OH}$, the position vector of $H$ is $\overrightarrow{OH}=\overrightarrow{OP}+t\vec n=(x_1+ta,\ y_1+tb)$, so the coordinates of $H$ are

$$ H(x_1+ta,\ y_1+tb) $$

Since the point $H$ also lies on the line $\ell$, the equation $ax+by+c=0$ of $\ell$ must remain true when we substitute $x=x_1+ta$ and $y=y_1+tb$ into it.

$$ a(x_1+ta)+b(y_1+tb)+c=0 $$

Expanding the left-hand side and collecting in terms of $t$ (we combine $a\cdot ta=a^2t$ and $b\cdot tb=b^2t$ into $t(a^2+b^2)$, and group the terms that do not contain $t$),

$$ t(a^2+b^2)+(ax_1+by_1+c)=0 $$

Since $(a,b)\neq(0,0)$, we have $a^2+b^2\neq0$, so dividing both sides by $a^2+b^2$ and solving for $t$ gives

$$ t = -\frac{ax_1+by_1+c}{a^2+b^2} $$

Now take the magnitude of $\overrightarrow{PH}=t\vec n$ (using the property of scalar multiplication in the vector tools, $|t\vec n|=|t|\,|\vec n|$). We get

$$ d = |\overrightarrow{PH}| = |t|\cdot|\vec n| = \left|-\frac{ax_1+by_1+c}{a^2+b^2}\right|\cdot\sqrt{a^2+b^2} $$

Since the factor $-1$ inside the absolute value can be taken outside without changing the sign (always positive), we have $\left|-\dfrac{ax_1+by_1+c}{a^2+b^2}\right|=\dfrac{|ax_1+by_1+c|}{a^2+b^2}$ (the denominator $a^2+b^2$ is always positive, so it can be taken outside the absolute value), and thus

$$ d = \frac{|ax_1+by_1+c|}{a^2+b^2}\cdot\sqrt{a^2+b^2} $$

Finally, if we rewrite $a^2+b^2=\sqrt{a^2+b^2}\cdot\sqrt{a^2+b^2}$ (multiplying two copies of the square root of $a^2+b^2\gt0$ gives back the original), one of the two factors $\sqrt{a^2+b^2}$ in the denominator cancels against the $\sqrt{a^2+b^2}$ on the right, while the absolute value signs survive as they are, and we obtain

$$ d = \frac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}\cdot\sqrt{a^2+b^2}}\cdot\sqrt{a^2+b^2} = \frac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}} $$

as the result.

∎

Formula 4.6: Distance from a point to a line

The distance $d$ between a point $P(x_1,y_1)$ and a line $\ell:ax+by+c=0$ is given by

$$ \begin{equation} d=\frac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}} \label{eq:4-point-line-distance} \end{equation} $$

Note that the numerator carries an absolute value—a distance is always a quantity that is at least $0$, so $d\ge0$ must hold regardless of the sign of $ax_1+by_1+c$.

Caution: When the point $P$ lies on the line $\ell$

If $P$ lies on $\ell$, then $H=P$ (the foot of the perpendicular is $P$ itself) and $\overrightarrow{PH}=\vec0$, that is, $t=0$. In this case $ax_1+by_1+c=0$ (since $P$ satisfies the equation of $\ell$), so Formula 4.6 returns $d=\dfrac{|0|}{\sqrt{a^2+b^2}}=0$. A distance of $0$ corresponds naturally to the statement “$P$ lies on $\ell$,” and the formula works correctly as it stands, without any case analysis.

Application: Contour lines, equipotential surfaces, and gradient vectors

The picture in Figure 4.6, in which “the gradient vector meets at right angles the lines on which the value of $f=ax+by+c$ is constant (the contour lines),” appears everywhere in materials science as well. For example, heat flow meets the isotherms of a temperature distribution $T(x,y)$ at right angles (heat flows in the direction of the temperature gradient $\grad T$), and the electric field meets the equipotential lines of an electric potential $V(x,y)$ at right angles (the electric field points in the direction of $-\grad V$). The “normal vector of a line $=(a,b)$” that we learned in this chapter is nothing more than the simplest case (that of a straight line) of this general law that the gradient vector is perpendicular to the contour lines.

Example 4.5: Basic computation of the distance from a point to a line

Find the distance between the point $(2,-1)$ and the line $3x-4y+5=0$.

Solution. By Formula 4.6 (Eq. \eqref{eq:4-point-line-distance}), taking $x_1=2,y_1=-1,a=3,b=-4,c=5$ gives

$$ d = \frac{|3\times2-4\times(-1)+5|}{\sqrt{3^2+(-4)^2}} = \frac{|6+4+5|}{\sqrt{9+16}} = \frac{15}{\sqrt{25}} = \frac{15}{5} = 3 $$

Hence the distance is $3$.

Example 4.6: An application of the distance from a point to a line—the area of a triangle

For the triangle with vertices $A(0,0)$, $B(6,0)$, $C(2,4)$, take side $BC$ as the base and find the height (the distance from $A$ to the line $BC$) by Formula 4.6, then use it to find the area of the triangle. Also verify that the result agrees with the area computed by the area formula in terms of coordinates (the shoelace formula).

Solution. First we find the equation of the line $BC$. A direction vector of the line through $B(6,0)$ and $C(2,4)$ is $\overrightarrow{BC}=(2-6,4-0)=(-4,4)$, and as a candidate for a normal vector perpendicular to it we take $\vec n=(4,4)$ (indeed they are perpendicular, since $(4,4)\cdot(-4,4)=-16+16=0$). The equation of the line is $4(x-6)+4(y-0)=0$, that is,

$$ 4x+4y-24=0 \quad\Longleftrightarrow\quad x+y-6=0 $$

(here we simplified by dividing both sides by $4$). Checking by substituting the coordinates of $B,C$, we get $6+0-6=0$ and $2+4-6=0$, so both hold. By Formula 4.6, the distance (= the height) from $A(0,0)$ to the line $x+y-6=0$ ($a=1,b=1,c=-6$) is

$$ h = \frac{|1\times0+1\times0-6|}{\sqrt{1^2+1^2}} = \frac{6}{\sqrt2} = 3\sqrt2 $$

Since the length of the base is $BC=\sqrt{(2-6)^2+(4-0)^2}=\sqrt{16+16}=\sqrt{32}=4\sqrt2$, the area of the triangle is

$$ S = \frac12\times BC\times h = \frac12\times4\sqrt2\times3\sqrt2 = \frac12\times12\times2 = 12 $$

On the other hand, by the shoelace formula (a formula that gives the area directly from the coordinates),

$$ S = \frac12\left|x_A(y_B-y_C)+x_B(y_C-y_A)+x_C(y_A-y_B)\right| = \frac12|0\times(0-4)+6\times(4-0)+2\times(0-0)| = \frac12|24| = 12 $$

so both methods agree, giving $S=12$.

4.4 Summary and Exercises

4.4.1 Summary

$$ \begin{align} &P\left(\frac{na+mb}{m+n}\right),\quad Q\left(\frac{-na+mb}{m-n}\right) && (\text{number line, internal and external division points}) \nonumber\\[4pt] &P\left(\frac{nx_1+mx_2}{m+n},\ \frac{ny_1+my_2}{m+n}\right) && (\text{plane, internal division point}) \nonumber\\[4pt] &G\left(\frac{x_1+x_2+x_3}{3},\ \frac{y_1+y_2+y_3}{3}\right) && (\text{centroid of a triangle}) \nonumber\\[4pt] &d=\frac{|ax_1+by_1+c|}{\sqrt{a^2+b^2}} && (\text{distance from a point to a line}) \label{eq:4-key-formulas} \end{align} $$

4.4.2 Exercises

Exercise 4.1: Internal and external division points on the number line

Find the coordinates of the point $P$ that divides the two points $A(-4)$, $B(6)$ on the number line internally, and of the point $Q$ that divides them externally, each in the ratio $3:2$.

Hint: Substitute $a=-4,b=6,m=3,n=2$ into Formula 4.1 and Formula 4.2.

Exercise 4.2: Internal and external division points in the plane

Find the point that divides the two points $A(2,5)$, $B(8,-1)$ internally, and the point that divides them externally, each in the ratio $2:3$.

Hint: Substitute $x_1=2,y_1=5,x_2=8,y_2=-1,m=2,n=3$ into Formula 4.3. Note that the denominator for the external division point is $m-n=-1$.

Exercise 4.3: The centroid of a triangle

Find the coordinates of the centroid $G$ of the triangle with vertices $A(2,-1)$, $B(5,4)$, $C(-4,3)$. Further, following Example 4.4, compute it also by an internal division in the ratio $2:1$ through the midpoint $N$ of side $CA$, and verify that you obtain the same answer.

Hint: Using Formula 4.4 directly is method (i). Finding $N=\dfrac{C+A}{2}$ first and then using $BG:GN=2:1$ is method (ii).

Exercise 4.4: Distance from a point to a line (basic)

Find the distance between the point $(0,0)$ and the line $5x-12y+26=0$.

Hint: Rather than the $3$-$4$-$5$ right triangle, it is the “$5$-$12$-$13$” triple that appears in the computation of $\sqrt{a^2+b^2}$.

Exercise 4.5: Comparing distances from a point to a line

For the line $3x+4y-12=0$, find the distance from the point $(1,1)$ and the distance from the origin $(0,0)$. Also state which of the two points is closer to this line.

Hint: You only need to use Formula 4.6 twice. If you also look at the sign (positive or negative) of the value of $3x+4y-12$, you can tell on which side of the line each of the two points lies.

Exercise 4.6: The external division formula when $m=n$

Suppose we try to find the point that divides the two points $A(1)$, $B(5)$ on the number line externally in the ratio $1:1$ using Formula 4.2. What happens? Explain by actually carrying out the computation. Also explain in your own words the geometric reason stated in the Caution in the main text (Section 4.1).

Hint: Actually compute what happens when you substitute $m=n=1$ into the denominator $m-n$ of Formula 4.2.

4.4.3 References

  1. Yasuhide Mochizuki, Mathematics Notes: High School Mathematics (handwritten lecture notes, in Japanese). The source of this chapter.
  2. Chart Institute (ed.), Chart-shiki Kiso kara no Sūgaku II [Chart-Style Mathematics II from the Basics], Suken Shuppan (in Japanese).