Integral of Absolute Value Calculator

Split at every sign change, flip the negative pieces, and integrate |f| the way the textbook intends.

Integral of Absolute Value Calculator

Integrating an Absolute Value

The integral of |f(x)| cannot be computed by finding "the antiderivative of the absolute value": |·| has no useful antiderivative rule of its own. The correct method is structural,

find where f changes sign, split the integral at those points, and flip the sign of the pieces where f is negative

because on each piece between consecutive roots, |f| equals either f or −f outright, and ordinary integration applies. The result is always the geometric total area between the curve and the axis, with the below-axis lobes counted positively instead of cancelling. This calculator automates the whole routine: it locates every sign change on your interval, integrates each piece, displays the flip decisions, and sums, with the folded curve |f| shaded on the graph and the original f dashed beneath it.

How to Use the Integral of Absolute Value Calculator

Enter f (without absolute value bars, the tool applies them), and the limits. The steps list the sign changes found, then one line per piece: its interval, the sign f keeps there, the piece's plain integral, and the absolute value contributed. The final line reports ∫|f| alongside the signed ∫f for contrast, identical when f never goes negative, dramatically different otherwise. The graph shades under |f|, whose reflected lobes make the fold visible. For the signed-versus-geometric comparison as the star of the show, see the companion area under the curve calculator, which reports both readings for any f.

Worked Example

Compute ∫−22 |x² − 1| dx. The parabola crosses zero at x = ±1, splitting [−2, 2] into three pieces. Integrating x² − 1 on each:

[−2, −1]: +4/3;   [−1, 1]: −4/3 (flip to +4/3);   [1, 2]: +4/3

Total: 4/3 + 4/3 + 4/3 = 4. The signed integral over the same interval is 4/3 − 4/3 + 4/3 = 4/3: cancellation hides two-thirds of the geometry. The |sin| chip is the classic follow-up: over one full period the signed integral is exactly 0, while ∫|sin x| dx = 4, the number that actually measures how much curve-versus-axis area exists, and the one rectified-current calculations in electronics genuinely need.

Why the Split-and-Flip Method Is Forced

Absolute value is a piecewise definition in disguise: |u| = u when u ≥ 0 and −u when u < 0. Any integral of |f| is therefore secretly a piecewise integral, and the split points are exactly where the definition switches, the roots of f. Skipping the split and "integrating then taking absolute value," |∫f|, computes something else entirely (it collapses the worked example's 4 to 4/3). The triangle inequality for integrals pins down the relationship precisely: |∫f| ≤ ∫|f|, with equality exactly when f keeps one sign. The gap between the two sides measures cancellation, and applications choose sides deliberately: net displacement versus total distance traveled is this exact pair, with velocity as f.

Common Mistakes to Avoid

  • Computing |∫f| instead of ∫|f|. The absolute value must go inside before integrating; outside, it merely strips the sign of the already-cancelled net. The two agree only for sign-constant integrands.
  • Missing a sign change. Every root of f inside [a, b] is a mandatory split point; missing one merges a positive and a negative piece and corrupts both. The tool root-hunts densely for exactly this reason.
  • Splitting at roots outside the interval. Only crossings strictly between a and b matter; splitting elsewhere is harmless but signals confusion about what drives the method.
  • Flipping the wrong pieces. The flip applies where f is negative, determined by a test point per piece, not by alternation. Tangencies (double roots) touch zero without changing sign, and no flip occurs across them.
  • Forgetting |f| is continuous but not smooth. The fold creates corners at the roots: |f| is continuous (so integration is untroubled) but generally not differentiable there, which matters if you later differentiate results.

Real-World Applications

Integrals of absolute values measure accumulated magnitude when direction is irrelevant. Kinematics is the canonical case: integrating |velocity| gives total distance traveled, odometer style, while the signed integral gives mere displacement. Electrical engineering rectifies alternating current, and the mean absolute value of a sinusoid over a period (2/π times the peak, from the |sin| computation above) is a standard quantity in power electronics. Statistics builds on ∫|f − g|: the L¹ distance between densities and the mean absolute deviation are both absolute-value integrals, valued for robustness against outliers. Finance sums absolute daily changes as a volatility proxy; ecology integrates absolute deviation from a baseline to score disturbance. And in numerical analysis, the L¹ norm of an error function, ∫|error|, is one of the three standard yardsticks for how wrong an approximation is, computed by exactly the split-and-flip performed here.

Frequently Asked Questions

Why can't I just find an antiderivative of |f(x)|?

Because no product/chain-style rule exists for absolute values; |f| is defined piecewise, switching between f and −f at each root. Antidifferentiation must respect the pieces, which is exactly the split-and-flip method, and any valid antiderivative of |f| is itself built piecewise this way.

What is the difference between ∫|f| and |∫f|?

∫|f| folds first, so every lobe counts positively: total geometric area. |∫f| cancels first, then strips the sign of the leftover net. The triangle inequality guarantees ∫|f| ≥ |∫f|, with the gap measuring how much positive and negative area annihilated.

How does the calculator find the sign changes?

By a dense root search of f over [a, b] (1600 sample cells with bisection refinement), the same engine as the site's root finders. Each located crossing becomes a split point; tangencies without sign change are detected by testing the sign on both flanks and induce no flip.

What if f touches zero without crossing, like x² at 0?

Then |f| = f near that point already (or −f throughout, for a downward tangency), and no split is needed: the piece's sign test says "keep." The method cares about sign changes, not zeros per se, a distinction double roots make vivid.

Is the answer always positive?

Strictly positive unless f is identically zero on the interval: |f| ≥ 0 everywhere, and a continuous nonzero function contributes positive area somewhere. A zero result from this tool on a nonzero function would indicate the interval has shrunk to nothing or f vanishes throughout.

How is this connected to total distance versus displacement?

Identically: with f as velocity, the signed integral is displacement (where you ended up relative to start) and ∫|f| is distance traveled (what the odometer logged). A round trip has zero displacement but positive distance, the |sin| example wearing physics clothes.

Can I integrate |f(x) − g(x)| to find the area between two curves?

Yes, that is precisely the general area-between-curves formula: ∫|f − g| handles curves that swap top and bottom automatically, splitting at intersections. The area between curves calculator runs this exact computation with the two curves entered separately.

Does the method work for functions with many crossings, like sin?

Without change: each period contributes its crossings, every piece flips or keeps by its own sign, and the sum telescopes into results like ∫₀|sin| = 4. Cost grows only linearly in the number of pieces, and the step list shows each one explicitly.

What smoothness does |f| have at the split points?

Continuity always; differentiability only where f crosses with zero slope. At a simple crossing the fold makes a corner with one-sided slopes ±f′, the |x| shape locally. This never troubles integration, but it is why formulas differentiating ∫|f| require care at the roots.

Is there a symbolic antiderivative trick using sgn(x)?

One can write d/dx of ½x|x| = |x| and generalize with sign functions, but any such formula secretly encodes the same piecewise structure and still requires knowing the roots. The split-and-flip method is not a workaround; it IS the mathematics, stated plainly.