SymPy Tutorial
Selected Reading
- SymPy - Discussion
- SymPy - Useful Resources
- SymPy - Quick Guide
- SymPy - Printing
- SymPy - Sets
- SymPy - Entities
- SymPy - Plotting
- SymPy - Solvers
- SymPy - Quaternion
- SymPy - Function class
- SymPy - Matrices
- SymPy - Integration
- SymPy - Derivative
- SymPy - Simplification
- SymPy - Querying
- SymPy - Logical Expressions
- SymPy - Lambdify() function
- SymPy - evalf() function
- SymPy - sympify() function
- SymPy - Substitution
- SymPy - Symbols
- SymPy - Numbers
- SymPy - Symbolic Computation
- SymPy - Installation
- SymPy - Introduction
- SymPy - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
SymPy - evalf() function
SymPy - evalf() function
This function evaluates a given numerical expression upto a given floating point precision upto 100 digits. The function also takes subs parameter a dictionary object of numerical values for symbols. Consider following expression
>>> from sympy.abc import r >>> expr=pi*r**2 >>> expr
The above code snippet gives an output equivalent to the below expression −
$Pi{r^2}$
To evaluate above expression using evalf() function by substituting r with 5
>>> expr.evalf(subs={r:5})
The above code snippet gives the following output −
78.5398163397448
By default, floating point precision is upto 15 digits which can be overridden by any number upto 100. Following expression is evaluated upto 20 digits of precision.
>>> expr=a/b >>> expr.evalf(20, subs={a:100, b:3})
The above code snippet gives the following output −
33.333333333333333333
Advertisements