## Visualisation of irrational numbers as vectors

### Beauty in irrationality?

Plotting irrational numbers (pi, e, sqrt2, golden ratio) as vectors allows their complexity to be visualised

I have always wanted to visualise irrational numbers. Our brains are capable of recognising patterns in nature and I wanted to know if these patterns could be visualised in irrational numbers, and whether beautiful patterns could be seen that could lead to an further understanding of the irrational nature of the numbers. Just found out after publishing this article that the idea has been round for a while! (here is an interesting blog article). Here I have extended the technique to 3 dimensions for better visualisation and give results and computer code.

### Experimental Technique

In this experiment the fractional parts of the irrational numbers, pi, e, sqrt2 and golden ratio are transformed into vectors in cartesian space for visualisation purposes. Each digit of the number sequence (from left to right) is transformed into a spatial vector with unit length. The orientation is calculated from the number as: angle = (digit/10)*2*pi. Sine and cosine functions are used to derive a position in the cartesian plane relative to the position of the previous digit (see code below for more details). As the irrational number is described to greater precision its decimal place increases, this occurs on the number string from left to right. As we are traversing the number sequence this corresponds to increasing time steps of the number analysis. On the plots the sequence position of the digit (its decimal place) is colour coded using a heat mapping (blue->red on increasing significant digits). The 3D plots also gives the sequence position of the digit on the Z axis, this helps to separate overlapping sequences in cartesian space.

### Visualisation/Results

These plots are the results of the analysis, please click them for more detail

### Data and Matlab/Octave computer code

Below is the Matlab/Octave code used for generating the plots. Data can be downloaded here: pi, e, golden ratio, sqrt2 (data is without decimal point!)

function  irrational_number_plot_as_vector(filepathname)
%   requires file name containing string of irrational number delete decimal point from string ie 3.14... -> 314...

% read text file containing number
format = "%1c"

fileID = fopen('pi.txt','r');

p = fscanf(fileID, format);

_p=0;

% convert character string to matlab array
for i=1:length(p); _p(i)  = str2double(strcat(p(i),".0")); end

% create arrays for plotting
x_array = zeros(1,length(_p));
y_array = zeros(1,length(_p));

% polar angle
for i=2:length(_p); x_array(i) = x_array(i-1)+cos((_p(i-1)/10.0)*2.0*pi); y_array(i) = y_array(i-1)+sin((_p(i-1)/10.0)*2.0*pi); end

% surface plot with z axis and colour blue->red as increased fractional part
h = surface([x_array(:), x_array(:)], [y_array(:), y_array(:)], [[1:length(_p)]', [1:length(_p)]'], [[1:length(_p)]', [1:length(_p)]'], 'EdgeColor','flat', 'FaceColor','none');

end

There is a new feature on MegaTangram called “create tangram picture” it is accessible either from the menu or by double clicking on one of your completed tangrams in the top of the screen. You must be logged or have completed some puzzles to add them to the canvas area. Any completed tangrams can be used as stamps and individually resized and re-coloured. An image can also be uploaded and used as the picture background. Once you are happy with the picture it can be send to facebook using the facebook upload button (directly above the zoom control).

## Here is a preview of the upcoming MegaMosaic HTML5 application.

Colourful mosaic patterns can be created from different sized building blocks. Resize and copy basic building block shapes, triangles, rectangles, circle, square, pentagon, hexagon parallelogram etc.

### User tangram puzzles can now be saved and viewed in the user home page area.

The user home page is a place where you can view all your completed puzzles. The tangram puzzle now has the ability to create your own tangram puzzles using unlimited amounts of the 7 tangram building block pieces.

To do this just click on the user tangram button in the top right corner of the MegaTangram screen and start building your tangram design. To save your user tangram click the button again. The new puzzle will be added to the user home page and also shown in the completed puzzle area on the top of the puzzle screen.

## User tangram functionality

### Construct your own tangram picture using as many shapes as needed

By clicking on the user tangram button a tangram picture can be designed. As many shapes as needed can be dragged from the bottom of the screen into the puzzle area to use making a pattern or picture. Zoom in and out and move the canvas around to give yourself more space in which to build. User tangrams can be seen on the user home page as well as in the MegaTangram game

## Understanding mortgages/loans

### How mortgages or loans companies make money from you

In our mortgage example we are going to borrow 140,000 pounds at an interest of 6.5% annually for a term lasting 30 years. The main calculation will be how much of the principal (amount borrowed is paid back every month). For this we will use the annuity formula, where r is the monthly interest rate expressed as a decimal (r=yearly_rate/12/100), P is the principal or the amount borrowed and N the number of months in the full term.

c=(r*P)/((1-(1+r)^-N))

Using this formula we can calculate our monthly payment (c=885 pounds). The other formula we need is for the debt schedule which tells us how much of the principal gets paid off every month which we will term p.

p=((1+r)*P’)-c

Where P’ is the previous months outstanding amount (p) which at the beginning of the term will be equal to P (More information on the formulas used can be found here).

I have generated a few plots from the formulas given above to try to demonstrate what happens to your money when you pay back a mortgage or loan. For example the plot of p vs N below shows a typical repayment curve for the borrowed money

You can see in this figure that the amount of the capital that you pay back in the beginning years is not much with most of the money being spent paying back the interest. This means that if you move early on in the term you wont get much money back from the mortgage, therefore it is better if possible to hang in there until the full term has ended.

The next figure shows the proportions of the monthly mortgage payment split between capital and interest payments as the mortgage progresses. It actually takes 19 years 4 months before capital payments are greater than the interest payments in a 30 year mortgage.

The final figure shows just how much extra money is made from lending the money and which proportion of this is interest or capital repayment. You actually pay more money towards interest than you do towards capital and the total money spent during the mortgage term is more than double the money borrowed.

Thank you Wikkipedia, Gnumeric and MathJax

## Music of the Chemical Spheres 2: listening to molecular vibrations

The Music of the Chemical Spheres webpage has been redesigned and now has audio from 40 molecules. The improved interface enables the sounds to be heard by clicking on keyboard like buttons or using keys on the keyboard. Matlab Octave source code is given.

## Responsive social sharing toolbar

The social tool bar featured on this site came from this excellent blog post. I really liked the social bar so I added it to the ejectamenta site. I have created some files to make it easy to install (click the links to download) responsive-share-bar.js and responsive-share-bar.css , and some 32×32 pixel image icons shareicons.zip. Save these files somewhere on your webserver and remember the path. Add this code in the head section of you

<link rel="stylesheet" type="text/css" href="http://www.yourwebsitename.com/path/to/file/responsive-share-bar.css"/>

Then add the reference to the javascript file just before the tag.

<script async type="text/javascript" src=""http://www.yourwebsitename.com/path/to/file/responsive-share-bar.js"></script>

Then copy the following html code to the body section of your webpage

<div id="share-wrapper">
<ul class="share-inner-wrp">

<!-- reddit -->
<li class="reddit button-wrap"><a href="#">Reddit</a></li>

<!-- Digg -->
<li class="digg button-wrap"><a href="#">Digg it</a></li>

<!-- Stumbleupon -->
<li class="stumbleupon button-wrap"><a href="#">Stumbleupon</a></li>

<!-- Delicious -->
<li class="delicious button-wrap"><a href="#">Delicious</a></li>

<!-- Email -->
<li class="email button-wrap"><a href="#">Email</a></li>
</ul>
</div>

For the linkedin summary field I get this from the meta-description tag on the page, so your page should have something like the following on it. If it is longer than 256 chars, linkedin say that they will truncate the string and use ellipses.

<meta name='description' content='How to install a responsive toolbar for your website that works well on desktop and mobile websites'>

That’s it, you should now have a good looking, slide out, and responsive social toolbar for your website, just like you see on the left of this page, please share if you like my site.

All The code was webpage formatted using the CodeToHTML converter

## Ejectamenta puzzles now as apps on Facebook

So far befuddled, KubicRube and Peg Solitare are on facebook as apps, here are some image links to the apps on facebook.

I am working on getting MegaTangram and Hexpac also on Facebook as apps and am working on functionality for sharing and swapping puzzles between friends at the moment. Here is a picture of how MegaTangram is looking at the moment (link not working at present as app in sandbox mode).