Linear functions
A
linear function is a function of the form
$f(x) = mx + b$ | | |
$y = mx + b$ | | |
with $m$ and $b$ being fixed numbers (the names "$m$" and "$b$" are traditional)
Role of mNumerically:- A change of 1 unit in $x$ results in a change of $m$ units in $y.$
- A change of $2$ units in $x$ results in a change of $m \times 2$ units in $y.$
- ...
- In general, a change of $\Delta x$ units in $x$ results in a change of $\Delta y = m\Delta x$ units in $y,$ so that
$m = \frac{\text{Change in }y}{\text{Change in }x} = \frac{\Delta y}{\Delta x}$
Graphically: - $m =$ Slope $= \frac{\text{Rise}}{\text{Run}} = \frac{\Delta y}{\Delta x}$
Role of bNumerically:- When $x = 0,\ \ y = b$ (Equation form), or $f(0) = b.$ (Function form)
Graphically:- $b =$ $y$-intercept
$\color{blue}{b}$
For these reasons, the equation $y = mx + b$ is often called the
slope-intercept form of the equation of a line.
Examples: Linear functions
The function
has equation form
Thus, the line crosses the $y$-axis at $b = -1,$ and $y$ increases by 3 units for every one-unit increase in $x.$
Graph:
Practice:
Converting to slope-intercept form $y = mx + b$ form The following equations can be solved for $y$ as linear functions of $x:$
$3x - y + 4 = 0$ | | $\color{indianred}{y=3x+4}$ |
$4y = 0$ | | $\color{indianred}{y=0}$ |
$3x + 4y = 5$ | | $\color{indianred}{y=-\frac{3}{4}x + \frac{5}{4}}$ |
How to draw the graph of a linear function
There are two good ways to draw the graph of a linear function:
- Write the function in $y = mx+b$ form, and draw the line with $y$-intercept $b$ and slope $m$.
- Find the $x$- and $y$-intercepts and draw the line going through those two points. To find the $x$-intercept of a line, set $y = 0$ in its equation and solve for $x$. To find the $y$-intercept, set $x = 0$ and solve for $y$. This method works only if the line does not pass through the origin. If it does, then you will need to plot an extra point or use the first method.
Example: How to draw the graph of a linear function
Here are the these techniques applied to the line with equation $2x - 3y = -6$
- Solving for $y$, we get $y = \frac{2x}{3} + 2$. Thus, the slope is $\frac{2}{3}$ and the y-intercept is 2. The following figure shows two stages of drawing its graph.:
- To get the $x$-intercept, set $y = 0$. The equation becomes
$2x - 3(0) = -6$,
giving $x = -3$.
This is the $x$-intercept. To get the $y$-intercept, set $x = 0$, to obtain $2(0) - 3y = -6$,
giving $y = 2$.
The following figure shows two stages of drawing its graph.
Finding a linear equation from data: How to make a linear model
Point and slope
An equation of the line through the point $(x_1, y_1)$ with slope $m$ is given by
where
When to use this method
- You can use this method whenever you know the slope and the coordinates of a point on the line. The formula does not apply if the slope is undefined.
- If you already know the slope $m$ and $y$-intercept $b$, then you can just write down the linear function directly as
by just substituting the values of $m$ and $b$.
Horizontal and vertical lines
An equation of the horizontal line through $(x_1, y_1)$ is
An equation of the vertical line through $(x_1, y_1)$ is
Examples: Finding a linear equation from data: How to make a linear model
An equation of the line through the point $(1, 2)$ with slope $-5$ is given by
where
$b = y_1 - mx_1 = 2 - (-5)(1) = 7$.
so that
An equation of the horizontal line through $((-3,4))$ is
An equation of the vertical line through $(-3,4)$ is
Practice:
Interpretation of the slope in applications
The slope of the line $y = mx + b$ is the rate at which $y$ is changing per 1-unit of change in $x$. The units of measurement of the slope are
units of $y$ per unit of $x$.
If $y$ is displacement (position along a line) and $x$ is time, then the slope represents
velocity. Its units are units of displacement per unit time (for example, meters per second)
If $y$ is cost and $x$ is the number of items purchased, then the slope represents
marginal cost. Its units are units of cost per item (for example, dollars per item).
Example: Interpretation of the slope in applications
The number of pages in this website is given by the equation
where where $t$ is time in weeks since June 1, 1997. The slope is
$m = 1.2$ pages per week.
Thus, we interpret the slope as follows:
The number of pages is growing at a rate of 1.2 web pages per week.
Regression: Residuals and sum of squares error
Linear regression is a method of finding the linear equation that comes closest to fitting a collection of data points.
Observed and predicted values Suppose we are given a collection of data points $(x_1, y_1), ..., (x_n, y_n)$. The $n$ quantities $y_1, y_2, ..., y_n$ are called the
observed values of $y$.
If we approximate the data by the linear equation $\hat{y} = mx + b$, then the
predicted values are
$\hat{y}_1 = m(x_1) + b$,
$\hat{y}_1 = m(x_2) + b$,
...,
$\hat{y}_n = m(x_n) + b.$
Residuals and sum of squares error If we model a collection of data points $(x_1, y_1), ..., (x_n, y_n)$ with a linear equation as above, then the
residuals are the $n$ quantities (Observed Value − Predicted Value):
$(y_1 - \hat{y}_1), \ (y_2 - \hat{y}_2), \ \dots (y_n - \hat{y}_n)$
| ↑ = Residual |
The
sum of squares error (SSE) is the sum of the squares of the residuals:
SSE $= (y_1 - \hat{y}_1)^2 + (y_2 - \hat{y}_2)^2 + \cdots + (y_n - \hat{y}_n)^2$
Example: Regression: Residuals and sum of squares error
Observed and Predicted values
Regression: Finding the regression line
The
regression line (least squares line, best-fit line) associated with the points $(x_1, y_1), ..., (x_n, y_n)$ is the line that gives the minimum value for SSE.
The regression line is given by
where
$m = \frac{n\left(\sum xy\right) - \left(\sum x\right)\left(\sum y\right)}{n\left(\sum x^2\right) - \left(\sum x\right)^2},$
$b = \frac{\left(\sum y\right) - m\left(\sum x\right)}{n}$.
Here, $\sum $ stands for "the sum of." Thus, for example,
$\sum x =$ Sum of the $x$-values $= (x_1 + x_2 + \dots + x_n)$
$\sum xy =$ Sum of the products $xy$ $= (x_1y_1 + x_2y_2 + \dots + x_ny_n)$
$\sum x^2 =$ Sum of the squares of the $x$-values $= (x_1^2 + x_2^2 + \dots + x_n^2)$
On the other hand,
$\left(\sum x\right)^2 =$ Square of $\sum x \quad = \quad $ Square of the sum of the $x$-values.
Finally,
$n =$ Number of data points.
Example: Regression: Finding the regression line