Quick answer

|x| = x when x ≥ 0; |x| = −x when x < 0

Formula

  • |x| = √(x²)
  • |a − b| = distance between a and b

Introduction

Textbooks present absolute value as a piecewise rule, with a square root, or as distance between two points. All are equivalent if you apply them correctly.

The formula is short, but each form highlights a different idea: cases, algebra, or geometry. Knowing more than one form helps on exams where notation varies.

The Absolute Value Calculator evaluates |x| using the same logic. If you need the concept first, read what is absolute value, then return here for notation you can reuse on every problem.

Why two cases?

Non-negative numbers already represent distance to the right of zero (or zero itself). Negative numbers lie left of zero, so the piecewise rule uses −x to produce a positive distance.

The expression |a − b| measures how far apart a and b are on a number line. Order inside the subtraction does not change the distance: |7 − 2| = |2 − 7| = 5.

In coordinate problems, |x − h| is the horizontal distance from x to h. That form appears when you shift absolute value graphs and when you write tolerance intervals around a target.

For a visual picture of |a − b| as a gap between two ticks, see absolute value vs distance.

Forms you may see

  • |x| = x if x ≥ 0
  • |x| = −x if x &lt; 0
  • |x| = max(x, −x)
  • |x| = √(x²)
  • |a − b| = distance between a and b

Choose the form that matches your course notes. On homework, write the piecewise definition unless your teacher asks for √(x²) or max form.

The identity |ab| = |a|·|b| is useful in algebra when constants factor out of bars. Do not assume |a + b| = |a| + |b| without extra conditions.

After you memorize the forms, practice with varied integers, decimals, and fractions until the sign rule feels automatic.

How to apply the formula

  1. Test the sign of x. Decide which branch of the piecewise rule applies. If x = 0, either branch gives 0.
  2. Apply the branch. Keep non-negative x. For negative x, use −x, which is the positive opposite.
  3. Simplify. The final value must be ≥ 0. Reduce fractions and decimals as usual.
  4. Match the question type. Single number → |x|. Two locations → |a − b|. Do not mix templates.

Formula walkthrough

For x = −11, the negative branch gives |−11| = −(−11) = 11.

For a = 4 and b = −9, |a − b| = |4 − (−9)| = |13| = 13. The points are thirteen units apart on a number line.

For x = 0, |0| = 0 using either branch.