Britannica Sources used in this answer

How can the absolute value function be written using different rules for positive and negative inputs?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

The absolute value function, denoted as |x|, measures the magnitude of a real number and represents its distance from zero on a number line. Because distance is always non-negative, the function is defined using a piecewise rule that accounts for the sign of the input.1

The absolute value function can be written as:

|x|={xif x≥0−xif x<0

In this definition, if the input x is positive or zero, the output is simply x. If the input is negative, the output is the negation of x (−x), which results in a positive value. This approach of defining a function using different rules for discrete intervals is known as a piecewise definition.12