JustANoob
JustANoob

Reputation: 620

ValueError using scipy.optimize on multidimensional function

What am i doing wrong here?

import numpy as np
import scipy.optimize as so

def f(z):
  return z


guess=np.array([1,1])
z0=so.newton(f,guess)

Im getting the following error:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

There is some info on scipy docs about vectorizing the function if its domain is multivalued, but cant quite understand what i have to do.

Upvotes: 0

Views: 67

Answers (1)

Ralf
Ralf

Reputation: 16515

If I run your code with an older version of the lib (Python 3.6.3, scipy 1.1.0), then I get the same error that you showed in your question.

When I upgrade to a newer version (same python, scipy 1.2.1) then the error goes away and the code runs fine.

Upvotes: 1

Related Questions