Complex Numbers in Python – An Introduction

The Python language provides comprehensive support for complex numbers, with basic functionality being included with the core language and more advanced features included in the cmath module.

This article will demonstrate the basic operations such as arithmetic which does not require any additional modules. I will also go a bit further than that by writing code to carry out these operations without using the Python operators; of course you wouldn't do this in production code but it does provide an insight into how these operations and complex numbers in general work.

Continue reading

Plotting Taylor Series

Previous posts have included an SVG library, memoization of factorials and Taylor Polynomials. In this post I will bring these all together to plot various sine waves created using Taylor Polynomials.

Taylor Polynomials are used to approximate functions, in this case sine, to any level of accuracy. We can plot these levels to show how they become increasingly accurate, which is the subject of this post.

Continue reading

Logarithmic Plots

The majority of data can easily be plotted on a graph with equal intervals on the axes, for example 1, 2, 3 or 100, 200, 300 etc.. Some data, typically that which increases or decreases exponentially, cannot comfortably be graphed on such a scale without squashing the data up so much at one end that it becomes incomprehensible. The solution to this problem is to use a logarithmic scale.

Continue reading

Normal Distribution

One of the most useful bits of number-crunching you can do is to calculate the probability distribution of a set of data in the earnest hope that it will be a reasonable fit for one of the recognised distributions such as the normal distribution. In this project I will write a Python class to calculate the normal distribution for a given data set.

Continue reading