Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

$$y = \begin{cases} 0, & \text{if } x < 0, \\ 2x, & \text{if } x \geq 0. \end{cases}$$

How can we represent the above function in one formula?

I'm not exactly sure how to tackle this sort of question. (This is not homework.) It comes from Functions and Graphs by I. M. Gelfand on page 32. On the face of it, it's an easy question that should have an easy answer. Yet my math intuition skills need a lot of work. (Hopefully this book will help!)

To solve this, is there a general method to work backwards from these two "rays" to an absolute value function?

Likewise, turning to page 33 to investigate another problem:

$$y = \begin{cases} 2x + 1, & \text{if } x \geq 0, \\ \frac{1}{2}x + 1, & \text{if } x \leq 0. \end{cases}$$

For example, $|2x+1|-|\frac{1}{2}x+1|$ clearly can't work as the formula. Besides guessing and attempting all sorts of possible formulas to the end of time, how can we look at this systematically?

Thank you so much for your time and patients!

share|cite|improve this question
up vote 1 down vote accepted

$y = max(0,2x) = \frac{1}{2}(|2x| + 2x) = |x| + x$

More generally, suppose you had $y = ax, x > 0$, and $y = bx$, $x<0$. Consider the generic function $y = c|x| - dx$. Then for $x > 0$, $y = cx - dx$, and for $x < 0$, $y = -cx - dx$. So you want to choose $c$ and $d$ to solve $c - d = a$, and $-c - d = b$. From this you can work out the general form of $c$ and $d$.

share|cite|improve this answer

Thank you.

It seems that there is no "direct" or "easy" way to solve these types of problems in general. To set up the system of equation you did, you needed to know the generic function ahead of time. Hence, mathematical intuition rules in the end.

It's kind of like factoring. There is no general recipe. That's always hard for me to get use to.

There appears to be a mistake in your reply, however. If x < 0, then y = -cx + dx and not -cx - dx.

The system of equations can't work for the second problem. So intuitively, I kept in mind that whatever the formula is, it would have the constant "+1." Ignoring that allows the system of equations to work. Then afterward, the constant "+1" is to be added: y = (1/2)|x|+(3/2)x+1.

(The next problem in Functions and Graphs has the solution y = .5|x+1|-.5|x-1|. This, again, does not conform to the system of equations. So intuitively, the way I looked at it is its relationship to y = |x+1|-|x-1|. The only other way that we might arrive at the solution is to notice that it's an odd function. So the formula would have to uphold that.)

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.