Optimizing math functions

Esmail ebonak at hotmail.com
Sat May 23 15:22:59 CEST 2009

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


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.



ps: Does anyone know if Octave or some other free Linux (or Windows)
     program might also do this in a simple way? My preference would
     still be a Python solution that would be simple to use, ie plug in
     the function, the ranges and have it pop out the solution :-)

More information about the Python-list mailing list