Book Image

Mastering Python Scientific Computing

Book Image

Mastering Python Scientific Computing

Overview of this book

Table of Contents (17 chapters)
Mastering Python Scientific Computing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Polynomials


SymPy allows us to define and perform various operations on polynomials. We can also find the roots of polynomials. We have already covered the simplify, expand, factor, and solve methods. These methods also perform the functionalities for polynomials. To check for the equality of two polynomials, we should use the simplify function:

from sympy import *

p, q = symbols ('p q')
p = (x+4)*(x+2)
q = x**2 + 6*x + 8
p == q # Unsuccessful
p - q == 0 # Unsuccessful 
simplify(p - q) == 0