Distance between complex numbers calculator
3 + 4i is 5 units from the origin, and 1 + 2i is 5 units from 4 + 6i: enter two complex numbers and get the distance between them, the squared distance and their difference. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Real1
- 3
- Imag1
- 4
- Real2
- 0
- Imag2
- 0
- Complex1
- 3+4i
- Complex2
- 0
- Delta real
- 3
- Delta imag
- 4
The distance between two complex numbers is the modulus of their difference: for z1 equals a plus b i and z2 equals c plus d i, the separation is the square root of (a minus c) squared plus (b minus d) squared. That length is exactly the Euclidean distance between the points (a, b) and (c, d) on the Argand plane. Students meet this formula when measuring chord lengths on unit-circle roots, comparing phasors, or checking whether two solutions coincide. Engineers use it for impedance separation, error magnitude between complex samples, and geometric checks in control or signal code. This distance between complex numbers calculator accepts the real and imaginary parts of both numbers, returns the non-negative distance, the squared distance, the difference components, compact display strings, and a short formula you can show next to the answer.
What distance between complex numbers means geometrically and algebraically
A complex number lives in the plane with its real part on the horizontal axis and its imaginary part on the vertical axis. Given two such points z1 equals real1 plus imag1 times i and z2 equals real2 plus imag2 times i, the vector from z2 to z1 is the complex difference (real1 minus real2) plus (imag1 minus imag2) times i.
The length of that vector is the modulus of the difference, written |z1 minus z2|, which expands by the Pythagorean theorem to the square root of the sum of the squared real difference and the squared imaginary difference. When the two numbers are identical the difference is zero and the distance is zero; when one number is the origin the formula reduces to the ordinary complex modulus of the other number, so this capability generalizes the single-point modulus calculator to an arbitrary pair.
Pure real pairs reduce to the ordinary absolute difference of the reals; pure imaginary pairs reduce to the absolute difference of the imaginary parts. The distance is never negative; it is zero only when both parts match.
Where measuring complex distances helps
Classrooms and tutoring platforms use a distance between complex numbers calculator so learners can verify |z1 minus z2| for arbitrary pairs without sign or order-of-operations mistakes when subtracting rectangular forms by hand. Exam generators and LMS plugins need a deterministic oracle that rejects non-finite junk, returns a stable rounded length, and never invents a negative separation. Electrical engineering notebooks reduce phasor separation, impedance difference magnitude, and complex residual checks to a single |z1 minus z2| call when a full computer-algebra system would be overkill.
Signal-processing and control scripts compare complex sample error via the squared distance without standing up heavy numeric libraries on the edge. Failed validation does not consume balance. Keep requests small, pin the rounded distance in tests, and you get reproducible separations for homework, LMS plugins, and edge workers without importing symbolic math infrastructure of your own.
What you can do with it
Classroom and homework checks
Let students submit real and imag parts for z1 and z2 and verify |z1−z2| against textbook Pythagorean or modulus-of-difference methods.
Exam and LMS auto-grading
Mark complex-plane distance items with a deterministic oracle that returns the non-negative sqrt of summed squared deltas and rejects non-finite input.
Engineering notebooks and phasors
Compute separation between two impedances or complex residuals in scripts without pulling a full computer-algebra library.
FAQ
How do I compute the distance between two complex numbers?
Send finite numbers real1, imag1, real2, and imag2 for z1 and z2.
Is complex distance the same as the modulus of the difference?
Yes. The Euclidean distance in the Argand plane between z1 and z2 is exactly the modulus |z1−z2| of their complex difference.
What if one of the numbers is zero?
Then the distance reduces to the ordinary modulus of the other number. For example, distance from 3+4i to the origin is 5.
What is the distance between 1 + 2i and 4 + 6i?
It is 5. Their difference is −3 − 4i, and the square root of 3² + 4² is 5, the same as the long side of a right triangle with sides 3 and 4 drawn in the plane.
Why is the squared distance also shown?
When you only compare separations, the square root is unnecessary: the squared distance ranks pairs in the same order. For 3 + 4i and the origin it is 25, while the distance itself is 5.
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/algebra/complex-distance \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"real1":3,"imag1":4,"real2":0,"imag2":0}'const res = await fetch("https://api.kit.forhosting.com/algebra/complex-distance", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"real1": 3,
"imag1": 4,
"real2": 0,
"imag2": 0
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/algebra/complex-distance",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"real1": 3,
"imag1": 4,
"real2": 0,
"imag2": 0
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/algebra/complex-distance", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"real1":3,"imag1":4,"real2":0,"imag2":0}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"real1":3,"imag1":4,"real2":0,"imag2":0}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/algebra/complex-distance", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"real1": 3,
"imag1": 4,
"real2": 0,
"imag2": 0
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "algebra.complex_distance",
"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
What distance between complex numbers means geometrically and algebraically
Because squares erase sign, swapping the two endpoints does not change the distance: |z1 minus z2| equals |z2 minus z1|. In applications you often need only the squared distance to compare separations without a square root; the API returns both fields so callers can choose the form that matches their textbook, LMS rubric, or numeric tolerance check without re-deriving the expansion by hand.
Input contract, response shape, and validation behaviour
Classic check: real1 equals three, imag1 equals four, real2 equals zero, imag2 equals zero yields distance five and squared distance twenty-five, matching the single-number modulus of three plus four i. Another check: real1 equals one, imag1 equals two, real2 equals four, imag2 equals six yields delta real negative three and delta imag negative four with distance five. POST a JSON body with four required finite numbers: real1 and imag1 for the first complex number z1, and real2 and imag2 for the second complex number z2. Non-finite values, missing fields, empty strings, and non-numeric text fail with invalid_input naming the field, and those failures are not billed. On success the body echoes real1, imag1, real2, and imag2 with stable twelve-decimal rounding; compact complex1 and complex2 display strings such as three plus four i or five minus two i; delta_real and delta_imag for the difference z1 minus z2; the non-negative distance; the squared_distance equal to delta_real squared plus delta_imag squared; a boolean is_zero that is true only when the distance is zero; and a formula string restating |z1 minus z2| equals the square root of (real1 minus real2) squared plus (imag1 minus imag2) squared. Use squared_distance when you only need to rank separations or avoid the square-root step; the distance field is always the non-negative root textbooks label |z1 minus z2|.
Technical questions
Does swapping z1 and z2 change the result?
No. Distance is symmetric: |z1−z2| equals |z2−z1|. Only the signed delta_real and delta_imag fields reverse when you swap the endpoints.
What does the distance between complex numbers calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.