It seems that evalf of atan2 currently expects that its arguments are real. 
For symbols like x and y, this
means that they have to be initialized with `real=True`. It does not 
suffice that evalf would return a real
value as assumption code does not try to run evalf.

Kalevi Suominen

On Tuesday, August 20, 2019 at 5:34:21 PM UTC+3, Ville Bergholm wrote:
>
> I've been trying to use sympy.Symbol to implement a system where the 
> numerical value of a symbolic quantity is only fixed when it is evaluated 
> using evalf().
> To accomplish this I've redefined _eval_evalf() to return the 
> aforementioned value (a fixed 5.0 in the toy example below).
>
> This works fine with basic algebraic operations and most SymPy functions. 
> However, for some reason atan2 seems to behave differently and _eval_evalf 
> is never called.
> Is this a bug, or have I misunderstood the purpose of _eval_evalf?
>
>
> import sympy
> import sympy.functions as syf
>
> class A(sympy.Symbol):
>     def _eval_evalf(self, prec):
>         print('*')
>         return sympy.Float(5.0)
>
> x = A('X')
> y = A('Y')
> print('polynomial:')
> print((2*x-4+y).evalf())  # works fine
> print('atan:')
> print(syf.atan(y / x).evalf())  # works fine
> print('beta:')
> print(syf.beta(y, x).evalf())  # works fine
> print('atan2:')
> print(syf.atan2(y, x).evalf())  # prints "atan2(Y, X)", does not call 
> A._eval_evalf
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/5b8f5d4f-478a-44e5-b56d-524d189e99d8%40googlegroups.com.

Reply via email to