# Finding the maximum value of a function

Tags:
1. Dec 4, 2015

### yugeci

1. The problem statement, all variables and given/known data

Find the extremizing (maximum) value of the function f(x) = sin x / x using Newton's 1D method.

2. Relevant equations

3. The attempt at a solution

I know the maximum point in this equation is (0, 1). When I differentiated the equation twice and used the formula above, I managed to get a converging value of x at 4.49 radians and my corresponding value of f(x) is -0.217. I checked this using wolframalpha as well, and the converging value is 4.49 radians also. I'm sure I didn't make any silly algebraic errors, so what could be wrong here?

2. Dec 4, 2015

### BvU

1 Check the formula. It doesn't make sense to me to bring in a second derivative !

2 Where did you start ? Show what you did in more detail. You and I are not interested in the answer, we want the correct path to find it !

--

Last edited: Dec 4, 2015
3. Dec 4, 2015

### yugeci

I think the formula should be right. My teacher derived it from the Taylor Series, but I don't have my notes right now so I can't show that.

It would take a while to type my working in LaTeX so I just took pictures of what I did. Just simple differentiation twice and then simplification. Then I took the initial value of x as 3 radians, and then kept iterating. Converged at ~4.49 radians.

File size:
61.6 KB
Views:
65
File size:
62.5 KB
Views:
62
4. Dec 4, 2015

### SteamKing

Staff Emeritus
Well, the formula in the OP is not Newton's Method, which is why your results are incorrect.

The correct formula is $x_{new} = x_{old} - \frac{f(x)}{f'(x)}$

https://en.wikipedia.org/wiki/Newton's_method

5. Dec 4, 2015

### yugeci

I thought that method was for root finding? I am finding the maximum value of a function. Unless my concepts are wrong here..

6. Dec 4, 2015

### BvU

($\leftarrow$clickable link) is what they say in general. Makes much more sense if you look at it.
Nice picture too: here

7. Dec 4, 2015

### SteamKing

Staff Emeritus
You're right. Late nite. Scratch that post.

8. Dec 4, 2015

### yugeci

OK I got it. But please correct me if I am wrong:

The formula you posted will give me the red circled values (function when x = 0), and the one I posted gives me the green value (converging value of x)? Just let me know if I'm wrong then I'll look up a book again.

File size:
4.3 KB
Views:
48
9. Dec 4, 2015

### SteamKing

Staff Emeritus
If you plot y = sin(x) / x with WA, you'll see that this function oscillates quite a bit when x > 0. Your initial guess for x, whatever it was, has led the Newton's method to locate one of the relative minimas, which happens to be located at x ≈ 4.49 rad.

You may have to try different starting points to see what pops out of the Newton's method for this function, since there are a lot of relative extremums, but only one global maximum point at x = 0.

10. Dec 4, 2015

### yugeci

Interesting. I just realised that now looking at the plot again. Is there no way of figuring out where the global maximum will approximately be beforehand? Or do you have to just keep guessing?

11. Dec 4, 2015

### BvU

Woops, me 2 !!

12. Dec 4, 2015

### Ray Vickson

Your formula is correct, since you are trying to solve the equation $f^{\prime}(x) = 0$. However, you need to start from near the solution, and starting from some points can lead to disaster; for example, starting from $x_0 = 2$ give you $x_1 \doteq -22.617$, and if you choose another $x_0$ near $2$ you can even make $x_1 < -10^{100}$. Practical implementations of Newton's method build in various "safeguards" to prevent that behavior from occurring, but they can sometimes slow down the convergence rate.

Basically, the way modern "global optimization" packages work is by a sophisticated implementation of "guessing", although there are some methods for 1-variable problems that avoid guessing or trial-and-error. One well-studied method is that of Bruno Shubert (B. Schubert, "A Sequential Method Seeking the Global Maximum of a Function", SIAM Journal on Numerical Analysis (1972), Volume 9, #3, pp. 379-388), but newer variants exist now that may be much more efficient---I haven't kept up with that literature.