Find root of function of 2 variables, with one variable set to constant
<p>I have a function which is explicitly a function of two variables - however in practice, one variable is always set to a constant. For a very simplified version of my function, consider</p>

<pre><code>def twovarfunc(x,z):
     return (x**2) - 2 - z
</code></pre>

<p>where, if I wanted to graph this function, it would always be of the form <code>func(x=np.linspace(),z=const)</code>. In fact, though, I don't actually care about what this function looks like - I just need to find the x-zeroes of this function given a value (or really, a range of values) of z.</p>

<p>I have already had success with, e.g.:</p>

<pre><code>from scipy import optimize as opt   
def onevarfunc(x):
     return x**2 - 4
opt.bisect(onevarfunc,0,5)
</code></pre>

<p>Which returns a decimal that is very close to 2: 1.9999999999998863</p>

<p>My problem is that I don't understand the syntax necessary to tell Python that I want to specify the constant value of the second argument of the function while solving for the roots of the first variable. Unfortunately, I have not found the SciPy documentation helpful in this regard.</p>

<p>I have made a few attempts at finding the right syntax using modules like <code>optimize.minimize</code>, <code>optimize.root</code>, <code>optimize.fsolve</code>, but I haven't been able to get it.</p>

<p>I am very new to Python (and OOP in general) - my prior experience is in MATLAB, Igor Pro, and Mathematica. It's possible (probable?) that there is a very simple solution that I'm not seeing.</p>

<p>For the physics-inclined folks here, I am trying to find a variational solution of a function of which <code>twovarfunc(x,z)</code> is the derivative with respect to x.</p>