Optimizing math functions
Robert Kern
robert.kern at gmail.com
Sat May 23 17:21:46 EDT 2009
On 2009-05-23 08:22, Esmail wrote:
> Hello all,
>
> I would like to maximize or minimize a given math function over a
> specific set of values, in Python preferably.
>
> I was checking out Wolfram Alpha (http://www70.wolframalpha.com/)
> and it can do simple optimization problems in math, such as
>
> maximize 15*x - x**2 over 0 to 15
>
> (http://www70.wolframalpha.com/input/?i=maximize+15*x+-+x**2+over+0+to+15)
>
> which finds the maximum value and input for x in the range 0 to 15.
> Very cool. (This is of course a very simple example).
>
> What it apparently can't do is for maximize (or minimize) functions
> that contain two variables, x and y, or more. So for example a simple
> example would be
>
> maximize x**2 + y**2 over x:0 to 15, y:0-12 -- this does not work
> -- though I'm unclear about
> -- the correct syntax too.
>
> Is there some sort of simple Python module that would allow me to
> evaluate this type of function?
>
> In this particular instance I am interested in the minimum of
>
> x * sin(4*x) + 1.1 * sin(2*y), where x,y in range 0-10
>
> though in other problems the range may not be identical for x and y.
We have several bounded optimization routines in scipy.
http://docs.scipy.org/doc/scipy/reference/optimize.html
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list