ForHosting KIT · Developer Utilities

Gaussian integer multiplication calculator

This Gaussian integer multiplication calculator takes two numbers of the form a + bi, where every real and imaginary component is an integer, and returns their exact product in the same form.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

Enter the four coefficients separately, and the calculator applies the distributive rule while accounting for i squared equaling negative one. The result contains a real component and an imaginary coefficient, ready for number theory exercises, algebra checks, program tests, or any workflow that needs a dependable Gaussian integer product.

Represent both Gaussian integers with four components

A Gaussian integer has the form a + bi, where a and b are ordinary integers and i is the imaginary unit. To multiply two of them, identify the real and imaginary coefficients before entering anything. The first value uses a_real for a and a_imag for b. The second uses b_real for c and b_imag for d. For example, to multiply 3 + 2i by 1 - 4i, enter 3, 2, 1, and -4 in those fields. Keep the sign attached to each coefficient: the coefficient of -4i is -4, not 4. A purely real Gaussian integer has an imaginary coefficient of zero, while a purely imaginary one has a real component of zero. Zero is therefore a valid value in every field. All four fields are required because an omitted coefficient is ambiguous in an API request. Components must be actual JSON integers within the published bounds; decimal fractions, numeric text, infinity, and other non-integer values are rejected instead of being rounded or silently converted. This strict contract keeps exact arithmetic distinct from approximate complex-number calculation.

Understand how the product is calculated

The calculation expands (a + bi)(c + di) using the distributive law. Multiplying each term gives ac + adi + bci + bdi squared. Since i squared equals -1, the last term becomes -bd. Combining the terms without i produces the real component ac - bd, and combining the coefficients of i produces the imaginary component ad + bc. The calculator returns those two integers as real and imaginary. For 3 + 2i and 1 - 4i, the real component is 3 times 1 minus 2 times -4, while the imaginary coefficient is 3 times -4 plus 2 times 1. This representation avoids formatting uncertainty around plus and minus signs and is convenient for further machine processing. The algorithm uses only bounded integer multiplication, addition, and subtraction. The component limit guarantees that every intermediate value and final result remains within JavaScript's exact safe-integer range, so there is no floating-point rounding hidden in a successful response. The operation is deterministic: identical inputs always produce identical output, with no network service, model inference, clock, or randomness involved.

Use the result in mathematics and software

Gaussian integers form a ring, so their product is always another Gaussian integer. That closure makes multiplication useful in elementary number theory, including reasoning about sums of two squares, Gaussian primes, norms, and factorization in Z[i]. You can verify a manual expansion by comparing its two coefficients with the response, or feed the returned real and imaginary values into the next exact step of a calculation. A useful independent check is the multiplicative norm N(a + bi) = a squared + b squared: the norm of the returned product should equal the product of the two input norms. In software tests, include sign changes, zero components, purely real factors, purely imaginary factors, and multiplication by the units 1, -1, i, and -i. The endpoint costs $0.002 per API request, while the browser implementation can run locally for interactive checks. Invalid components fail with an invalid-input response and are not approximated. If your data contains fractional real or imaginary parts, it describes general complex numbers rather than Gaussian integers, so use a complex-number operation designed for non-integer coefficients instead of changing the values to make this calculator accept them.

Check a number theory exercise

Verify the real and imaginary coefficients obtained when expanding a product in the Gaussian integers.

Test exact complex arithmetic code

Create stable expected results for unit tests involving integer-valued complex multiplication and negative coefficients.

Build a Gaussian integer workflow

Pass the exact product components into later norm, divisibility, factorization, or visualization steps.

What is a Gaussian integer?

It is a complex number a + bi whose real component a and imaginary coefficient b are both integers.

What formula does the calculator use?

It uses (a + bi)(c + di) = (ac - bd) + (ad + bc)i.

Can I enter decimal or fractional components?

No. Every component must be an integer; fractional, non-finite, missing, and textual values return an invalid-input error.

How are purely real or purely imaginary values entered?

Use zero for the absent component. For example, 5 is represented by real 5 and imaginary 0, while 5i is represented by real 0 and imaginary 5.

What does it cost?

Each API request costs $0.002. The interactive browser version can run locally without an API request.

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.

POSThttps://api.kit.forhosting.com/numth/gaussian-integer-multiply

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.

curl -X POST https://api.kit.forhosting.com/numth/gaussian-integer-multiply \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a_real":3,"a_imag":2,"b_real":1,"b_imag":-4}'
{
  "a_real": 3,
  "a_imag": 2,
  "b_real": 1,
  "b_imag": -4
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "numth.gaussian_integer_multiply",
  "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.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_abs_component10000000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →