Evaluating symbolic expressions

In the context of scientific computing, there is often the need of first making symbolic manipulations and then converting the symbolic result into a floating-point number .

The central tool for evaluating a symbolic expression is evalf. It converts symbolic expressions to floating-point numbers by using the following:

pi.evalf()   # returns 3.14159265358979

The data type of the resulting object is Float (note the capitalization), which is a SymPy data type that allows floating-point numbers with an arbitrary number of digits (arbitrary precision). The default precision corresponds to 15 digits, but it can be changed by giving evalf an extra positive integer argument specifying the desired precision in terms the numbers ...

Get Scientific Computing with Python 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.