Ask Your Question

Revision history [back]

Using numerical values (first case in your question)

a. My first suggestion is to work in RDF, and define pi = RDF.pi(). On the one hand, elements in RDF are close to machine floats, which will usually make your code faster than using RR. On the other hand, they have a wealth of methods you can apply to them, contrary to floats that you get by using pi.n().

b. Personally I would name the numerical value the same as the symbolic constant, eg pi = RDF.pi().
This way the same code can work in both numerical and symbolic setting. Do reset('pi') to revert to the default.

c. If you are always using 2*pi, why not define two_pi = 2 * RDF.pi() and use two_pi all along.

Finally, I don't know much about numpy, scipy, and sympy, but maybe they can help with your question.