Integer Linear Combination Calculator

Enter integers a, b, and target d to analyze diophantine equations. We compute gcd, Bézout pair, and minimal absolute solution with steps shown. Explore all solutions with parameter t and constraints for ranges you choose. Export results, share links, and download reports easily today.

Inputs

Formula used

We use the extended Euclidean algorithm to find integers u, v with au + bv = gcd(a,b). If d is divisible by g = gcd(a,b), one solution to ax + by = d is x0 = u(d/g) and y0 = v(d/g). The general solution is x = x0 + (b/g)t, y = y0 − (a/g)t, where t is any integer.

How to use

  1. Enter integers for a, b, and the target d.
  2. Optionally set ranges for x, y, mod constraints, or non-negativity.
  3. Choose an objective to guide the recommended solution.
  4. Use t bounds to scan specific solution windows.
  5. Provide multiple targets in batch to compute several at once.

Results

Enter values and click Compute to see results.

Example data

abdgcdSolvable?Example (x0,y0)
567288Yes4,-3
352055Yes-1,2
9978333Yes-121,154
173111Yes11,-6

Key identities & properties

  • Solvable iff g = gcd(a,b) divides d.
  • All solutions are x = x0 + (b/g)t, y = y0 − (a/g)t.
  • Step sizes are b/g for x and a/g for y, always integers.
  • Any solution pair preserves ax + by = d exactly for every integer t.

Effect of parameter t

QuantityExpressionComment
x(t)x0 + (b/g)tArithmetic progression step size b/g
y(t)y0 − (a/g)tArithmetic progression step size a/g
|x| + |y|varies with tSearch near t minimizing L1 norm
max(|x|,|y|)varies with tBalance x and y to reduce peak

Residue classes of x and y

For any solution, the residues are fixed modulo the step sizes:

VariableResidue constraintExplanation
xx ≡ x0 (mod b/g)Changing t shifts x by multiples of b/g
yy ≡ y0 (mod a/g)Changing t shifts y by multiples of a/g

Small-number examples (auto)

abdgcdOne (x0, y0)x stepy step
1521333,-275
143577-2,152
2710113,-81027
8466664,-51114
121866-1,132

FAQs

1) When does ax + by = d have solutions?

Exactly when gcd(a,b) divides d. If not, there is no integer solution. If yes, there are infinitely many solutions parametrized by an integer t.

2) Why are there infinitely many solutions?

If one pair (x0, y0) works, then adding (b/g)t to x and subtracting (a/g)t from y keeps ax + by unchanged. Different integer t values generate distinct solutions.

3) How do I get non‑negative solutions?

Enable x ≥ 0 and/or y ≥ 0 and set t bounds. The tool searches t within bounds and returns a feasible solution that satisfies your objective and non‑negativity requirements.

4) Can I force residue conditions on x or y?

Yes. Set x ≡ r (mod m) and y ≡ s (mod n). The scan over t accepts only solutions meeting the congruences, together with any range and non‑negativity constraints.

5) What if the calculator says “Not solvable”?

Then gcd(a,b) does not divide d. Adjust d to a multiple of gcd(a,b), or change a or b. Otherwise, no integer pair can satisfy the equation.

6) Do signs of a and b matter?

The algorithm works with any signs. Internally it runs on |a| and |b| and then corrects the Bézout coefficients’ signs so the final identity uses your original a and b.

7) How are “min |x|”, “min |y|”, or “min x²+y²” handled?

We try t values near an analytically suggested point and select the best under your constraints. Objectives guide which feasible solution is reported, without changing the full parametric solution family.

Related Calculators

Inverse Function Finder CalculatorPolynomial Long Division Calculatorroots of cubic equation calculatorquadratic function from 3 points calculatorWeighted linear regression calculatorremainder and factor theorem calculatordivide using long division calculatorsynthetic division remainder calculatorLCM fraction Calculatorfactor polynomials by grouping calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.