Random Equation Generator

Generates a random linear equation (e.g. "3x + 5 = 20") or a simple quadratic equation (e.g. "2x^2 - 4x - 6 = 0") with one unknown, and shows the solved value(s) of x, built from the solution outward so the answer is always exact. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-26

Overview

Introduction

This tool generates a random algebra equation, either linear (one unknown, first degree) or quadratic (one unknown, second degree), along with its exact solution.

It's built to always produce a clean, verifiable answer: the solution is chosen first, and the equation is constructed around it, rather than generating arbitrary coefficients and hoping for a tidy result.

What Is Random Equation Generator?

A generator for one-variable algebra equations: linear equations of the form ax + b = c, or quadratic equations of the form ax^2 + bx + c = 0.

Every generated equation ships with its worked solution: the value (or values) of x that satisfy it.

How Random Equation Generator Works

For a linear equation, the tool picks random integers for the coefficient a, the constant b, and the intended solution x0, then computes c = a*x0 + b so that x0 is guaranteed to satisfy the equation.

For a quadratic equation, the tool picks two random integer roots r1 and r2 and a small leading coefficient a, then expands a*(x - r1)*(x - r2) into standard ax^2 + bx + c form, guaranteeing r1 and r2 are the exact real roots.

The 'random' type simply flips a coin between these two paths each time an equation is generated.

When To Use Random Equation Generator

Use it to generate algebra practice problems or quiz questions with guaranteed clean, whole-number solutions.

It's also useful as a source of test cases for an equation-solving function, since you already know the exact expected answer.

Features

Advantages

  • Solutions are always exact whole numbers, since the equation is built from the answer outward rather than solved after the fact.
  • Covers both linear and quadratic forms, with an option to mix both.
  • No risk of an unsolvable or messy-fraction result.

Limitations

  • Quadratic coefficients are intentionally kept small (leading coefficient capped at 5) so the expanded equation stays readable; it won't produce equations with large leading coefficients.
  • Only single-variable linear and quadratic forms are supported, not higher-degree polynomials or systems of equations.
  • Roots are always whole numbers by design, so it won't generate equations with irrational or fractional solutions.

Examples

A linear equation

Input

(no input; generated from settings: type=linear, maxCoefficient=10)

Output

3x + 5 = 20
x = 5

A quadratic equation with two distinct roots

Input

(no input; generated from settings: type=quadratic, maxCoefficient=10)

Output

2x^2 - 4x - 6 = 0
x = -1 or x = 3

Best Practices & Notes

Best Practices

  • Use a smaller maxCoefficient for beginner practice problems, and a larger one for more challenging equations.
  • Choose 'random' type when building a mixed practice set that includes both linear and quadratic problems.

Developer Notes

Quadratic equations are built by expanding `a * (x - r1) * (x - r2)` into `a*x^2 - a*(r1+r2)*x + a*r1*r2`, which guarantees r1 and r2 are the exact real roots without ever running an actual quadratic-formula solve.

Random Equation Generator Use Cases

  • Generating algebra practice problems or worksheet questions with known answers
  • Producing test cases for an equation-solving function, since the exact expected root(s) are already known
  • Quizzing students on solving linear or quadratic equations for x

Common Mistakes

  • Assuming the leading quadratic coefficient can be arbitrarily large; it's intentionally capped at 5 for readability.
  • Expecting non-integer or irrational solutions; every generated equation is built to have whole-number roots.
  • Confusing the 'random' type (which picks linear or quadratic per generation) with a single fixed equation form.

Tips

  • Use the Random Math Expression Generator instead if you just want an arithmetic expression to evaluate, with no unknown to solve for.
  • Generate a batch of both linear and quadratic equations using the 'random' type for a mixed practice worksheet.

References

Frequently Asked Questions