Repository: sympy/sympy

Issue:
nsolve does not accept starting vector of type Matrix
nsolve gives a TypeError when given a Matrix for the starting vector, requiring instead a manual conversion to a list via `v0.T.tolist()[0]`. Notably, nsolve is fine with a Matrix expression for the equation.

A minimal example:
```
import sympy as sy
v = sy.Matrix(sy.symarray("v", (2,)))
w = sy.Matrix([17, 23])
equation = v - w
```
The following line gives a `TypeError: cannot create mpf from Matrix([[17],[23]])`:
`
sy.nsolve(equation, v, w)
`

The following line gives the correct output, `Matrix([[17.0],[23.0]])`:
`
sy.nsolve(equation, v, w.T.tolist()[0])
`

See [this stackoverflow post](https://stackoverflow.com/questions/51431487/sympy-nsolve-typeerror-with-matrix-starting-vector) for more details.

Discussion:

Patch:
diff --git a/sympy/solvers/solvers.py b/sympy/solvers/solvers.py
index 6717b4cfd7..6e72b573f5 100644
--- a/sympy/solvers/solvers.py
+++ b/sympy/solvers/solvers.py
@@ -2909,6 +2909,8 @@ def nsolve(*args, **kwargs):
             if isinstance(fi, Equality):
                 f[i] = fi.lhs - fi.rhs
         f = Matrix(f).T
+    if iterable(x0):
+        x0 = list(x0)
     if not isinstance(f, Matrix):
         # assume it's a sympy expression
         if isinstance(f, Equality):


Test patch:
diff --git a/sympy/solvers/tests/test_numeric.py b/sympy/solvers/tests/test_numeric.py
index 05cdf25b93..34e8e5cef0 100644
--- a/sympy/solvers/tests/test_numeric.py
+++ b/sympy/solvers/tests/test_numeric.py
@@ -124,3 +124,11 @@ def test_nsolve_dict_kwarg():
 def test_nsolve_rational():
     x = symbols('x')
     assert nsolve(x - Rational(1, 3), 0, prec=100) == Rational(1, 3).evalf(100)
+
+
+def test_issue_14950():
+    x = Matrix(symbols('t s'))
+    x0 = Matrix([17, 23])
+    eqn = x + x0
+    assert nsolve(eqn, x, x0) == -x0
+    assert nsolve(eqn.T, x.T, x0.T) == -x0