Finding the maximum value of a function

Click For Summary
The discussion centers on finding the maximum value of the function f(x) = sin x / x using Newton's 1D method. The initial attempt led to a converging value of x at approximately 4.49 radians, which corresponds to a local minimum rather than the global maximum at (0, 1). Participants clarify that the correct application of Newton's method requires starting near the maximum and using the formula x_new = x_old - f(x)/f'(x). It is noted that this function oscillates significantly, making the choice of initial guess crucial for convergence. Overall, the conversation emphasizes the importance of proper initial values and understanding the behavior of the function to successfully find the global maximum.
yugeci
Messages
61
Reaction score
0

Homework Statement



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

Homework Equations



upload_2015-12-4_16-13-34.png
[/B]

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?
 
Physics news on Phys.org
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 !

-- :smile:
 
Last edited:
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.
 

Attachments

  • 1.jpg
    1.jpg
    61.6 KB · Views: 506
  • 2.jpg
    2.jpg
    62.5 KB · Views: 499
yugeci said:
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.
Well, the formula in the OP is not Newton's Method, which is why your results are incorrect. :frown:

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

https://en.wikipedia.org/wiki/Newton's_method
 
  • Like
Likes yugeci
I thought that method was for root finding? I am finding the maximum value of a function. Unless my concepts are wrong here..
 
99ca3ee7752a4df7bf1c4bbb7c963595.png
(##\leftarrow##clickable link) is what they say in general. Makes much more sense if you look at it.
Nice picture too: here
 
yugeci said:
I thought that method was for root finding? I am finding the maximum value of a function. Unless my concepts are wrong here..
You're right. Late nite. Scratch that post.
 
OK I got it. But please correct me if I am wrong:

upload_2015-12-4_16-56-45.png


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. :wideeyed:
 

Attachments

  • upload_2015-12-4_16-56-34.png
    upload_2015-12-4_16-56-34.png
    3.3 KB · Views: 493
yugeci said:

Homework Statement



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

Homework Equations



View attachment 92880[/B]

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?
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
Interesting. I just realized 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
SteamKing said:
You're right. Late nite. Scratch that post.
Woops, me 2 ! o:) o:)
 
  • #12
yugeci said:

Homework Statement



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

Homework Equations



View attachment 92880[/B]

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?

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.
 
  • Like
Likes BvU

Similar threads

  • · Replies 5 ·
Replies
5
Views
2K
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
2
Views
1K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K