Chapter 14. Comprehensive Examples

In this chapter, we present some comprehensive and longer examples together with a brief introduction to the theoretical background and their complete implementation. By this, we want to show you how the concepts defined in this book are used in practice.

Polynomials

First, we will demonstrate the power of the Python constructs presented so far by designing a class for polynomials. We will give some theoretical background, which leads us to a list of requirements, and then we will give the code, with some comments.

Note, this class differs conceptually from the class numpy.poly1d.

Theoretical background

A polynomial: p(x) = an x n + an-1 xn-1+…+ a1x + ais defined by its degree, its representation, and its coefficients. ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.