Slope-intercept form calculator
Give two points and get the line's equation in slope-intercept form: (0, 3) and (2, 7) give a slope of 2 and an intercept of 3, so y equals 2x plus 3. Vertical lines are flagged, not forced. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- X1
- 1
- Y1
- 2
- X2
- 4
- Y2
- 8
- Slope
- 2
- Intercept
- 0
- Equation
- y = 2x
The slope-intercept form y equals mx plus b is the first language most algebra students learn for a straight line: m is the constant rate of change, and b is where the graph crosses the vertical axis. Teachers, tutors, CAD helpers, and homework checkers need that equation from two known points without hand arithmetic that flips a sign or swaps rise and run. This slope-intercept form calculator accepts the coordinates of two distinct points on a non-vertical line, applies the textbook formulas for slope and intercept, and returns m, b, and a clean equation string ready to paste into notes or an LMS.
What y = mx + b means and how two points fix m and b
In the slope-intercept form of a line, the letter m stands for slope—the constant change in y for each unit change in x—and the letter b stands for the y-intercept, the value of y when x is zero. Given any two distinct points that do not share the same x-coordinate, the unique non-vertical line through them has slope m equal to the difference of the y-coordinates divided by the difference of the x-coordinates: m equals (y2 minus y1) divided by (x2 minus x1).
Once m is known, rearrange y equals mx plus b at either point to isolate the intercept: b equals y1 minus m times x1, which is the same as y2 minus m times x2. Substituting those two numbers yields the full equation string, for example y equals 2x plus zero when the points are (1, 2) and (4, 8).
Horizontal lines are a special case of the same formulas: the rise is zero, so m is zero and the equation collapses to y equals a constant equal to the common y-coordinate of both points. The geometric picture is simple: two distinct non-vertical points determine one line, and that line always intersects the y-axis once, giving a unique b for a unique m.
What you can do with it
Classroom and homework checks
Let students enter two points and verify slope m, intercept b, and the equation y=mx+b against textbook methods.
Exam and LMS auto-grading
Mark slope-intercept items with a deterministic oracle that rejects identical points and vertical lines as invalid.
Notebooks and linear calibration
Turn two sample points into y=mx+b in scripts without importing a full computer-algebra library.
FAQ
How do I get y = mx + b from two points?
Send finite numbers x1, y1, x2, and y2 for two distinct non-vertical points.
Why does a vertical line fail?
When x1 equals x2 the slope formula divides by zero.
What does a zero slope mean?
A horizontal line: y is constant for all x. The equation becomes y equals the intercept b, which matches the shared y-coordinate of both points when they lie on a horizontal line.
What happens if both points are identical?
Infinitely many lines pass through a single point, so there is no unique slope or intercept. You get a clear message instead of an equation that means nothing.
How is the intercept b found once the slope is known?
Take either point and subtract the slope times its x value from its y value. With the point (0, 3) and a slope of 2, the intercept is 3.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geom/slope-intercept-form \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x1":1,"y1":2,"x2":4,"y2":8}'const res = await fetch("https://api.kit.forhosting.com/geom/slope-intercept-form", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x1": 1,
"y1": 2,
"x2": 4,
"y2": 8
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/slope-intercept-form",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x1": 1,
"y1": 2,
"x2": 4,
"y2": 8
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/slope-intercept-form", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x1":1,"y1":2,"x2":4,"y2":8}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x1":1,"y1":2,"x2":4,"y2":8}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/slope-intercept-form", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"x1": 1,
"y1": 2,
"x2": 4,
"y2": 8
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.slope_intercept_form",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Coincident points and vertical lines fail with invalid_input so automation never invents a slope that does not exist.
What y = mx + b means and how two points fix m and b
Vertical lines cannot be written as y equals mx plus b at all, because division by zero would appear in the slope formula; this capability therefore rejects equal x-coordinates with a clear invalid_input message rather than returning null or infinity.
Input contract, response fields, and error behaviour
Example: x1 equals one, y1 equals two, x2 equals four, y2 equals eight yields slope two, intercept zero, and equation y equals 2x. Another example with a non-zero intercept: points (0, 3) and (2, 7) give m equals two and b equals three, so y equals 2x plus 3. Failed validation is not billed; successful calls use the published base price. POST a JSON body with four required finite numbers: x1 and y1 for the first point, x2 and y2 for the second. Each coordinate may arrive as a JSON number or as a numeric string; missing fields, empty strings, non-finite values, and non-numeric text fail with invalid_input naming the field. If the two points are identical—same x and same y—the request fails because infinitely many lines pass through a single point and no unique slope-intercept form exists. If x1 equals x2 but the y-values differ, the line is vertical and slope-intercept form is undefined, so the task also fails with invalid_input mentioning a vertical line. On success the response echoes the four coordinates rounded for stable goldens, plus slope, intercept, equation (a human-readable y equals mx plus b string with compact coefficients), and formula restating m equals rise over run and b equals y1 minus m times x1. Pair the numbers with your own plotter if you need a graph; this endpoint only solves for m, b, and the equation string.
Where a slope-intercept form calculator earns its keep
Algebra classrooms and tutoring platforms use a slope-intercept form calculator so learners can check y equals mx plus b for arbitrary point pairs without arithmetic slips on signed slopes. Exam generators and LMS plugins need a deterministic oracle that rejects coincident points and vertical lines instead of silently returning NaN that a buggy grader might treat as a correct blank. Keep coordinates finite, pin the rounded slope and intercept in tests, and you get reproducible equations for homework, CAD helpers, and edge workers without standing up symbolic math infrastructure of your own. Engineering notebooks often reduce two calibration samples to a linear model y equals mx plus b before fitting more complex curves; a tiny parse API avoids pulling a computer-algebra stack for four numbers. The focus on y equals mx plus b alone keeps the SEO landing and the API response aligned with the search intent students actually type.
Technical questions
What happens if the two points are identical?
The task fails with invalid_input. Two coinciding points do not determine a unique line, so no slope-intercept form is returned and the call is not billed.
What does the slope-intercept form calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.