# minimization without constraints gives error for multiple dimension

I'm trying to use `minimize(func, x0, gradient=None, hessian=None, algorithm='default', verbose=False, **args)`

given the gradient function. But I'm getting the following error:

```
sage: f = lambda x : (x*y)**4
sage: g = lambda x : 4*y*(x*y)**3
sage: y = random_vector(RR, 5)
sage: x = random_vector(RR,5)
sage: minimize(f, x, gradient=g)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```

What am I doing wrong? the gradient return a vector (correctly so). Shouldn't this work?

`minimize`

wants to minimize real-valued function but the codomain of the lambda function that you provide is not the real numbers because it contains a symbolic variable:Also that function

`f`

is not defined over`R^5`

so you can't start the minimization algo at such a point.you are right, it should have been as below, and then x domain is now the one I want

thanks, I'll try again like so

`minimize`

uses`numpy.ndarray`

objects so you might have to turn them into vectors to make it work:is there a way to use sum([x,y]) for x=var('x')?, with x and y in R^5

Sorry, I don't understand what you mean. You seem to prefer to use

`def`

and`lambda`

functions. In that case, you don't need the symbolic variables`x=var('x')`

.