Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Translate the entire conversation x

finding the maximum

Jbryant61
4-Participant

finding the maximum

Could some one point out where im going wrong in finding the maximum of my function. I thought it should be trivial.

I want to create a generic way to pass any function. Please see attached.

Thanks

Jason

4 REPLIES 4
Jbryant61
4-Participant
(To:Jbryant61)

Its OK, I've done it. I changed the order of the two line sin the for loop and it worked 😉

Jason

Werner_E
25-Diamond I
(To:Jbryant61)

Or maybe better using just one if-statement

maxfunc1.png

or even a more analytical approach (with all limitations of root, of course) which will yield more precise results more quickly

maxfunc2.png

Or

thru.png

Werner_E
25-Diamond I
(To:Jbryant61)

Here is a version with some error handling which should work even if the extremum is not between xlo and xhi.

Announcements

Top Tags