Course contentsShow
← Mathematics
Lesson 597 of 3,12114. Functions in DepthFree lesson

The Sign Function

Understand the sign function that returns -1, 0, or 1 based on whether the input is negative, zero, or positive.

The Sign Function

You'll learn how the sign function categorizes any real number as negative, zero, or positive by returning exactly three possible values.

What Is the Sign Function?

The sign function (often written as sgn or sign) is a simple but useful tool that tells you whether a number is negative, zero, or positive. It's like a mathematical referee that makes one of three calls:

  • Returns -1 if the input is negative
  • Returns 0 if the input is zero
  • Returns +1 if the input is positive

How It Works

The sign function strips away a number's magnitude (size) and focuses only on its direction. Think of it like asking, "Which way is this number pointing on the number line?"

Formal definition:

sgn(x) = { -1  if x < 0
         {  0  if x = 0
         {  1  if x > 0

Examples

  • sgn(-7.5) = -1 (negative input)
  • sgn(0) = 0 (zero input)
  • sgn(42) = 1 (positive input)
  • sgn(-0.001) = -1 (even tiny negatives give -1)
  • sgn(1000000) = 1 (all positives give 1)

Why It Matters

The sign function is a piecewise function that appears in physics, computer science, and advanced mathematics. It's useful when you need to know direction but not magnitude—like determining which way a force acts, or implementing certain algorithms.

Key Takeaway: The sign function returns -1 for negative numbers, 0 for zero, and +1 for positive numbers, extracting only the "direction" information from any real number.