A mathematical model of pattern formation