## Complex Plots in SAGE Math

After playing around with SAGE-Math over the last week I discovered that it is possible to plot complex-valued functions. Unfortunately complex functions are functions from $\mathbb{C}$ to $\mathbb{C}$ which means that unless you are pretty good at visualising things in four dimensions it can be tricky to visualise them. A function from $\mathbb{R}$ to $\mathbb{R}$ such as $y=x^{3}-5x^{2}+4x+14$, which is a function from a one-dimensional space to another one-dimensional space, can be displayed on the familiar two-dimensional $x$-$y$-axes as in the diagram below.

The graph of a cubic equation

However, with a function from $\mathbb{C}$ to $\mathbb{C}$ we are taking points from a two-dimensional space to another two-dimensional space so we would need four dimensions to plot the graph of the function. I don’t know about you but I’ve never really got the hang of seeing things in four dimensions so we have to have a different way of displaying the data. This is where SAGE comes in useful.

Here is a plot of the function $f(z)=\dfrac{z^{2}}{1+z^{4}}$ that I put into SAGE to plot.

Plot of a complex-valued function.

The code that I used to do this is surprisingly simple:

p = complex_plot(lambda z: (z^2)/(1+z^4), (-2, 2), (-2, 2));p

The plot shows what happens to each complex number after it has been transformed. The colours in the plot correspond to different behaviours of the function.

In the plot above, zero is the only point that is mapped by the function to zero – notice how the colours are quite dark near the origin; this means that these points are mapped to other points in the complex plane of small magnitudes. Darker colours correspond to points that are mapped to complex numbers of relatively small magnitudes and lighter shades represent points that are mapped to complex numbers of larger magnitudes. As you move out from the centre the colours become lighter and there are white spots at the points $\dfrac{1}{\sqrt{2}}(1+i), \dfrac{1}{\sqrt{2}}(1-i), \dfrac{1}{\sqrt{2}}(i-1), -\dfrac{1}{\sqrt{2}}(1+i)$ these are the singularities, or poles, of the function – these are the points that can be considered as being mapped to infinity.

The plot has a certain degree of symmetry – any points that are the same colour are mapped by the function to the same point. For example $z=1+\dfrac{3}{2}i$ and $z=-1-\dfrac{3}{2}i$ are mapped to the same point and are therefore the same colour on the plot. I’m sure that I will be able to use these plots in the future – here’s a few more that I managed to create of the functions $f(z)=\dfrac{\mathrm{sin}(3z)}{1+z^{4}},\; f(z)=z^{2}$ and $f(z)=\dfrac{z^{3}-3z^{2}+4}{z^{4}-2z^{2}+12}$

## Fourier Transforms Part 2

Following on from the post that I made a couple of weeks ago introducing Fourier Transforms – this post will go into a little bit more detail and I will be looking at a simple example of a particular transform to illustrate what is happening. I will try to keep things as simple as possible – there are certain regularity conditions that would need to be applied in the general case, but here I will be choosing functions that satisfy these conditions anyway.

For a function $f(x)$ its Fourier Transform is defined to be $$\hat{f}(k)=\int_{-\infty}^{\infty}\!{f(x)e^{-2 \pi ikx}} \;\mathrm{d}x$$

The function $f(x)$ is in the time-domain with $x$ representing time. The transform $\hat{f}(k)$ is in the frequency-domain with $k$ representing the frequency.

I decided to make a video to visually present Fourier Transforms. They are something that I have always personally had difficulty visualising and making this video has helped me to understand them even better and I hope that it will help others likewise. Fourier Transforms are generally complex-valued functions and in some cases can be very difficult to find as an explicit formula. However, in the video below, I have chosen the function $\mathbf{cos}(2\pi(2x))\mathbf{e}^{-x^2}$ to work with which has a real-valued Fourier Transform that can be explicitly stated; I will typing-up the derivation of the Fourier Transform over the coming weeks.

I would love to hear any comments about how the video could be improved and any feedback on the video.

## An Interesting Application of Mathematics

The internet is a strange place – you don’t know where you will end up.

A couple of days ago I was searching on the internet for some information about Fourier Series and Fourier Transforms – I managed to find some information that looked interesting (and it was…I promise) but then I started clicking around. I didn’t expect to end up where I eventually did.

From Fourier Transforms I moved to looking at crystal-structures – Fourier Transforms are widely used in the technique known as X-ray crystallography so this isn’t really surprising. But from there I started looking at Bravais lattices then Point Group Symmetries and finally, I ended up looking at something that I didn’t expect.

Now, I know that mathematics has many applications in science and technology but I downloaded a pdf file that was linking some quite deep mathematics with…..bead-weaving. Really? Yes, really. You can download the document here for yourself. The author of the document also has a Youtube video titled Mathematical Bead Weaving which is well worth watching and even a website.

I have to say that I was almost tempted to go out and buy some needles and beads and get to work – this is a very unique and creative way of linking two topics that, at first, appear to be completely unrelated. I would love to see more of this kind of stuff.

## Fourier Transforms – An Introduction

I have been taking quite an interest in Fourier Transforms lately. Fourier Analysis was one of the courses that I did during my final year at Warwick – I didn’t know what to expect at the time since I had heard about Fourier Series and Fourier Transforms but had never really worked with them or studied any of the theory. The course, like many of the other maths courses at Warwick, was very fast-paced and extremely demanding. I spent most of my time trying to keep up with all of the definitions, theorems and proofs not just from this course but from all of the other courses that I was doing at the time. I more or less just had to accept that there existed these things called Fourier Transforms but I never really got round to settling down to try and visualise them to really understand what they were (after all, there are only 24 hours in a day).

Well, a few years later and I have managed, to some degree, to do just that – better late than never; but I realise now how exciting and interesting Fourier Transforms are (no, really).

Fourier Transforms are a way of breaking a function down. The function can (and often does) represent a sound wave and the Fourier Transform enables you to analyse the frequencies that are involved – the transform tells you which frequencies are present and how much a particular frequency contributes to the overall sound wave being analysed.

From the transform it is then possible to see which frequencies are dominant in the sound wave and what gives it its characteristic feel. For example, a sound wave produced by a guitar will be very different from the sound wave produced by a saxophone – even though they may be playing the same note, neither one is playing a completely pure note; each will have various other frequencies present and in different amounts which all interact with each other to produce the sound that you recognise as either a guitar or a saxophone. This explains why it is possible to distinguish the sound of one instrument from the sound of a different instrument just by listening to them – as your ear receives the various frequencies all interacting with each other your brain is then able to recognise the characteristic pattern of the wave and determine whether you are listening to a violin or a piano.

Fourier transforms take the original function (which is in the time-domain) and converts it to a function in the frequency-domain.

Here is an example

 Rectangle Function Sinc Function

The picture on the left is the rectangle wave (very important in digital signal processing) and the picture on the right is its Fourier Transform, the sinc function defined by $$f(x)=\dfrac{\mathrm{sin}(\pi x)}{\pi x}$$

The sinc function tells us that the dominant frequencies in the rectangle wave are between 0 and 1 and as the frequency gets higher then its contribution generally decreases. This is just the beginning – Fourier theory finds its way into many different and unexpected areas of science from pure mathematics, to signal processing, astronomy and music technology.

I have been playing around with Fourier Transforms on SAGE Math over the last couple of days so I will be posting a bit more about them over the coming weeks and going into a bit more detail with them.

## Introducing Fractals

Throughout my studies at University for my maths degree I did courses in all sorts of different topics – but because of the sheer number of courses that were on offer I never got round to doing the course called “Fractal Geometry”. Which is a shame.

What is a fractal? Fractals are not easy to define; even among mathematicians there can be disagreement about how to define a fractal – but a fractal is something that, loosely-speaking, displays some degree of self-similarity at all levels of magnification. In other words, you could zoom in as much as you want on a fractal and what you see will in some ways resemble the original fractal.

Although I suspect that the course at Warwick would have been more concerned with the theoretical aspects of of fractals and fractal analysis, the fractals that are actually being analysed can be very interesting and visually appealing.

Probably one of the most famous fractals is called the Mandelbrot set – it looks like this;

The Mandelbrot Set

This fractal can be created using a very simple formula that someone with even a basic understanding of mathematics can understand. Not only is this fractal interesting from a theoretical perspective, I think it is also interesting from a visual perspective. From this single fractal it is possible to generate countless different fractals such as these Julia Sets

The above images were produced using some fractal-generating software that is freely available, and surprisingly easy to use, called Fraqtive.

There is a considerable amount of theory surrounding fractals; I’m working on learning some of the theory but for the time-being it doesn’t stop me from appreciating how beautiful these things can be.

The Mandelbrot set is just one example of a fractal – there are millions of other examples, each of which has its own character. Fractals appear all over the place, probably without you even noticing them.

No doubt I’ll be coming back to fractals at some point in the future.