HP Prime Forum
Brent's method for computing extrema - Printable Version

+- HP Prime Forum (http://forum.hp-prime.de)
+-- Forum: HP Prime (/forumdisplay.php?fid=1)
+--- Forum: Software (/forumdisplay.php?fid=4)
+--- Thread: Brent's method for computing extrema (/showthread.php?tid=84)



Brent's method for computing extrema - cdeaglejr - 14-03-2016 08:12 PM

This HP Prime program demonstrates how to interact with a function called minima which computes a single minimum of a user-defined function. The user provides an initial and final value for a search interval along with a convergence criterion.

Here is the output for this program. For this example the user-defined function is simply y = cos(x) and the search interval was 0 to 2 pi. To find the maximum value of a function, remember that a maximum is simply a minimum with a negative attitude! So for this example, changing the user-defined function to y = -cos(x) will find a maximum if one exists in the search interval.

brent's minima method

y = cos(x)

minima = 3.14159265359

error = 0

The error displayed here is pi minus the value computed by the minima function.