# Finding maximum value

1. Dec 8, 2013

### utkarshakash

1. The problem statement, all variables and given/known data
The maximum value of $| \sqrt{x^4-3x^2-6x+13} - \sqrt{x^4+5x^2+4}|$

2. Relevant equations

3. The attempt at a solution
First of all I'd like to ask a question which always troubles me and that is how do you find max value of any given expression? What clues do you look for? As in this case it is a random expression and the only thing I can say is that the term under square root should be positive. Now, I could have used Wavy Curve method here if only it could be easily factorised which I think is impossible in this case. The other method is by approaching it the 'calculus' way i.e. differentiating and setting it to 0. But the roots are impossible to calculate manually. I find these questions really intriguing

2. Dec 8, 2013

### Ray Vickson

In your specific case, both terms under the square root signs are > 0 for all real x; showing that the second one is > 0 is easy but showing that the first one is > 0 needs more work (such as finding the minimum of the thing inside the square root). So, in this specific case we get a finite, well-defined result for any real x.

If you did not have the absolute value operation you could set derivatives = 0 to find local maxima and local minima. One of the points obtained this way is the global max and the other is the global min (as we can see by plotting). However, things change when you apply the absolute value: now the function has a local max and a global max, plus two global minima. The maxima are obtained by setting the derivative to zero (basically, the are the max and the min of the previous problem without absolute values). However, the minima cannot be obtained by setting the derivative to zero because the function |f(x)| is not differentiable at those two points.

You might think I cheated by looking at plots, etc., but the point is that such problems can be quite hard---especially when absolute values are involved---so using all available modern tools is a good strategy.

3. Dec 8, 2013

### haruspex

If you expect the problem setter to be kind, you can look for a way to rewrite it as a sum of squares: x4-4x2+4 looks like a good start.. leaving what?

4. Dec 8, 2013

### haruspex

To make the algebra easier, I tried writing it as |√f(x) - √g(x)|.
Clearly any maximum of that will also be an extremum of √f(x) - √g(x).
Differentiating etc. we get f'2g = g'2f.
Now writing f = a(x)2+b(x)2, g = c(x)2+d(x)2, where a' = 2ax, c' = 2cx, c' = d' = 1 (trust me), there's some cancellation straight away. Better, a factor emerges which is a fairly simple combination of a, b, c and d. That allows solutions to be separated into one cubic and one quintic. Haven't taken it further, but it looks like more cancellations will arise after substituting the actual expressions for a, b, c, and d, reducing the polynomial degrees somewhat.

5. Dec 8, 2013

### Mentallic

Wolfram had a fit trying to find the maximum, which leads me to believe that I would too if I tried.

6. Dec 9, 2013

### haruspex

Fwiw, here's a graphical way of looking at it. Write y = x2. Then the two surds (square roots) are the distances from a point (x, y) on that parabola to two fixed points. Since the locus of a point whose distances from two fixed points have a constant difference is also a conic, this gives rise to a family of conics (one for each given distance difference). The solution to the OP corresponds to finding a curve in the family that's tangential to the parabola.
Not sure how this helps, other than allowing one to see roughly where the solutions must lie.

7. Dec 9, 2013

### Saitama

Rewrite the given expression as follows:

$$\left|\sqrt{(x-3)^2+(x^2-2)^2}-\sqrt{x^2+(x^2+2)^2}\right|$$

Notice that the first surd is the distance of the point $(x,x^2)$ from (3,2) and the other is distance of $(x,x^2)$ to (0,-2). The triangle inequality should do the trick now.

I hope that helped.

8. Dec 9, 2013

### utkarshakash

This does help. But instead of finding the curve, it was easier to apply triangle inequality as suggested by Pranav-Arora. But how did it strike to you that it must be something related the distance and you cleverly factorised it out to make it look like that? I'm just curious to know

Last edited: Dec 9, 2013
9. Dec 9, 2013

### Ray Vickson

Your original question suggested you wanted to know how to find optima in general, and that the expression you gave was just an example. That is why I tried to give you a somewhat general answer, not really doing a lot of 'head' work on your specific function; that is, I let the computer do most of the heavy lifting. That would be my suggestion for dealing with the 'general' case.

Of course, if your function comes from some specific application area you might be able to apply subject-specific insights to it in order to simplify it or re-write in a more tractable form.

Last edited: Dec 9, 2013
10. Dec 9, 2013

### haruspex

At first I was just looking to prove both surds were positive definite. The second was obviously the sum of two squares, so I looked for a way to get the first in that form. When that turned out to be easy, I was pretty sure I could ignore your advice that these were random expressions! And since each surd was now of the form √(a2+b2), they could be represented as distances. It threw me for a while that one distance in each case was itself quadratic.
I don't know whether you also looked at my first approach to a solution, using the f and g function substitution. Wrapping the complexity up like that, then gradually unwrapping it and simplifying as much as possible at each step is quite a handy method for taming the algebra.