user1535776
user1535776

Reputation: 607

find a value other than a root with fsolve in python's scipy

I know how I can solve for a root in python using scipy.optimize.fsolve.

I have a function defined f = lambda : -1*numpy.exp(-x**2) and I want to solve for x setting the function to a certain nonzero. For instance, I want to solve for x using f(x) = 5.

Is there a way to do this with fsolve or would I need to use another tool in scipy? In other words, I'm looking for something analogous to Maple's fsolve.

Upvotes: 0

Views: 493

Answers (1)

mgilson
mgilson

Reputation: 309891

This is easy if you change your definition of f(x). e.g. if you want f(x) = 5, define your function: g(x) = f(x) - 5 = 0

Upvotes: 4

Related Questions