Assumptions in sympy arbitrary functions
<p>With SymPy we can set assumptions on variables:</p>

<pre><code>from sympy import *
x = Symbol('x', real=True)
x, re(x), im(x)
</code></pre>

<p>the result is :</p>

<pre><code>(x,x,0)
</code></pre>

<p>as expected. But if we try to do the same for a function:</p>

<pre><code>from sympy import *
x = Symbol('x', real=True)
f = Function('f', real=True)(x)

f, re(f), im(f)
</code></pre>

<p>the result is :</p>

<pre><code>(f(x),re(f(x)),im(f(x)))
</code></pre>

<p>but I expected something as </p>

<pre><code>(f(x),f(x),0)
</code></pre>

<p>The question is then: Is there a way to make python assume the range of the function to be real, i.e.</p>

<p>In this previous <a href="https://stackoverflow.com/questions/40298497/sympy-arbitrary-function-range">question</a> it is partially answered, but if the we take the derivative we get again the same problem:</p>

<pre><code>from sympy import *
x = Symbol('x', real=True)
class f(Function):
    is_positive = True
df = f(x).diff(x)


df, re(df), im(df)
</code></pre>

<p>with result:</p>

<pre><code>(f(x).diff(x),re(f(x).diff(x)),im(f(x).diff(x)))
</code></pre>

<p>wanting it to be like</p>

<pre><code>(f(x).diff(x),f(x).diff(x),0)
</code></pre>

<p>is there a way?</p>