Wednesday, 15 December 2010

Faking Hirst with four lines of code

I don't know anyone who's not grateful that computers have replaced humans for performing tasks like doing arithmetic calculations or searching for bits of information. Few think, however, that humans can be replaced for creating art. I have yet to see a computer-generated piece selling for millions.

But how difficult is it to mimic art pieces on a computer? Are pieces worthless because they can easily be replicated? And who gets the credit (or the money) for a computer-generated piece - the programmer or the computer?

Here are two examples to put things in perspective. First, my replica of Damien Hirst's polka-dot-LSD painting, obtained with only a few Mathematica lines:


The advantage of using the computer here is obvious: I can generate endless variations of Hirst's piece with different colors at random at the touch of 'Shift-Enter'. How's that for simplicity and productivity?

Needless to say perhaps, I'm not a big fan of Hirst, and being able to generate what he sold (or copied) for £43,300 doesn't help me appreciate what he does.

Next, a piece of Bridget Riley I saw described this morning by Adrian Searle on the Guardian website:


Searle says about the piece: "I can't see the system of drawing at all... It took about a week, a week to actually execute... What you're watching is your own perception."

I'm not sure about my own perception - even less about Mathematica's - but I know that with a bit of fine-tuning and luck (the output is random after all), I can get close to the original, again with only a few lines of code.

Does that mean that Riley's circles are trivial? Well no. She puts a lot of time on her pieces, as shown in the Guardian video, and it does take some work for us humans to come up with something that looks random yet nice and original at the same time.

Riley has also done in the past some remarkable pieces on optical illusion and geometry. For those in London, you can see some of her works at the National Gallery until May 2011.

This is a just a preview of the underestimated art of using computers for doing art. Have a look at the Computer Arts Society website for more (historical) examples. I'll post more of my own computer art in the future, though none in the next two weeks because of Christmas vacations.

Thursday, 2 December 2010

Mathematica Bingo

I've just discovered the command Speak, although it was available in Mathematica 7. After the excitement of listening to my computer reciting silly things like the first 100th digits of π, I wondered what I could do with Speak that would be useful. What I came up with is a Bingo machine - sort of useful.

Here’s what the machine looks like:


Download and run the notebook to hear the numbers as you draw them.

The code for this applet is divided into three functions. The first one initializes the set of numbers to draw (all the usual Bingo numbers) and the set of numbers drawn so far (empty set to begin with):


The second one implements a random draw in the set of numbers that remain:


The third function displays in a neat way the drawn and un-drawn numbers:


The remaining bits of code that use these functions to generate the Bingo machine can be found here. Download it and run it in Mathematica or Mathematica Player to listen to your very own Bingo master!

Monday, 29 November 2010

Octave in Snow Leopard

When I opened Octave on my Mac this morning, I realised I wasn't able to plot. Quite worrying. It was working before, so why is it not working now? The problem it turns out is that the upgrade to Snow Leopard (Mac OS 10.6) introduces some problems (64 vs 32 bits stuff apparently). This is mentioned on the Octave-Forge website and more precisely here.

Before you follow the instructions posted on this last website, it's probably a good idea to take some time to upgrade your version of Octave and Gnuplot (included in the Octave distribution).

Update 05/03/2012: I updated Octave to v3.4.0 and found that Gnuplot had the same problem. I followed the fix above but, this time, it didn't work.

What I do now is to resort to the OpenGL/FLTK package, with the line

graphics_toolkit('fltk')

at the Octave prompt.

Saturday, 27 November 2010

What this blog is about

Welcome to Comp Maths Central, my diary of the maths stuff I'm working on while traveling on the Central Line every morning and evening. Two hours on the tube is a lot of free time, especially when the Metro and the Evening Standard have zero content.

I spend my time doing mostly programming and playing with Mathematica, so that's what you're likely to come across here. But from time to time, I'm also working on serious maths results, which I might discuss if I have time.

One post a week - that's my target. Let's see if my schedule can beat that of TFL.

Dabbling in Mathematica 8

I've just updated my version of Mathematica to version 8, and I'm quite impressed. Lots of new commands and features, which I've been trying on two tube journeys so far. Here are a few I find interesting:

Speak["Some text"]

This one is from Mathematica 7 actually, but I had never seen it before. Use it to turn your computer into a slave repeater with something like

N[π,10]//ToString//Speak

Or better yet use it to program a Bingo game (to come).

CurrentImage[]

Get images from your computer camera and do real-time computations on them. Try for example

Dynamic[EdgeDetect[CurrentImage[]]]

Probability is my main subject, so I'm pleased to see that Mathematica has two new commands, Probability and NProbability, for computing the probability of all sorts of events and distributions.

Another function related to probability:

StableDistribution[type,α,β,μ,σ]

Finally. Stable distributions were available as part of an intermediary package called StableDistribution (see also here), but now it's built-in.

Last but not least,

TextRecognize[image]

will convert the text of an image into actual text. It's not full-proof, but it can be useful. Test it on some scanned paper you have and have your computer read it using

TextRecognize[image]//Speak

This is just a teaser of what I'm playing with now. I'll discuss more commands and features (e.g. free form programming) in future posts.