# Linear Function f(x) = mx + b: Graph, Slope, Derivative and Integral

> The linear function f(x) = mx + b: slope and intercept, its straight-line graph, why its derivative is the slope m, its integral and worked examples.

Source: https://practicecalculus.com/functions/linear-function
Updated: 2026-11-03

$$ f(x) = mx + b $$

## At a glance

- **Domain:** $(-\infty, \infty)$
- **Range:** $(-\infty, \infty)$ if $m \ne 0$
- **Derivative:** $m$
- **Integral:** $\frac{m}{2}x^2 + bx + C$
- **Slope:** $m = \frac{y_2 - y_1}{x_2 - x_1}$
- **y-intercept:** $(0, b)$

## Key takeaways

- A linear function $f(x) = mx + b$ has a straight-line graph with slope $m$ and $y$-intercept $b$.
- Its derivative is the constant $m$: a line has the same rate of change everywhere.
- Its integral is $\frac{m}{2}x^2 + bx + C$, a quadratic.
- Tangent lines and linear approximations are linear functions built from a derivative.

A **linear function** has a constant rate of change, so its graph is a straight line. Written $f(x) = mx + b$, the number $m$ is the slope (how much $f$ rises per unit of $x$) and $b$ is the $y$-intercept (the output at $x = 0$).

## Formula and forms

$$f(x) = mx + b$$

The same line can be written in other ways, depending on what you know:

| Form | Equation | Use it when you know |
| --- | --- | --- |
| Slope-intercept | $y = mx + b$ | the slope and $y$-intercept |
| Point-slope | $y - y_1 = m(x - x_1)$ | the slope and one point |
| Standard | $Ax + By = C$ | an equation to rearrange |

Point-slope form is the one calculus uses most, because a tangent line is built from a point $(a, f(a))$ and a slope $f'(a)$.

## Graph of a linear function

```graph
title: 'Graph of the linear functions y = 2x + 1 and y = -0.5x + 3'
caption: 'A positive slope rises left to right and a negative slope falls. Each line crosses the $y$-axis at its intercept $b$.'
x: [-4, 4]
y: [-5, 7]
functions:
  - expr: 2x + 1
    label: y = 2x + 1
  - expr: -0.5x + 3
    label: y = -0.5x + 3
points:
  - [0, 1, '(0, 1)']
  - [0, 3, '(0, 3)']
```

- $m > 0$: increasing. $m < 0$: decreasing. $m = 0$: a horizontal line, the [constant function](/functions/constant-function).
- The larger $|m|$ is, the steeper the line.
- The $x$-intercept is where $mx + b = 0$, that is $x = -\frac{b}{m}$ when $m \ne 0$.

## Derivative of a linear function

$$\frac{d}{dx}(mx + b) = m$$

The derivative of $mx$ is $m$ by the [power rule](/rules/power-rule) and [constant multiple rule](/rules/constant-multiple-rule), and the derivative of $b$ is $0$. This matches the geometry: the tangent line to a line is the line itself, and its slope never changes. The second derivative is $0$, so a line has no concavity.

## Integral of a linear function

$$\int (mx + b)\,dx = \frac{m}{2}x^2 + bx + C$$

Integrating a line gives a [quadratic function](/functions/quadratic-function). For a definite integral over $[a, b]$, the region under a line is a trapezoid (or two triangles if it crosses the axis), so you can check any answer with geometry.

## Worked examples

**Example 1: slope from two points.** Find the line through $(1, 3)$ and $(4, 9)$.

$$m = \frac{9 - 3}{4 - 1} = 2, \qquad y - 3 = 2(x - 1) \;\Rightarrow\; y = 2x + 1$$

**Example 2: derivative.** If $f(x) = -4x + 7$, then $f'(x) = -4$ for every $x$.

**Example 3: definite integral.** Evaluate $\int_0^2 (3x + 1)\,dx$.

$$\left[\tfrac{3}{2}x^2 + x\right]_0^2 = (6 + 2) - 0 = 8$$

Check: the region is a trapezoid with parallel sides $f(0) = 1$ and $f(2) = 7$ and width $2$, so its area is $\frac{1 + 7}{2} \cdot 2 = 8$.

**Example 4: a tangent line.** The tangent line to $y = x^2$ at $x = 3$ has slope $2(3) = 6$ and passes through $(3, 9)$, so it is the linear function $y = 6x - 9$.

## Common mistakes

1. **Swapping the order in the slope formula.** Keep the same point first on top and bottom: $\frac{y_2 - y_1}{x_2 - x_1}$, not $\frac{y_2 - y_1}{x_1 - x_2}$.
2. **Calling $f(x) = x^2 + 1$ linear.** Linear means the variable appears only to the first power.
3. **Integrating $mx$ as $mx^2$.** The reverse power rule divides by the new exponent: $\int mx\,dx = \frac{m}{2}x^2 + C$.
4. **Confusing "linear function" with "linear equation in two unknowns".** A vertical line $x = 2$ is a linear equation but not a function.

## How it connects

Lines are the reason derivatives exist: the derivative at a point is the slope of the best line through it. That idea powers [tangent lines](/blog/limit-definition-of-the-derivative), [linear approximation](/blog/linear-approximation) and Newton's method. Lines are degree-one [polynomial functions](/functions/polynomial-functions), and integrating them leads to quadratics.

## Frequently asked questions

### What is the derivative of a linear function?

The derivative of $f(x) = mx + b$ is $f'(x) = m$, the slope of the line. A line rises by the same amount for every unit step in $x$, so its rate of change is constant.

### What is the integral of mx + b?

The integral is $\int (mx + b)\,dx = \frac{m}{2}x^2 + bx + C$. You can check it by differentiating: the derivative of $\frac{m}{2}x^2 + bx$ is $mx + b$.

### How do you find the slope of a linear function from two points?

Use $m = \frac{y_2 - y_1}{x_2 - x_1}$. For the points $(1, 3)$ and $(4, 9)$ the slope is $\frac{9 - 3}{4 - 1} = 2$.

### Is a horizontal line a linear function?

Yes. A horizontal line $y = b$ is a linear function with slope $m = 0$, which is also a constant function. A vertical line $x = a$ is not a function at all.
