Skip to main content
🟢 Beginner

Absolute Value Calculator

Calculate the absolute value of any number or expression. |x| returns the non-negative magnitude. This free math tool gives instant, accurate results.

★★★★★ 4.8/5 · 📊 0 calculations · 🔒 Private & free

What Is Absolute Value?

The absolute value of a number is its distance from zero on the number line, regardless of direction. Written as |x|, the absolute value is always non-negative. For any real number x: if x ≥ 0, then |x| = x. If x < 0, then |x| = -x (the negative of x, which makes it positive).

Examples: |7| = 7, |-7| = 7, |0| = 0, |-3.14| = 3.14. The absolute value represents magnitude without regard to sign. Think of it as the physical distance between the number and the origin on a number line — distance is always positive.

In notation: |x - y| represents the distance between two points x and y on the number line. This interpretation extends to complex numbers as the modulus: |a + bi| = √(a² + b²), representing the distance from the origin in the complex plane. The concept is foundational in analysis, topology, and metric space theory, where "distance functions" are generalized from the familiar absolute value.

The notation |x| was introduced by Karl Weierstrass in 1841. Before this, mathematicians described the concept verbally. The simple vertical bar notation is now universal across mathematics, physics, engineering, and computer science, reflecting how central the idea of "magnitude without sign" truly is.

Properties and Rules of Absolute Value

Absolute value follows several important algebraic properties that are used constantly in proofs and calculations. Understanding these rules lets you manipulate absolute value expressions with confidence.

Solving absolute value equations requires considering both cases. |x| = 5 means x = 5 or x = -5. |2x - 3| = 7 means 2x - 3 = 7 (so x = 5) or 2x - 3 = -7 (so x = -2). Always check both solutions in the original equation. For more complex equations like |x - 2| = |x + 1|, square both sides or consider cases based on sign regions.

Absolute value inequalities follow two patterns. |x| < a (where a > 0) means -a < x < a — a bounded interval. |x| > a means x < -a or x > a — two unbounded rays. These arise frequently in error analysis, tolerance specifications in engineering, and defining neighborhoods in calculus and analysis. The notation |x - c| < δ is the formal definition of "x is within δ of c," which is the heart of the epsilon-delta definition of a limit.

Step-by-Step Examples

Working through examples solidifies understanding of absolute value calculations and equation solving. Here are several worked examples at increasing levels of difficulty.

ExpressionStep-by-Step SolutionResult
|-42|Since -42 < 0, apply |x| = -x: -(-42) = 4242
|3.14 - 7|3.14 - 7 = -3.86; since negative, apply negation: 3.863.86
|x| = 9x = 9 or x = -9 (two solutions)x ∈ {-9, 9}
|2x + 4| = 10Case 1: 2x+4=10 → x=3; Case 2: 2x+4=-10 → x=-7x ∈ {-7, 3}
|x - 3| < 5-5 < x-3 < 5 → -2 < x < 8x ∈ (-2, 8)
|3x - 6| ≥ 93x-6 ≥ 9 (x≥5) or 3x-6 ≤ -9 (x≤-1)x ≤ -1 or x ≥ 5
|(-3)² - 12|(-3)² = 9; 9 - 12 = -3; |-3| = 33
|i| in complex|0 + 1i| = √(0² + 1²) = √1 = 11

A key mistake students make: |-x| is NOT always -x — it equals |x| which is positive. Also, √(x²) = |x|, not just x. For example, √((-5)²) = √25 = 5 = |-5|. Forgetting this leads to incorrect simplifications in algebra.

The Triangle Inequality: Why It Matters

The triangle inequality |x + y| ≤ |x| + |y| is arguably the most important property of absolute value. Its name comes from geometry: in any triangle, the length of any side is less than or equal to the sum of the other two sides. The 1D version (absolute value) is the degenerate case of this geometric truth.

This inequality is the cornerstone of analysis. It is used to prove continuity of functions, convergence of sequences and series, and fundamental results about metric spaces. Every proof that a function is continuous essentially uses the triangle inequality at some point. The generalization to vector spaces becomes the norm inequality: ||u + v|| ≤ ||u|| + ||v||.

In practice, the triangle inequality provides useful bounds. If you know |a| ≤ M and |b| ≤ N, then |a + b| ≤ M + N — the combined error is at most the sum of individual errors. This is used in numerical analysis, error propagation, and engineering tolerances. The reverse triangle inequality ||a| - |b|| ≤ |a - b| tells you that the difference in magnitudes is bounded by the magnitude of the difference.

The equality condition |x + y| = |x| + |y| holds only when x and y have the same sign (or at least one is zero). This is the "degenerate triangle" case where all three points are collinear — meaning x and y point in the same direction.

Absolute Value in Real-World Applications

Absolute value appears throughout science, engineering, and daily life wherever you care about magnitude rather than direction. Understanding its applications helps you recognize when and why to use it.

Physics — Speed vs. Velocity: Speed is the absolute value of velocity. A car with velocity -60 mph (moving backwards at 60 mph) has a speed of |-60| = 60 mph. Velocity is a signed quantity (direction matters); speed is unsigned (magnitude only). The same principle applies to displacement vs. distance traveled.

Finance — Deviation from Benchmarks: When comparing investment returns, you might want the absolute deviation from a benchmark regardless of sign: how far off are you, up or down? The tracking error of a fund is typically expressed as the root mean square of absolute deviations.

Statistics — Mean Absolute Deviation (MAD): MAD = (1/n) × Σ|xᵢ - mean|. Unlike variance (which squares deviations), MAD preserves the original units and is less sensitive to outliers. It's used in robust statistics, quality control, and as a measure of forecast accuracy (mean absolute error, or MAE).

Computer Science — Distance Functions: The L1 norm (Manhattan distance) between two points is the sum of absolute differences of coordinates: d = Σ|aᵢ - bᵢ|. It's used in image processing, machine learning (lasso regression), and city-block routing problems. abs() functions are heavily used in sorting, comparison operations, and signal processing algorithms.

Engineering — Tolerances: A manufacturing specification of "5.00 mm ± 0.02 mm" means |measured - 5.00| ≤ 0.02. All measurements within the tolerance band are acceptable. This is a direct application of absolute value inequalities to quality control.

Machine Learning — Loss Functions: The Mean Absolute Error (MAE) loss function uses |predicted - actual| for each training example. Unlike Mean Squared Error (MSE), it treats all errors equally regardless of size and is robust to outliers. Lasso regularization adds Σ|wᵢ| to the loss function, shrinking small weights to exactly zero and producing sparse models.

Absolute Value Function: Graph and Calculus

The graph of y = |x| forms a V-shape, with the vertex at the origin. For x ≥ 0, it follows y = x (slope +1); for x < 0, it follows y = -x (slope -1). The function is continuous everywhere but not differentiable at x = 0 — there's a sharp corner where the left and right derivatives disagree (+1 and -1).

Transformations of |x| follow the standard rules: y = |x - h| + k shifts the vertex to (h, k). y = a|x| scales the slopes (steeper for |a| > 1, flatter for |a| < 1, reflected for a < 0). These absolute value functions are common in introductory algebra and piecewise function work.

In calculus, d/dx |x| = x/|x| = sign(x) for x ≠ 0, and is undefined at x = 0. The signum function sign(x) returns +1 for positive x, -1 for negative x, and 0 for x = 0. In the theory of distributions (generalized functions), the derivative at 0 is handled using the Dirac delta function: d/dx |x| is the Heaviside step function (shifted and scaled), and its second derivative involves the delta function.

Integration: ∫|x| dx = (x|x|)/2 + C = (|x|²/2)·sign(x) + C. Definite integrals involving absolute value require splitting the integral at the zeros of the expression inside. For ∫₋₂³ |x| dx: split at x=0 → ∫₋₂⁰ (-x) dx + ∫₀³ x dx = [x²/2]₋₂⁰ + [x²/2]₀³ = (0 - 2) + (4.5 - 0) = 6.5. This splitting technique is essential in real analysis.

Absolute Value in Programming Languages

Every major programming language provides built-in absolute value functions. Knowing the correct function to use — and potential pitfalls — is important for writing correct, efficient code.

LanguageIntegerFloat/DoubleNote
Pythonabs(-5)abs(-3.14)Works for complex too: abs(3+4j) = 5.0
JavaScriptMath.abs(-5)Math.abs(-3.14)Returns NaN for non-numeric input
JavaMath.abs(-5)Math.abs(-3.14)Warning: Math.abs(Integer.MIN_VALUE) returns negative!
C/C++abs(-5) (stdlib)fabs(-3.14) (math.h)Use correct function — mixing types causes silent errors
SQLABS(-42)ABS(-3.14)Works across numeric types in all major RDBMS
Excel=ABS(-42)=ABS(-3.14)Can be used in array formulas
Rabs(-5)abs(-3.14)Vectorized: abs(c(-1,2,-3)) = c(1,2,3)

A critical Java gotcha: Math.abs(Integer.MIN_VALUE) returns Integer.MIN_VALUE (-2,147,483,648), not a positive number. This is because two's complement integer representation has no positive counterpart for the most negative value. Always handle this edge case when writing robust code.

In NumPy (Python), np.abs() is vectorized and works on arrays: np.abs(np.array([-1, -2, 3])) returns array([1, 2, 3]). This is far more efficient than looping. Similarly, SQL's ABS() function works on entire columns, making it easy to compute absolute deviations in aggregate queries.

Frequently Asked Questions

Can absolute value ever be negative?

No. By definition, absolute value is always non-negative. |x| ≥ 0 for all real numbers x. The absolute value represents a distance, and distances are never negative. If you get a negative result, you've made an algebraic error.

What is |0|?

The absolute value of zero is zero: |0| = 0. Zero is neither positive nor negative, and its distance from itself is zero. It is the only number whose absolute value equals zero, per the identity property.

How do I solve an equation with absolute value?

Split into two cases. For |x - 3| = 5: Case 1: x - 3 = 5, so x = 8. Case 2: x - 3 = -5, so x = -2. Both solutions are valid. Always check both cases in the original equation.

What is the absolute value of a complex number?

For a complex number z = a + bi, the absolute value (also called modulus) is |z| = √(a² + b²). This is the distance from the origin to the point (a, b) in the complex plane. For example, |3 + 4i| = √(9 + 16) = √25 = 5.

Is √(x²) the same as x?

No — √(x²) = |x|, not x. For example, √((-5)²) = √25 = 5 = |-5|, not -5. This is a very common mistake in algebra. The principal square root always returns a non-negative value, so √(x²) = |x| for all real x.

How do I graph y = |x - 2| + 3?

This is a V-shape with vertex at (2, 3). For x ≥ 2: y = (x - 2) + 3 = x + 1 (slope +1). For x < 2: y = -(x - 2) + 3 = -x + 5 (slope -1). Plot the vertex, then draw two rays going upward at ±45°.

What does |x| < 3 mean on a number line?

|x| < 3 means x is within distance 3 of zero, so -3 < x < 3. On a number line, this is the open interval (-3, 3). It represents all points closer than 3 units from the origin.

What is the mean absolute deviation and when is it used?

Mean Absolute Deviation (MAD) = average of |xᵢ - mean| for all data points. It measures data spread in original units, unlike variance which squares deviations. MAD is preferred when you want a spread measure that's robust to outliers and easy to interpret. It's widely used in forecast accuracy (as Mean Absolute Error) and quality control.

Why is absolute value not differentiable at zero?

The derivative of |x| at x = 0 doesn't exist because the left-hand limit of the slope is -1 (from the y = -x piece) while the right-hand limit is +1 (from y = x). Since these limits disagree, the derivative is undefined at x = 0. Geometrically, there's a sharp corner — no unique tangent line exists.

How is absolute value related to distance?

The absolute value |a - b| gives the distance between a and b on the number line. This is the foundation of the concept of a metric (distance function) in mathematics. A metric d(a, b) must satisfy: non-negativity, d(a,a) = 0, symmetry d(a,b) = d(b,a), and the triangle inequality d(a,c) ≤ d(a,b) + d(b,c). Absolute value satisfies all of these.

},{"@type":"Question","name":"What is |0|?","acceptedAnswer":{"@type":"Answer","text":"The absolute value of zero is zero: |0| = 0. Zero is neither positive nor negative, and its distance from itself is zero."}},{"@type":"Question","name":"How do I solve an equation with absolute value?","acceptedAnswer":{"@type":"Answer","text":"Split into two cases. For |x - 3| = 5: Case 1: x - 3 = 5, so x = 8. Case 2: x - 3 = -5, so x = -2. Both solutions are valid. Always check both cases in the original equation."}}]}