- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Python - Getting started with SymPy module

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python. SymPy only depends on mpmath, a pure Python library for arbitrary floating point arithmetic, making it easy to use.

## #Installing sympy module

pip install sympy

SymPy defines following numerical types: Rational and Integer. The Rational class represents a rational number as a pair of two Integers, numerator and denominator, so Rational(1, 2) represents 1/2, Rational(5, 2) 5/2 and so on. The Integer class represents Integer number.

SymPy uses mpmath in the background, which makes it possible to perform computations using arbitrary-precision arithmetic. That way, some special constants, like exp, pi, oo (Infinity), are treated as symbols and can be evaluated with arbitrary precision.

## Example

# import everything from sympy module from sympy import * # you can't get any numerical value p = pi**3 print("value of p is :" + str(p)) # evalf method evaluates the expression to a floating-point number q = pi.evalf() print("value of q is :" + str(q)) # equivalent to e ^ 1 or e ** 1 r = exp(1).evalf() print("value of r is :" + str(r)) s = (pi + exp(1)).evalf() print("value of s is :" + str(s)) rslt = oo + 10000 print("value of rslt is :" + str(rslt)) if oo > 9999999 : print("True") else: print("False")

## Output

value of p is :pi**3 value of q is :3.14159265358979 value of r is :2.71828182845905 value of s is :5.85987448204884 value of rslt is :oo True

- Related Questions & Answers
- Python Getting started with psycopg2-PostgreSQL
- Getting started with coding
- Getting Started with C++ in Visual Studio
- Rust programming language – Getting Started
- Contributing to Open Source : Getting Started in C++
- Get Started With Selenium and Python Automation
- Python - Working with .docx module
- Getting Error while calling XBP Function Module via SAP.net connector
- How to Get Started with C++ Programming?
- How do I get started with Node.js?
- Python getpass Module
- Fraction module in Python
- Import module in Python
- Keyboard module in Python
- colorsys module in Python