# Writing Linear Functions

### {{ 'ml-heading-theory' | message }}

## Linear Function

If a function has a constant rate of change, it is linear. Graphically, a linear function is a straight line.

Using that line, it's possible to determine the rate of change by finding the horizontal change $(\Delta x)$ and the vertical change $(\Delta y)$ between any two given points on the line. Any function whose graph is not a straight line cannot be linear.## Slope

The slope of a line passing through the points $(x_1,y_1)$ and $(x_2,y_2)$ is the ratio of the vertical change $(\Delta y)$ to the horizontal change $(\Delta x)$ between the points. The variable $m$ is most commonly used to represent slope.

$m=\dfrac{\Delta y}{\Delta x}$

The words *rise* and *run* are sometimes used to describe the slope of a line, especially when the line is given graphically. Rise corresponds to $\Delta y$ and run corresponds to $\Delta x.$

This gives the following definition for the slope of a line.

$m=\dfrac{\Delta y}{\Delta x}=\dfrac{\text{rise}}{\text{run}}$

## Slope Formula

The slope of a line can be found algebraically using the following rule.

$m=\dfrac{y_2-y_1}{x_2-x_1}$

## Slope-Intercept Form

One way to express linear function rules is called slope-intercept form.

$y=mx+b$

Sometimes, $f(x)=mx+b$ is used. In either case, $m$ and $b$ describe the general characteristics of the line. $m$ indicates the slope, and $b$ indicates the $y$-intercept. The linear function graphed below can be expressed as $f(x)=2x+1,$ because it has a slope of $2$ and a $y$-intercept at $(0,1).$

## Writing the Equation of a Line in Slope-Intercept Form from a Graph

To write the equation of the graph of a line in slope-intercept form, $y=mx+b,$

the $y$-intercept, $b$, and the slope of the line, $m,$ must be found. The following method can be used. As an example, consider the line shown.

## Exercises

*settings_overscan*

## {{ 'ml-heading-exercise' | message }} {{ focusmode.exercise.exerciseName }}

*keyboard_backspace*

{{ 'ml-tooltip-premium-exercise' | message }}

{{ 'ml-tooltip-recommended-exercise' | message }}

Programmeringsuppgift | {{ 'course' | message }} {{ exercise.course }}

*keyboard_backspace*{{ 'ml-btn-previous' | message }}

*keyboard_backspace*