# Optimizing a simple 2D parabolaΒΆ

In this example, we will use Optunity to optimize a very simple function, namely a two-dimensional parabola.

More specifically, the objective function is \(f(x, y) = -x^2 - y^2\).

The full code in Python:

```
import optunity
def f(x, y):
return -x**2 - y**2
optimal_pars, details, _ = optunity.maximize(f, num_evals=100, x=[-5, 5], y=[-5, 5])
```

For such simple functions we would use different solvers in practice, but the main idea remains.

To get a basic understanding of the way various solvers in Optunity work, we can optimize this function with all solvers and plot the resulting call logs. The source code for this example is available in bin/examples/python/parabola.py. Below are plots of the traces and precision of various solvers in optimizing a 2D parabola. These results are averaged over 200 runs, in each run the solvers got a budget of 100 function evaluations with the box \(x=(-5, 5)\), \(y=-(5, 5)\).

Note that both Nelder-Mead simplex and CMA-ES started from an initial solution close to the optimal one. The results on this toy problem do not generalize directly to a real tuning problem.