cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. 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

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

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

Top Tags