sympy and mpmath give "TypeError: cannot create mpf" when using the erf() function within solveset()
<p>I have 4 input variables (floats):</p>

<ul>
<li>Xmax</li>
<li>Xmin</li>
<li>percentage</li>
<li>mode</li>
</ul>

<p>and I want to solve the following (rather long) equation for s:</p>

<pre><code>&gt; (1/2+1/2*erf((log(Xmax)-(log(mode)+s**2))/(sqrt(2)*s))-(1/2+1/2*erf((log(Xmin)-(log(mode)+s**2))/(sqrt(2)*s))) - percentage == 0
</code></pre>

<p>I want to use mpmath and sympy to solve the equation, but it gives me the following error message:</p>

<blockquote>
  <p>TypeError: cannot create mpf from 0.707106781186547*(-s**2 -
  0.287682072451781)/s</p>
</blockquote>

<p>My code is as follows:</p>

<pre><code>from mpmath import erf, log, sqrt
from sympy import Symbol, solveset, S

percentage = 0.95
mode = 2
Xmin = 1.
Xmax = 1.5
s = Symbol('s')

eqn = (1/2+1/2*erf((log(Xmax)-(log(mode)+s**2))/(sqrt(2)*s))-(1/2+1/2*erf((log(Xmin)-(log(mode)+s**2))/(sqrt(2)*s))) - percentage)

solveset(eqn, s, domain=S.Reals)
</code></pre>

<p>mpf is the float type created by mpmath.</p>

<p>I think I narrowed down the problem to the erf() function, it returns </p>

<pre><code>EmptySet()
</code></pre>

<p>when i run </p>

<pre><code>solveset(log(Xmax) - (log(mode) + s ** 2), s, domain=S.Reals)
</code></pre>

<p>I cannot figure out what to try next, any help would be appreciated!</p>

<p>I initially thought it was an issue with the math but the equation is solved successfully in matlab, so the problem is probably coming from sympy or mpmath. </p>