Working with polynomials and calculus
Polynomials are among the simplest functions in mathematics and are defined as a sum:
Here, represents a placeholder to be substituted (an indeterminate), and is a number. Since polynomials are simple, they provide an excellent means for a brief introduction to calculus.
In this recipe, we will define a simple class that represents a polynomial and write methods for this class to perform differentiation and integration.
Getting ready
There are no additional packages required for this recipe.
How to do it...
The following steps describe how to create a class representing a polynomial, and implement differentiation and integration methods for this class:
- Let’s start by defining a simple class to represent a polynomial:
class Polynomial:
"""Basic polynomial class"""
def __init__(self, coeffs):
...