Thank you very much

Is there a way, like f.is_real, to tell sympy that f(x).diff(x) is real, so 
that print((f(x).diff(x)).is_real) will be true? Right now the output of 
print((f(x).diff(x)).is_real) is none.

On Tuesday, August 11, 2015 at 8:24:45 PM UTC-5, Aaron Meurer wrote:
>
> It looks like some parts of the assumptions could be improved here. 
>
> Probably the simplest way to get what you want is to blanket replace all 
> instances of re() with the identity function and im() with 0, like
>
> In [21]: print(a.replace(re, Id).replace(im, lambda x: 0))
> Derivative(f(x), x)*Subs(Derivative(_xi_2, _xi_2), (_xi_2,), 
> (Derivative(f(x), x),))/Abs(Derivative(f(x), x))
>
> In [22]: print(a.replace(re, Id).replace(im, lambda x: 0).doit())
> Derivative(f(x), x)/Abs(Derivative(f(x), x))
>
> Aaron Meurer
>
> On Tue, Aug 11, 2015 at 6:07 PM, chaowen guo <[email protected] 
> <javascript:>> wrote:
>
>> Hi:
>>
>> source code:
>> import sympy
>> x=sympy.symbols('x',real=True)
>> f=sympy.symbols('f',cls=sympy.Function)
>> f.is_real=True
>> a=sympy.Abs(f(x).diff(x)).diff(f(x).diff(x))
>> a
>>
>> the output is:
>>
>> (re(Derivative(f(x), x))*Subs(Derivative(re(_xi_2), _xi_2), (_xi_2,), 
>> (Derivative(f(x), x),)) + im(Derivative(f(x), x))*Subs(Derivative(im(_xi_2), 
>> _xi_2), (_xi_2,), (Derivative(f(x), x),)))/Abs(Derivative(f(x), x))
>>
>>
>> the imaginary part still exist. Obviously, sympy does not think 
>> f(x).diff(x) is real. So I try:
>> sympy.refine(a,sympy.Q.real(f(x).diff(x)))
>> but the output remains the same. So how to tell sympy that f(x).diff(x) 
>> is real?
>>
>> More weird stuff is:
>> f(x).diff(f(x))
>> the output is 1
>>
>> but:
>> sympy.Abs(f(x)).diff(f(x))
>> the output is:
>>
>> f(x)*Subs(Derivative(re(_xi_2), _xi_2), (_xi_2,), (f(x),))/Abs(f(x))
>> why sympy is not smart enough to simplify it to f(x)/Abs(f(x))?
>>
>> I use python3.4 and sympy 0.7.6
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] <javascript:>
>> .
>> Visit this group at http://groups.google.com/group/sympy.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/2deb519b-9cdd-4b2e-93d7-f3f252ff8fc6%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/2deb519b-9cdd-4b2e-93d7-f3f252ff8fc6%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/bd709ced-bc6f-4db2-ab51-57989354eda8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to