Get "TypeError: cannot create mph' When Using sympy.nsolve()
<p>I am attempting to determine the time, angle and speed that something would have to travel to intersect with a moving ellipse.  (I actually want these conditions for the minimum time).  Right now I was trying to use Sympy to help with this adventure.  The following is the code which I am executing:</p>

<pre><code>import sympy as sp
sp.init_printing()

delta_x, delta_y, t = sp.symbols('delta_x delta_y t', real=True, positive=True)
V, V_s, x_0, y_0, theta_s, theta_t = sp.symbols('V V_s x_0 y_0 theta_s theta_t', real=True)
x, y = sp.symbols('x y', real=True)

EQ1 = sp.Eq(((x-(x_0+V*sp.cos(theta_t)*t))/(delta_x+V*sp.cos(theta_t)*t))**2+((y-(y_0+V*sp.sin(theta_t)*t))/(delta_y+V*sp.sin(theta_t)*t))**2-1, 0)
sx = sp.Eq(x, V_s*sp.cos(theta_s)*t)
sy = sp.Eq(y, V_s*sp.sin(theta_s)*t)

mysubs = [(V,5), (x_0, 10), (y_0, 10), (theta_t, 7*(sp.pi/4)), (delta_x, 0), (delta_y, 0)]
sp.nsolve((EQ1.subs(mysubs), sx.subs(mysubs), sy.subs(mysubs)), (V_s, theta_s, t), (5, 0.0, 1))
</code></pre>

<p>The result of this operation yields:</p>

<pre><code>---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sympy/mpmath/calculus/optimization.py in findroot(ctx, f, x0, solver, tol, verbose, verify, **kwargs)
    927         try:
--&gt; 928             fx = f(*x0)
    929             multidimensional = isinstance(fx, (list, tuple, ctx.matrix))

&lt;string&gt; in &lt;lambda&gt;(_Dummy_75, _Dummy_76, _Dummy_77)

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sympy/mpmath/matrices/matrices.py in __init__(self, *args, **kwargs)
    300                     for j, a in enumerate(row):
--&gt; 301                         self[i, j] = convert(a)
    302             else:

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sympy/mpmath/ctx_mp_python.py in convert(ctx, x, strings)
    661             return ctx.convert(x._mpmath_(prec, rounding))
--&gt; 662         return ctx._convert_fallback(x, strings)
    663 

/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/sympy/mpmath/ctx_mp.py in _convert_fallback(ctx, x, strings)
    613                 raise ValueError("can only create mpf from zero-width interval")
--&gt; 614         raise TypeError("cannot create mpf from " + repr(x))
    615 

TypeError: cannot create mpf from 0.08*(x - 13.535533905932737622)**2 + 0.08*(y - 6.464466094067262378)**2 - 1
</code></pre>

<p>Is this because the system is not constrained enough?  There is a family of angles and velocities which could be used to intercept the moving ellipse.  This error does not seem to imply this. (Yes, even when I attempt to constrain V_s in this problem the same error appears).</p>

<p>I am using the following versions of things:</p>

<pre><code>| Software | Version   |
|----------|-----------|
| python   | 3.5.2     |
| sympy    | 1.0       |
| mpmath   | 0.19      |
</code></pre>

<p>The variables <code>x</code> and <code>y</code> are still symbolic in the equations. <code>nsolve</code> requires all variables to be specified, and at least as many equations as variables. So you either need to include values for them in <code>mysubs</code>, or else solve for them (but to do that with <code>nsolve</code>, you will need two more equations). </p>

python sympy