Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Linear Function
f(x) = 2x + 0
slope-intercept form
Slope (m) 2
Y-intercept (b) 0

What This Calculator Does

Given any two distinct points on a line, this tool finds the unique linear function \(f(x) = mx + b\) that passes through both of them. It returns the slope \(m\) and the y-intercept \(b\) so you can write the full equation of the line.

How to Use It

Enter the coordinates of your first point as \(x_1\) and \(y_1\), then your second point as \(x_2\) and \(y_2\). Click calculate and the tool reports the slope and intercept, and assembles them into \(f(x) = mx + b\). If both points have the same x-value, the line is vertical and cannot be expressed in slope-intercept form, so the calculator tells you so.

The Formula Explained

The slope measures how much y changes per unit change in x: $$m = \frac{y_2 - y_1}{x_2 - x_1}$$ Once you know the slope, the y-intercept follows by substituting one point into \(y = mx + b\) and solving for \(b\): $$b = y_1 - m \cdot x_1$$ The result is the equation of the unique straight line through both points.

Advertisement
Line on coordinate axes through two points showing slope rise over run and y-intercept
The slope \(m\) is rise over run between the two points; \(b\) is where the line crosses the y-axis.

Worked Example

For the points (1, 2) and (3, 6): the slope is $$m = \frac{6 - 2}{3 - 1} = \frac{4}{2} = 2$$ The intercept is $$b = 2 - 2 \times 1 = 0$$ So the line is \(f(x) = 2x + 0\), i.e. \(f(x) = 2x\).

Two specific points connected by a line with slope and intercept highlighted
A worked example: two known points determine a single line \(f(x)=mx+b\).

FAQ

What if the slope is zero? Then both points have the same y-value and the line is horizontal: \(f(x) = b\), a constant.

What if the two x-values are equal? The line is vertical (\(x = \text{constant}\)). It has undefined slope and cannot be written as \(f(x) = mx + b\).

Can the inputs be negative or decimals? Yes. The slope and intercept formulas work for any real coordinates, positive, negative, or fractional.

Last updated: