Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How do you solve equations that involve the $\max$ function? For example: $$\max(8-x, 0) + \max(272-x, 0) + \max(-100-x, 0) = 180$$

In this case, I can work out in my head that $x = 92.$ But what is the general procedure to use when the number of $\max$ terms are arbitrary? Thanks for the help, here is a Python solution for the problem if anyone is interested.

def solve_max(y, a):
    y = sorted(y)
    for idx, y1 in enumerate(y):
        y_left = y[idx:]
        y_sum = sum(y_left)
        x = (y_sum - a) / len(y_left)
        if x <= y1:
            return x
print solve_max([8, 272, -100], 180)
share|improve this question

3 Answers 3

up vote 4 down vote accepted

Check each of the possible cases. In your equations the "critical" points (i. e. the points where one of the max's switches) are $8$, $272$ and $-100$. For $x \le -100$ your equation reads \[ 8-x + 272 - x + (-100-x) = 180 \iff 180 - 3x = 180 \] which doesn't have a solution in $(-\infty, -100]$.

For $-100 \le x \le 8$, we have \[ 8-x + 272 - x = 180 \iff 280 - 2x = 180 \] and the only solution $50\not\in [-100, 8]$.

For $8 \le x \le 272$ we have \[ 272-x = 180 \iff x = 92 \] so here we have a solution.

And finally for $x \ge 272$ the equation reads \[ 0 = 180 \] so no more solutions.

share|improve this answer

Hint: You can think of $max(8-x,0)$ as a piecewise defined function. $$ max(8-x,0) = \begin{cases} 0 \text{ if $ x\geq 8$} &\\ 8-x \text{ if $x \lt 8$} \end{cases} $$ Apply this idea to other $max$ functions as well.

share|improve this answer

In different domains, the max function will yield different values (of course!). Therefore, you can turn the max function into a piecewise function over the different domains, and then compute the zeros of a (potentially extensive) piecewise function.

For instance, you can write $\max(8-x,0)$ as $$f(x) = \left\{\begin{array}{cc} 0, & x \ge 8, \\ 8-x, & x < 8. \end{array}\right.$$

share|improve this answer
    
Beaten to the punch! –  Arkamis May 15 '12 at 14:33

Your Answer

 
discard

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.