Complex root calculator
Get every nth root of a complex number, not only the principal one: the cube roots of −8 are −2 and 1 ± √3 i, all of magnitude 2, at 60°, 180° and 300°. They come ordered by angle around the circle. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Real
- -8
- Imag
- 0
- Degree
- 3
- Magnitude
- 8
- Angle rad
- 3.1415926536
- Angle deg
- 180
- Root magnitude
- 2
The complex root calculator takes a complex number given by its real part and imaginary part, plus a positive integer degree n, and returns the complete list of its nth roots: exactly n complex numbers, each one raised to the power n reproducing the original. The computation applies De Moivre's formula, spreading the roots evenly around a circle in the complex plane, and reports every root in rectangular form together with its magnitude and its angle in both radians and degrees. The degree must be a positive integer up to 1000 and both parts must be finite numbers; anything else is rejected with a clear validation error.
Why a complex number has exactly n nth roots
Over the real numbers, asking for a square root is already ambiguous: 4 has two square roots, and negative numbers have none at all. Complex numbers resolve this cleanly. The fundamental theorem of algebra guarantees that the equation w^n = z has exactly n solutions in the complex plane, counted with multiplicity, and they are all distinct whenever z is not zero.
For example, the number 1 has three cube roots: the familiar real root 1, and two complex roots, -1/2 plus or minus sqrt(3)/2 times i, each of which cubes back to exactly 1. Sending a real part, an imaginary part, and a degree to this complex root calculator returns the full set, not just the so-called principal root that most pocket calculators show.
The list comes back ordered by increasing angle starting from the principal root, so the first entry is always the one with the smallest non-negative argument, and the rest follow counterclockwise around the circle.
De Moivre's formula and the geometry of the roots
The algorithm is De Moivre's theorem run in reverse. First the input number real + imag*i is converted to polar form: the magnitude r is the hypotenuse of the two parts, and the angle theta is the two-argument arctangent, so the quadrant is always correct. Every nth root then has magnitude r raised to the power 1/n, the same for all of them, which places every root on one circle centered at the origin.
The angles are (theta + 2*pi*k)/n for k from 0 to n-1: the full turn is divided into n equal sectors, so the roots form the vertices of a regular n-sided polygon inscribed in that circle, rotated so that the first vertex sits at angle theta/n. The eighth roots of a number on the positive real axis, for instance, land every 45 degrees like the points of a compass rose.
The calculator reports each root three ways at once: as a rectangular pair real and imag ready for further arithmetic, as a magnitude, and as an angle in both radians and degrees, because radians feed code and degrees feed humans.
Validation, edge cases, and determinism
The degree n must be a positive integer: zero, negative values, fractions like 2.5, and non-numeric input are rejected with an invalid input error that names the degree field, because a fractional or non-integer degree is a different operation (a complex power, which is multi-valued in a deeper way). The degree is also capped at 1000, which keeps the response bounded and the runtime predictable; the cap is declared in the capability limits and enforced in the code.
The real and imaginary parts must be finite numbers, with numeric strings such as "3.5" accepted for convenience when values arrive from web forms, while nulls, booleans, arrays, empty strings, NaN, and Infinity are all rejected naming the offending field. The zero complex number is the one legitimate special case: its magnitude is zero, so every nth root collapses to 0 + 0i, and the calculator returns n copies of the origin rather than failing, which keeps pipelines total.
There is no network access, no randomness, and no clock anywhere in the computation, only a bounded loop of trigonometric calls, so the same input always produces the same bytes.
What you can do with it
Roots of unity and the FFT
Generate the n nth roots of 1 + 0i, the twiddle factors that drive the Fast Fourier Transform and other divide-and-conquer signal processing algorithms.
Solving z^n = c equations
Find every solution of an equation like z^4 = -16 in the complex plane, not just the principal root, for algebra homework or polynomial system analysis.
Filter and control design
Place the poles of a Butterworth-style filter, which sit on a circle at the angles of the roots of -1, and read each pole directly in rectangular form.
FAQ
What does it cost?
The same computation is free to run in your browser on this page.
What exactly is returned?
The echoed input (real, imag, degree), the input magnitude and angle, the shared root magnitude, and the list of all n roots. Each root carries its index, rectangular real and imaginary parts, magnitude, and angle in radians and degrees.
Why are there n roots and not just one?
The equation w^n = z has exactly n solutions in the complex plane. They lie on a circle as the vertices of a regular n-gon, spaced 360/n degrees apart, and every one of them raised to the power n reproduces the input.
What happens for 0 + 0i?
The magnitude is zero, so every nth root is 0 + 0i. The calculator returns n copies of the origin instead of failing.
Which inputs are rejected?
A degree that is not a positive integer (0, negatives, fractions, text) or that exceeds 1000, and real or imaginary parts that are not finite numbers. Numeric strings like "3.5" and "4" are accepted.
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/complex-root \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"real":1,"imag":1,"degree":2}'const res = await fetch("https://api.kit.forhosting.com/math/complex-root", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"real": 1,
"imag": 1,
"degree": 2
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/complex-root",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"real": 1,
"imag": 1,
"degree": 2
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/complex-root", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"real":1,"imag":1,"degree":2}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"real":1,"imag":1,"degree":2}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/complex-root", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"real": 1,
"imag": 1,
"degree": 2
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.complex_root",
"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_degree | 1000 |
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
The same algorithm runs free in your browser on this page, and the identical code serves the paid API at $0.002 per request.
Why a complex number has exactly n nth roots
This matters in practice because picking only the principal root silently discards solutions: when you solve z^n = -1 in filter design, or find the roots of unity that drive the Fast Fourier Transform, or compute all equilibrium points of a polynomial system, you need every one of the n answers.
Validation, edge cases, and determinism
It runs on the edge in milliseconds, keeps nothing after the response, and costs $0.002 per request through the API while remaining free to use interactively in the browser.
Technical questions
Is the first root the principal root?
Yes. The list starts at k = 0, whose angle is the input argument divided by n, which is the principal nth root, and the remaining roots follow counterclockwise in order of increasing angle.