|Doing Math with Python|
Author: Amit Saha
Math and Python? A crossover book - is this a good idea?
Python is a language that is used by scientists and engineers, less so by mathematicians but the math covered in this book isn't so advanced that we need to make a distinction - everyone should know it. The problem is what is the book trying to achieve - teach Python or teach Math?
The idea seems to be that the two help illuminate each other. By writing Python programs that explore the math you will learn math and by tackling math problems in Python you will improve your Python.
It is worth pointing out that the book uses Python 3 which is a good thing.
However this said it is clear that you are going to have to know quite a lot of Python to get anything much from this book. It doesn't attempt to teach Python at all except by example. You could say the same for the math but there are more explanations of the math, they are just not adequate to cope with such a difficult subject. So if you are going to get much from this book it is going to be more like a project book than something that teaches you the concepts you need.
Chapter 1 starts off looking a how numbers are handled in Python - integers and floats are standard programing topics but fractions and complex numbers are also explained using Python modules. The examples are very simple, multiplication tables, factors, units and roots of a quadratic. If you have trouble with the basic math this isn't really going to help.
Chapter 2 is about drawing graphics using Matplotlib. The example projects are gravitation and projectile motion. Chapter 3 is on simple statistics - computing the mean, median and mode, range, variance and correlation.
Chapter 4 is slightly unexpected because it is about using Sympy to do symbolic math. Not quite up to what you can do using Wolfram Alpha or Mathematica on a Raspberry Pi but interesting.
Chatper 5 is about sets and probability and it is also interesting but not very practical. You learn what a set is as a data structure but the examples don't really demonstrate why you might want a set. After all we go to a lot of trouble to implement the set as a data structure we have to make sure that duplicates are eliminated and that there no implied order. So example that make use of sets really need to have the property that the have duplicates that need to be removed and for which set operations are natural - unions, intersections and especially the Cartesian product. The examples don't really do the idea justice.
Chapter 6 returns to graphic but this time drawing mathematical shapes and fractals. It is good to see Barnsley's Fern used as an example rather than the usual Mandelbrot set or Sierpinski triangle etc. However the theory is much more difficult.
The final chapter is about calculus and it introduces limits and derivatives but if you don't already have a good grasp of these ideas I doubt using SymPy is going to help you acquire one. As well as the basics we also take a look at optimization by way of gradient ascent.
The big problem with this book is that it is light on the math. As long as you know enough of the theory then the programming exercises might be interesting enough to deepen your understanding. The really irritating part is that the suggestions for further work the "programming challenges" are a lot more interesting than the simpler examples that are worked out in full. If the book expanded on these then it would be a much more valuable source book of examples.
If you are a math teacher with a knowledge of Python then this book might provide some useful practical examples of the two things working together. I'm not at all sure how you could make use of these in the classroom however unless your students also programme in Python.
This is quite a good book but it's going to struggle to find its readership niche. If you think you fit into it - just enough Python and just enough math - then you will find some of the ideas fun.
|Last Updated ( Sunday, 14 February 2016 )|