Statue of Aristotle
Aristotle offered some philosophical insight into the difficulty of mastering our impulses. Photograph: Popperfoto/Getty Images Popperfoto/Popperfoto/Getty Images

For the last year or so I've been trying to go to the gym. Compared with previous attempts to adopt a regular gym habit, this latest venture has been relatively successful. Thanks in very large part to an agreement with a friend to act as each other's "gym buddy", we managed to sustain a pattern of attendance averaging two or three times a week for a period of about nine months.

The benefits were very apparent. We grew fitter and stronger; our bodies changed shape; we could run for 40 minutes. What I noticed most though was the improvement in my mood. While I wasn't exactly a couch potato – my dogs ensured that I got up off the sofa for at least a couple of hours a day – a dose of vigorous exercise could transform my whole outlook in 30 minutes. I felt far more positive, more in control, and consequently less stressed. Exercise really seemed to do everything they said it would. And what's more, I enjoyed it. Amazing! And then I stopped going.

The problem with gym buddies is that they're sentient beings. On the plus side this meant that the commitment we felt, our desire not to let each other down, caused us to turn up on many occasions when neither of us would have done so independently. But the problem was that once we did fail to make a session, the next one became that bit easier to miss, and the next one easier still. Soon our commitment had so many cracks, it simply fell apart.

I am regularly amazed (and depressed) by the seemingly insurmountable challenge of getting myself to do things that I want to do, need to do and will, I know, make me feel better. Motivation, self-discipline, willpower; call it what you will, the challenge of, as Shelley put it, "rul[ing] the empire of [one]self", has occupied the greatest minds from Aristotle and Socrates to psychologists such as Abraham Maslow. In some ways, thinking has changed very little since Aristotle, writing in The Nicomachean Ethics, spoke of "akrasia" (literally "lack of mastery"). An akratic person acts against reason because of pathos (emotion). There are two types of akrasia: impetuousness and weakness.

Psychologists today tend to describe this as "affect regulation" and "impulse control", but it amounts to much the same thing. How can we overcome short-term impulses (laziness, the urge for chocolate) in order to achieve far more satisfying and/or important longer-term goals (health and fitness, a completed novel, a debt-free existence or whatever)? Research suggests that a great many factors affect our ability to do this. Alcohol, for example, is widely considered to reduce inhibitions because it acts on the brain's prefrontal cortex, the area responsible for impulse control. Brain injury can have a similar effect, and impulse control disorders are often associated with depression. But even the healthiest, most sober individual must struggle to balance instant gratification and long-term ambition.

Not surprisingly, there is a vast range of literature on the subject, much of it sitting on my bookshelves, purchased on impulse with a click of the mouse, much of it unread. We tend to think of technology, and the internet in particular, as the enemy of self-discipline, the very definition of the instant world. How ironic, then, that what's helped me most is a simple iPhone app. With GymPact I pay a $10 fine (I'm not making this up) for every workout I miss. If I go I get a cash reward, paid from the fines of those who don't. And there's no cheating either, the phone's GPS is used to confirm that I'm there. So far it's working brilliantly; I haven't missed a session. Really, it gives you hope for the human race.