CalcMountain

Absolute Value Calculator

Enter one or two numbers to find their absolute values and the distance between them on the number line. Absolute value represents the magnitude of a number regardless of sign.

The absolute value of a number is its distance from zero on the number line, ignoring direction. Written as |x|, absolute value strips away the sign: |−7| = 7, |7| = 7, |0| = 0. It answers the question "how far from zero?" rather than "in which direction?"

This seemingly simple concept appears throughout mathematics, physics, statistics, and computer programming. It defines distance between two numbers (|a − b|), measures error in approximations (|observed − true|), describes magnitude of vectors and complex numbers, and underlies many fundamental inequalities. Without absolute value, the simple notion of "how big" or "how far" would lack precise mathematical expression.

The definition formalizes as a piecewise function: |x| = x if x ≥ 0, and |x| = −x if x < 0. The negative-of-negative gives positive, so |x| is always ≥ 0. This guarantees absolute value is non-negative regardless of input sign.

In two dimensions and beyond, absolute value extends to magnitude (length): |v⃗| = √(x² + y²) for 2D, generalizing to √(x² + y² + z² + ...) for higher dimensions. For complex numbers a + bi, the absolute value (modulus) is √(a² + b²). These all measure "size" of a quantity, abstracting from coordinate-system orientation.

Common applications: error analysis (|measured − expected|), physics (vector magnitudes, distances), statistics (mean absolute deviation), programming (Math.abs() in nearly every language), and elementary algebra (solving |x − a| = b).

Inputs

Results

|A|

7

|B|

3

Distance |A - B|

10

Midpoint

-2

A + B

-4

A - B

-10

A * B

-21

|A * B|

21

Last updated:

Formula

**Absolute value definition:** |x| = x if x ≥ 0 |x| = −x if x < 0 So |x| ≥ 0 always. **Worked example: basic absolute values** |7| = 7 |−7| = 7 |0| = 0 |−3.14| = 3.14 |−(−5)| = |5| = 5 **Distance between two numbers:** distance(a, b) = |a − b| = |b − a| The order doesn't matter — distance is symmetric. **Worked example: distance on number line** Distance from -3 to 5: |−3 − 5| = |−8| = 8 Or: |5 − (−3)| = |8| = 8 Both give 8 (units between them on the number line). **Key properties:** | Property | Statement | |---|---| | Non-negativity | \|x\| ≥ 0 | | Definiteness | \|x\| = 0 ⟺ x = 0 | | Symmetry | \|−x\| = \|x\| | | Multiplicativity | \|xy\| = \|x\| × \|y\| | | Triangle inequality | \|x + y\| ≤ \|x\| + \|y\| | | Reverse triangle | \|\|x\| − \|y\|\| ≤ \|x − y\| | | Idempotence | \|\|x\|\| = \|x\| | | Equivalent form | \|x\| = √(x²) | **Solving absolute value equations:** |x| = a (where a ≥ 0) → x = a or x = −a |x − 3| = 5 → x − 3 = 5 OR x − 3 = −5 → x = 8 OR x = −2 **Solving absolute value inequalities:** |x| < a → -a < x < a (between -a and a) |x| > a → x > a OR x < -a (outside the range) |x − 3| < 5 → -5 < x − 3 < 5 → -2 < x < 8 |x − 3| > 5 → x − 3 > 5 OR x − 3 < -5 → x > 8 OR x < -2 **Absolute value function (graph):** f(x) = |x| V-shape: - Left branch slope = -1 (for x < 0). - Right branch slope = +1 (for x > 0). - Vertex at origin (0, 0). **For 2D and higher (magnitude):** |v⃗| = √(x² + y²) for 2D |v⃗| = √(x² + y² + z²) for 3D This is the Pythagorean theorem applied to vectors. **Complex number absolute value (modulus):** |a + bi| = √(a² + b²) For 3 + 4i: |3 + 4i| = √(9 + 16) = √25 = 5. Geometric interpretation: distance from origin in complex plane. **Mean absolute deviation (MAD):** MAD = (1/n) × Σ|xᵢ − μ| Statistical measure of variability using absolute differences from mean. Less sensitive to outliers than variance (uses absolute values, not squares). **Triangle inequality (geometric):** In any triangle: any side length ≤ sum of other two. Algebraically: |x + y| ≤ |x| + |y|. Equality when x and y same sign. **L1 vs L2 norms:** |x|₁ = Σ|xᵢ| (Manhattan distance, sum of absolute values) |x|₂ = √(Σxᵢ²) (Euclidean distance, square root of sum of squares) L1 used in: machine learning regularization (Lasso), robust statistics. L2 used in: physics (Pythagorean), classical least squares. **Common applications:** | Application | Use of |·| | |---|---| | Error analysis | |measured - actual| | | Hypothesis tests | |t| > critical value | | Optimization | minimize Σ|residuals| | | Computer graphics | distance between pixels | | Audio processing | signal amplitude | | Voltage analysis | absolute peak voltage | | Coding | Math.abs() function | **Number line visualization:** For two points a and b on a number line: - Position: actual locations (-3 and 5). - Distance: |a - b| or |b - a| (always positive). This is why absolute value matters: distance is intrinsically positive. **Programming:** - **Python**: abs(x) or |x| - **JavaScript**: Math.abs(x) - **C/C++**: abs(int), fabs(double), labs(long) - **Java**: Math.abs(x) - **R, MATLAB**: abs(x) All return non-negative magnitude regardless of input sign. **Sign function (related):** sgn(x) = 1 if x > 0 sgn(x) = 0 if x = 0 sgn(x) = -1 if x < 0 So x = sgn(x) × |x|.

How to use this calculator

  1. Enter one number to find its absolute value.
  2. Enter two numbers to find distance between them.
  3. Absolute value strips the sign, giving magnitude.
  4. Distance = |A - B| = |B - A| (same result either way).
  5. For 2D points or vectors, use distance formula calculator.
  6. For complex numbers, |a + bi| = √(a² + b²).

Worked examples

Temperature change

**Scenario:** Today's temperature is -5°C, yesterday was 8°C. Change in temperature magnitude? **Calculation:** Distance = |8 - (-5)| = |13| = 13°C. **Result:** 13°C temperature swing. The absolute value tells you the magnitude of change without worrying about direction (whether it warmed up or cooled down). Useful for grading "temperature shock" or any change-detection scenario.

Stock price movement

**Scenario:** A stock moved from $52.30 to $48.10. Absolute movement? **Calculation:** Δ = 48.10 - 52.30 = -4.20. |Δ| = 4.20. **Result:** $4.20 absolute movement. Useful when calculating volatility (average absolute change), trading position size (always positive), or risk metrics where direction matters less than size.

Distance between cities

**Scenario:** City A is at mile marker -15, City B at marker +47 on a highway. Distance? **Calculation:** |47 - (-15)| = 62 miles. **Result:** 62 miles apart. The negative sign on marker -15 indicates west of zero point; absolute value of the difference gives actual distance regardless of direction. Same principle works for time differences, GPS coordinates (in one dimension), and any "how far apart" question.

When to use this calculator

**Use absolute value for:**

- **Distance calculations**: between any two points (1D, 2D, 3D, ...). - **Error analysis**: |measured - true| measures error size. - **Magnitude**: of vectors, complex numbers, signals. - **Statistical analysis**: mean absolute deviation (MAD). - **Optimization**: L1 regularization, robust regression. - **Algebra**: solving equations with |...|. - **Inequalities**: tolerance regions, bounds. - **Physics**: amplitudes, speeds (vs velocities).

**Key insight:**

Absolute value answers "how much" without regard to direction or sign. When you need a non-negative measure of size, magnitude, or distance, absolute value is the tool.

**Common applications:**

- **Programming**: Math.abs() for ensuring positive values. - **Audio**: peak voltage measurement. - **Image processing**: pixel intensity differences. - **Numerical methods**: convergence criteria |x_new - x_old| < ε. - **Machine learning**: L1 regularization, robust losses. - **Financial analysis**: drawdown calculations. - **Quality control**: process tolerance (|measurement - target| ≤ ε).

**Solving |expression| equations:**

|expression| = value Split into TWO equations: - expression = +value - expression = -value

Solve each, combine solutions.

|x + 3| = 10 → x + 3 = 10 OR x + 3 = -10 → x = 7 OR x = -13

**Inequalities:**

|x - a| < b → a - b < x < a + b (interior of interval) |x - a| > b → x < a - b OR x > a + b (exterior) |x - a| ≤ b → a - b ≤ x ≤ a + b |x - a| ≥ b → x ≤ a - b OR x ≥ a + b

Useful for stating tolerances: |x - target| ≤ epsilon means x is within epsilon of target.

**Vector magnitude:**

For 2D vector v = (3, 4): |v| = √(3² + 4²) = √25 = 5

For 3D vector v = (1, 2, 2): |v| = √(1 + 4 + 4) = √9 = 3

Generalizes to any dimension. Always non-negative.

**Triangle inequality applications:**

|x + y| ≤ |x| + |y|

Used in: - Proving convergence in analysis. - Geometric constraints (triangle side lengths). - Vector inequalities. - Inequalities in real and complex numbers.

Equality holds when x and y have same sign (or same direction for vectors).

**Mean absolute deviation:**

MAD = mean of |xᵢ - μ|

Robust measure of dispersion (less affected by outliers than variance). Used in statistics, time series analysis.

**Complex modulus:**

|a + bi| = √(a² + b²)

Has all properties of real absolute value plus: |z₁ × z₂| = |z₁| × |z₂| |z₁/z₂| = |z₁|/|z₂|

**Software:**

- **Excel**: ABS(value) - **Python**: abs(x), or math.fabs(x) for floats - **JavaScript**: Math.abs(x) - **R**: abs(x) - **MATLAB**: abs(x) works for real and complex

**Pitfalls:**

- **Negating result of |x| = x**: |x| equals x only if x is non-negative. - **|x + y| ≠ |x| + |y|**: triangle inequality, equality only when same sign. - **Solving |x| < negative**: no solution (impossible). - **Forgetting both ±cases**: |x| = a means x = ±a. - **Square root identity**: |x| = √(x²) — sometimes useful. - **In programming**: integer overflow with abs(MIN_INT). - **Confusing |x| with x²**: |x|² = x², but |x| ≠ x² (unless |x| ≤ 1).

Common mistakes to avoid

  • Forgetting that |x| = a has two solutions: x = a and x = -a.
  • Solving |x| < negative number (no solution — always false).
  • Treating |x + y| = |x| + |y| (only true when same sign).
  • Confusing absolute value with squaring (|x| ≠ x² in general).
  • Forgetting that |x| ≥ 0 always.
  • Negating result of |x| (giving negative output).
  • For complex numbers: using simple |x| instead of √(a² + b²).
  • In programming: integer overflow with abs(MIN_INT) on some systems.

Frequently Asked Questions

Sources & further reading

SponsoredShop Top Deals on AmazonSupport CalcMountain — browse top-rated products at no extra cost to you.

Related Calculators