Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
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
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
or even a more analytical approach (with all limitations of root, of course) which will yield more precise results more quickly
Or
Here is a version with some error handling which should work even if the extremum is not between xlo and xhi.