Facebook Pixel
Mathos AI logo

Piecewise and Absolute Value Functions

Piecewise and Absolute Value Functions

What is a Piecewise Function?

A piecewise function is a function made up of different rules (or "pieces") applied to different parts of its domain. Instead of a single equation, the function looks at the input value (xx) to decide which rule to use.

Example: Evaluate the following function at x=3x = -3 and x=2x = 2. f(x)={2xif x<0x2if x0f(x) = \begin{cases} 2x & \text{if } x < 0 \\ x^2 & \text{if } x \geq 0 \end{cases}

  • For x=3x = -3: Since 3<0-3 < 0, we fall into the first interval. We use the top rule: 2x2x. f(3)=2(3)=6f(-3) = 2(-3) = -6
  • For x=2x = 2: Since 202 \geq 0, we fall into the second interval. We use the bottom rule: x2x^2. f(2)=(2)2=4f(2) = (2)^2 = 4

The Absolute Value Function

The absolute value function, written as y=xy = |x|, represents the distance of a number from zero on the number line. Because distance is always positive (or zero), the graph of y=xy = |x| forms a sharp "V" shape with its vertex at the origin (0,0)(0,0).

Interestingly, the absolute value function is just a specific piecewise function: f(x)={xif x<0xif x0f(x) = \begin{cases} -x & \text{if } x < 0 \\ x & \text{if } x \geq 0 \end{cases}

Transforming Absolute Value Functions

You can shift, stretch, or flip the V-shaped graph using the general transformation formula: y=axh+ky = a|x - h| + k

  • hh (Horizontal Shift): Moves the graph left or right. The vertex's x-coordinate is hh. (Note the minus sign: x2|x - 2| moves right, x+2|x + 2| moves left).
  • kk (Vertical Shift): Moves the graph up or down. The vertex's y-coordinate is kk.
  • aa (Stretch/Compression): Makes the "V" narrower or wider. If aa is negative, the "V" flips upside down.

Example: Graph f(x)=x2+1f(x) = |x - 2| + 1.

  1. Find the vertex: Based on y=axh+ky = a|x - h| + k, we have h=2h = 2 and k=1k = 1. The vertex is at (2,1)(2, 1).
  2. Determine the shape: Since a=1a = 1 (positive), the graph opens upwards with a standard slope of 11 on the right side of the vertex and 1-1 on the left.
  3. Plot points: Starting from the vertex (2,1)(2,1), go right 1 and up 1 to the point (3,2)(3,2). Go left 1 and up 1 to the point (1,2)(1,2). Connect them to form the V-shape.