A linear relation between two variables, say \(x\) and \(y\),
is when the change between the variables, rather than the variables themselves,
are proportional.

Definition7.2.1Linear Relation

Given two covarying variables \(x\) and \(y\), we say that \(x\) and \(y\)
have a linear relation if there exist some constants \(A\), \(B\) and \(C\)
such that for every state of the system, the variables \(x\) and \(y\) satisfy
\begin{equation*}Ax+By=C.\end{equation*}
The graph of such a relation in the Cartesian plane is a line.

The form of the equation used in the definition of a linear relation is called the
general equation for a line. This equation can describe horizontal, vertical and slanted lines.
A vertical line occurs in the \(x\)-\(y\) plane when the value of \(x\) is
the same regardless of the value of \(y\), or \(x\) is independent of \(y\).
This corresponds in the general equation with \(B=0\) and the equation can be rewritten
as \(x=a\) with \(a=C/A\), where \(a\) represents the constant value of \(x\) over
all states of the system.

With the exception of the case of that \(x\) is constant (discussed above), for linear relations
we say that \(y\) is a linear function of \(x\).

Definition7.2.2Linear Function

Given two covarying variables \(x\) and \(y\), we say that \(y\)
is a linear function of \(x\) if there exist a constant \(m\)
such that for any two states of the system \((x_1,y_1)\) and \((x_2,y_2)\),
the ratio of the change in \(y\), \(\Delta y = y_2-y_1\),
to the change in \(x\), \(\Delta x = x_2-x_1\), always equals \(m\),
\begin{equation*}\frac{\Delta y}{\Delta x} = \frac{y_2-y_1}{x_2-x_1} = m.\end{equation*}

That is, the change in \(y\) is proportional to the change in \(x\),
or \(\Delta y \propto \Delta x\).
The ratio of the changes, or rate of change, is called the slope.

Many students finish algebra courses remembering the slope–intercept form
of the equation of a line,
\begin{equation*} y = mx+b, \end{equation*}
and have unfortunately used it so much that they think this is a preferred form.
This equation's form involves two model parameters, the slope \(m\) and
the \(y\)–intercept, \(b\). An intercept describes a point
where a graph crosses one of the axes in the plane. A \(y\)-intercept
is a point where the graph crosses the \(y\)-axis. So this form of the line requires
knowing the slope \(m\) and the value of \(y\) when \(x=0\) so that \((x,y)=(0,b)\)
is a known state.

It would be much better to remember the more general point–slope form,
\begin{equation*} y-y_1 = m(x-x_1). \end{equation*}
Although this form involves three parameters, it is structured in a way that reminds
you of the definition of the slope and the idea of proportional change,
\begin{equation*}\Delta y = m \cdot \Delta x.\end{equation*}
In addition to the slope \(m\), we need one particular known point for the state
\((x,y) = (x_1,y_1)\).
If we solve for \(y\), this form is written
\begin{equation*} y = y_1 + m(x-x_1), \end{equation*}
which mathematically says that the value of \(y\) for a corresponding value of \(x\)
is equal to the known value of \(y=y_1\) at some known value \(x=x_1\) plus the
change that is proportional to \(\Delta x=x-x_1\).

If you remember the point–slope form of an equation for a line, other uses can
be immediately recovered.
For example, if you do know the \(y\)–intercept \(b\),
then you know a point \((x,y)=(0,b)\).
The resulting point–slope form becomes equivalent to the slope–intercept form,
\begin{equation*}y=b+m(x-0) = b+mx.\end{equation*}
But if you instead know the \(x\)–intercept \(a\), then you know
a point on the \(x\)–axis \((x,y)=(a,0)\) and the point–slope form
immediately leads to an equation capturing this information,
\begin{equation*}y=m(x-a).\end{equation*}

Example7.2.3

Write \(y\) as a linear function of \(x\) if we know that \(y=24\)
when \(x=5\) and the rate of change is \(\frac{\Delta y}{\Delta x}=-3\).

This is an ideal setting to use the point–slope form
because we know the slope \(m=-3\) and we know a point \((x,y)=(5,24)\).
One way to do this is to write down the slope equation using \((x,y)\)
and \((5,24)\) to get
\begin{equation*} \frac{y-24}{x-5} = -3. \end{equation*}
After cross-multiplying and solving for \(y\), we get
\begin{equation*} y = -3(x-5) + 24. \end{equation*}

The other way to do this problem is to start with the general formula
\begin{equation*} y = m(x-a) + b \end{equation*}
where \(m\) is the slope and \((a,b)\) is a known point.
Since we know \(m=-3\) and our point is \((a,b)=(5,24)\),
we can use these values as our model parameters to get
\begin{equation*} y = -3(x-5) + 24. \end{equation*}

If we have two points, we need to calculate the slope before proceeding.
One special application of this is the idea of linear interpolation.
Often, we have data for two variables where we expect there is a nice relation
between the variables but we do not know an appropriate formula.
Linear interpolation adopts a modeling strategy that between any two neighboring
data points, a linear model should give a reasonable approximation.
So the strategy involves identifying which two points to use, finding the
appropriate slope and equation of a line, and then use the equation to
approximate the unknown point.

Example7.2.4

The following graph illustrates data representing the volume of water
in a draining container \(V\) (liters) at various times \(t\) (seconds).
Approximate how much water was in the container after 35 seconds.

The data are given at times \(t \in \{0, 20, 40, 60\}\).
Notice that although the change in time is always \(\Delta t = 20\)
for consecutive points, the change in volume for consecutive points
is different with values -1.6, -1.2, and -0.9. So a single line can not
describe all of the points.

Interpolation is to consider a line only between the two points surrounding
the point of interest. The time of interest \(t=35\) is between the
times \(t=20\) and \(t=40\).
So we will use the points at those times, \((20, 4.8)\) and \((40, 3.6)\),
to define our approximating model for all times \(t \in [20,40]\).
We use these to find the rate of change
\begin{equation*} \frac{\Delta V}{\Delta t} = \frac{3.6-4.8}{40-20} = \frac{-1.2}{20} = -0.06. \end{equation*}

Knowing the rate of change and either end-point, we can get an equation
for the line.
If we use the point \((20, 4.8)\), then the point–slope
equation of the line is given by
\begin{equation*} \frac{V-4.8}{t-20} = -0.06 \quad \Leftrightarrow \quad
V = -0.06(t-20) + 4.8.\end{equation*}
Using a time \(t=35\), we can approximate the value for \(V\):
\begin{equation*}V = -0.06(35-20) + 4.8 = -0.06(15) + 4.8 = 3.9.\end{equation*}

Subsection7.2.2Testing for Linearity

Given some data involving two variables, we want to decide if those data follow a linear relation.
We do this by testing whether the statement in the definition is satisfied.

Example7.2.5

Consider the simple dataset consisting of four points illustrated in the table.
Determine if \(y\) is a linear function of \(x\).

\(i\)

\(x_i\)

\(y_i\)

1

0.20

0.48

2

0.45

0.45

3

0.60

0.40

4

0.80

0.36

Table7.2.6Dataset to illustrate testing if data are linear.

To test whether the definition of a linear function is satisfied, we need to
check the slope between any two points. This corresponds to computing six different slopes,
shown in the next table.

Table7.2.7Dataset to illustrate testing if data are linear.

Notice that the computed values for the slope between points are not always the same value.
So these data do not satisfy a linear relation.
However, notice that those pairings that do not include \(i=2\) all result in slopes \(m=-0.20\).
It is the second point \(i=2\) that makes these data fail to be linear.

The graphical visualization of the data reinforces why the data are not linear.
It is possible to draw a line going through the points \(i=1,3,4\), but that line
fails to go through the point \(i=2\).

When checking a collection of points to determine if they are collinear (on the same line),
we do not need to check all of the pairs of points. It is enough to choose one point, and then compare the slopes between
that point and each of the other points. If those all agree, then the points will be collinear.
Alternatively, it is also acceptable to compute the slope for each consecutive pair of points.
This is a consequence of the following theorem.

Theorem7.2.9

Given three points \((x_1,y_1)\), \((x_2,y_2)\) and \((x_3,y_3)\) with distinct \(x\) values,
if we define the slopes \(\displaystyle m_{i,j} = \frac{y_j-y_i}{x_j-x_i}\), then
\begin{equation*}m_{2,3} = \frac{x_3-x_1}{x_3-x_2} \cdot m_{1,3} - \frac{x_2-x_1}{x_3-x_2} \cdot m_{1,2}.\end{equation*}
In particular, if \(m_{1,3}=m_{1,2}=m\), then \(m_{2,3}=m\).

This proof uses the strategy of adding and subtracting an especially chosen value that
will allow us to rewrite \(m_{2,3}\) in terms of the formulas for \(m_{1,2}\) and \(m_{1,3}\).
We know that \(y_3-y_1 = m_{1,3}(x_3-x_1)\) and \(y_2-y_1 = m_{1,2}(x_2-x_1)\).
So adding and subtracting \(y_1\) in the numerator of \(m_{2,3}\) we find
\begin{equation*}
\begin{aligned}
m_{2,3} &= \frac{y_3-y_2}{x_3-x_2} = \frac{(y_3-y_1)-(y_2-y_1)}{x_3-x_2} \\
&= \frac{m_{1,3}(x_3-x_1) - m_{1,2}(x_2-x_1)}{x_3-x_2} \\
&= \frac{x_3-x_1}{x_3-x_2} \cdot m_{1,3} - \frac{x_2-x_1}{x_3-x_2} \cdot m_{1,2}
\end{aligned}
\end{equation*}
In the case that \(m_{1,2}=m_{1,3}=m\), then we can use a common factor:
\begin{equation*}m_{2,3} = \left( \frac{x_3-x_1}{x_3-x_2} - \frac{x_2-x_1}{x_3-x_2} \right) \cdot m
= \frac{(x_3-x_1)-(x_2-x_1)}{x_3-x_2} \cdot m = m\end{equation*}

So in the previous example, we really only needed to compute \(m_{1,2}\), \(m_{1,3}\) and \(m_{1,4}\).
Because \(m_{1,3}=m_{1,4}\) we know that the points 1, 3 and 4 were collinear. But because \(m_{1,2}\) was
different, we knew immediately that the point 2 falls off of the line.

Example7.2.10Testing for Proportionality and Linearity

Consider two variables \(x\) and \(y\) that are measured under four
different states, as recorded in the following table. Determine if these data
are consistent with a proportional or linear model.

\(i\)

\(x_i\)

\(y_i\)

1

0.2

0.3

2

0.4

0.5

3

0.8

0.9

4

1.6

1.7

Table7.2.11Second dataset to illustrate testing if data are linear.

For a real application, you would not compute values by hand;
you would use a computational tool, such as a calculator or spreadsheet,
which can perform many calculations at essentially one time.

Nearly all spreadsheets use a grid system with columns labeled by letters and rows labeled by numbers.
Each rectangle in the sheet is called a cell and stores either a value or text.
The value can be a formula based on other cells by typing an equal sign followed
by a formula. References to the values of other cells in the formula are accomplished
by using the column letter followed by the row number.

While we are at it, let us also illustrate how we could determine if the data have a
proportional relation in addition to testing the more general linear relation.
We will compute the ratio of \(y/x\) and observe if it is constant and then
compute the ratio of changes \((y_j-y_i)/(x_j-x_i)\) for consecutive points
and observe if that is constant.
A completed spreadsheet is shown, once showing formulas that you would type and
another showing the numeric results. (Technically, you only type a formula for the
first entry; then you copy and paste the result in the other cells and it will
adjust the references appropriately.)

Figure7.2.12Automatic calculation of ratio and slope based on data in a table using a spreadsheet.

Because the ratio of variables was changing, we know that \(y\) is not proportional to \(x\).
However, because the ratio of change for the variables is constant, we know
that \(y\) is a linear function of \(x\) with a slope \(m=1\).
Using the first point as our reference, \((x_1,y_1) = (0.2,0.3)\), we can write
an equation of our line.
\begin{equation*}
y = y_1+m(x-x_1) = 0.3 + 1.(x-0.2) = x+0.1
\end{equation*}
You can easily verify that this formula is correct since for every data point,
if you add 0.1 to the \(x\)-value, you get the \(y\)-value.