Search code examples
sympyatan2

sympy's atan2 not full numerical evaluation


I am using sympy's atan2 and for certain values it isn't giving me the full numerical evaluation but giving me a (value + pi)

from sympy import atan2
print(atan2(0.0037, -0.056))

gives the following output:

-0.0659755361339305 + pi

I want the code to give the numberical value without the "+ pi", in this case 3.07402446387

mpmath's mpf function solves this issue but gives me error messages in other parts of my code. Is there another way of doing this?


Solution

  • from sympy import atan2
    print(atan2(0.0037, -0.056).evalf())
    

    Does excatly what you want.

    from sympy import atan2
    print(atan2(0.0037, -0.056).evalf(30))
    

    Gives you the numerical result with 30 digits precision.