Sphere equation
Write the equation of a sphere from its center and radius: center (1, 2, 3) and radius 5 give (x − 1)² + (y − 2)² + (z − 3)² = 25, plus the expanded general form ready to copy. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- H
- 1
- K
- 2
- L
- 3
- Resistance (Ω)
- 5
- R squared
- 25
- D
- -2
- E
- -4
- F
- -6
The standard equation of a sphere is the Cartesian statement that every point (x, y, z) on the surface sits at a fixed distance r from a known center (h, k, l).
Where a sphere-equation calculator earns its keep in study, design, and code
Students meet the equation of a sphere when an analytic-geometry chapter asks them to write the standard form from a listed center and radius, when an exam wants the general form after expanding the three squares, or when a later multivariable course treats the sphere as a level set of x² + y² + z² + Dx + Ey + Fz + G.
Teachers can pre-generate answer keys that list D, E, F, G and r² for integer centers and radii, and that refuse a zero or negative radius instead of printing NaN. Mechanical and civil design often needs the implicit equation of a spherical tank, a bearing surface, or a clearance envelope before a solid model is built; knowing that a requested radius is not positive is as valuable as the equation itself.
Computer-graphics, robotics and collision pipelines place spheres as bounding volumes and need a deterministic monic implicit form they can evaluate at a query point without re-deriving the expansion. Remember the contract limits: this tool does not size volume or surface area, does not recover a sphere from four sample points, and does not convert units. If the center is in metres and the radius is in metres, the equation is in metres.
What you can do with it
Homework and exam sphere-equation drills
Write the standard and general equations from a textbook center and radius, and verify that a non-positive radius is rejected instead of treated as a point-sphere.
Bounding spheres in CAD and graphics
Build the implicit equation of a tank, bearing, or collision sphere from a known center and radius so a query point can be classified against the surface.
FAQ
What does the sphere equation calculator cost?
It is free in your browser on this page.
What if the radius is zero or negative?
A point or a negative length is not a sphere.
What is the standard equation of a sphere?
With center (h, k, l) and radius r it is (x − h)² + (y − k)² + (z − l)² = r². The calculator also expands that identity into the general form.
Does this compute volume or surface area?
No. This contract is only the algebraic equation and its coefficients. Volume and surface from a radius belong to dedicated sphere-measure tools.
How do I get the general form of a sphere equation?
Expand the three squares and move everything to one side. Center (1, 2, 3) and radius 5 give x² + y² + z² − 2x − 4y − 6z − 11 = 0, where each linear coefficient is minus twice a center coordinate.
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/math/sphere-equation \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"h":1,"k":2,"l":3,"r":5}'const res = await fetch("https://api.kit.forhosting.com/math/sphere-equation", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"h": 1,
"k": 2,
"l": 3,
"r": 5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/sphere-equation",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"h": 1,
"k": 2,
"l": 3,
"r": 5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/sphere-equation", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"h":1,"k":2,"l":3,"r":5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"h":1,"k":2,"l":3,"r":5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/sphere-equation", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"h": 1,
"k": 2,
"l": 3,
"r": 5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.sphere_equation",
"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.
Limits
max_abs | 1000000000000 |
min_radius | 1e-15 |
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
This calculator accepts those four numbers — the three center coordinates and a strictly positive radius — and returns the textbook identity (x − h)² + (y − k)² + (z − l)² = r² together with the expanded general form x² + y² + z² + Dx + Ey + Fz + G = 0. The four coefficients D = −2h, E = −2k, F = −2l, G = h² + k² + l² − r² and the radius squared travel in the same payload so a student, a grader, or a CAD script can copy either form without expanding by hand. Radius must be a positive finite number; a missing, zero, negative, or non-numeric value fails with invalid_input instead of a silent NaN. Through the API a successful request costs $0.002; validation failures are not billed.
What the standard equation of a sphere is and which coefficients this tool returns
A sphere in three-dimensional Cartesian space is completely determined by a center point (h, k, l) and a positive radius r: it is the set of all points whose Euclidean distance from that center is exactly r. Squaring both sides of the distance formula removes the square root and produces the standard equation (x − h)² + (y − k)² + (z − l)² = r², which is the form textbooks ask students to write down and the form most computer-graphics and CAD notes start from. A translated sphere such as center (1, 2, 3) and radius 5 becomes (x − 1)² + (y − 2)² + (z − 3)² = 25, with coefficients D = −2, E = −4, F = −6 and G = −11. Expanding the three squared binomials and collecting like terms yields the general form x² + y² + z² + Dx + Ey + Fz + G = 0, whose four coefficients are D = −2h, E = −2k, F = −2l and G = h² + k² + l² − r². This calculator returns both writings of the same surface, the four coefficients, and the radius squared, so you can paste the standard identity into a homework line or feed D, E, F, G into a solver that prefers the monic general form. The unit sphere at the origin is the special case h = k = l = 0 and r = 1, which collapses to x² + y² + z² = 1 and to x² + y² + z² − 1 = 0. Radius must be strictly positive: r = 0 is a single point, not a sphere, and a negative radius is not a geometric length. Those cases fail with invalid_input rather than a hollow success payload. This tool does not compute volume or surface area, does not fit a sphere through four sample points, and does not convert units; the search intent is the algebraic equation of a sphere from a known center and radius, with a clear answer or an honest error.
Input contract, coefficient identities, and how the two equation strings are built
After parsing, the engine insists that r is strictly greater than zero and that every coordinate stays inside the published absolute bound of 10^12, so a non-positive radius never becomes a fake r² and an overflow never becomes a silent Infinity. Once the four values pass, radius squared is r times r, D is −2h, E is −2k, F is −2l and G is the sum of the three squared center coordinates minus that radius squared. The standard-equation string writes each axis with a sign-aware binomial: a zero center prints x² rather than (x − 0)², a positive center prints (x − h)², and a negative center prints (x + |h|)², and likewise for y and z. The general-equation string always starts from x² + y² + z² and then appends only the non-zero linear and constant terms, so the unit sphere at the origin is x² + y² + z² − 1 = 0 rather than a cluttered line of plus-zero coefficients. POST a JSON body with four required finite numbers: h, k and l for the center, and r for the radius. Each field may arrive as a JSON number or as a numeric string; aliases cx or center_x, cy or center_y, cz or center_z, and radius are accepted so a CAD-style payload does not need remapping. Missing fields, empty strings, NaN and Infinity fail with invalid_input naming the field. Pair the free browser run on this page with the priced API when you need the identical algebraic result inside an automated pipeline without re-expanding the three binomials yourself.
Where a sphere-equation calculator earns its keep in study, design, and code
On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — lets you move from a classroom demo to an automated pipeline without changing the algebraic result. Whether you arrived searching for a sphere equation calculator or for the standard form from center and radius, the contract is the same: finite center, positive radius in, coefficients and r² out, or a clear invalid_input.
Integration use cases
Deterministic geometry fixtures
Generate reproducible D, E, F, G and r² for unit tests, contest validators, and CI assertions without hand-expanding (x−h)²+(y−k)²+(z−l)².
Technical questions
Which coefficients does the calculator return?
It returns D = −2h, E = −2k, F = −2l and G = h² + k² + l² − r² for the general form x² + y² + z² + Dx + Ey + Fz + G = 0, plus the radius squared r².