Machines can already write music and beat us at games like chess and Go. But the rise of artificial intelligence should inspire hope as well as fear, says Marcus du Sautoy

As Marcus du Sautoy greets me at the entrance to New College, Oxford, his appearance is a quiet riot of colour. His clothes rather suggest someone who ran into White Stuff or Fat Face and frantically grabbed anything he could find – in this case, a salmon zip-up top, multihued check trousers and shoes that are a headache-inducing shade of turquoise. When we settle down to talk in a nearby meeting room, he repeatedly glances at a notepad – whose pages, just to add to all the garishness, are a bold shade of yellow.

They are full of what look like scrawled equations, mixed with odd-looking shapes: the raw material, he explains, of a project involving very complicated geometry. “There’s an infinite symmetrical structure that I’m looking at,” he says, “and I think the top bit of it will tell me everything that’s going on inside it. It’s almost like an infinite lake, and I should be able to know everything that’s happening in it by looking at the first centimetre.”

He suddenly looks rather pained. “But I don’t know.”

Du Sautoy, 53, is a professor of maths and a fellow of New College. Eleven years ago, Oxford University made him its Simonyi professor for the public understanding of science, a role ideally suited to a prolific author who is a regular presence on the TV. But a lot of his day-to-day life still seems to revolve around the fascinatingly abstract and complex world of pure maths – which, as his current quest suggests, is becoming ever more onerous and complex. Modern mathematicians stand on top of a body of knowledge that stretches back centuries. A great many theorems have been proved; even some of the most complicated fields of research have been fully explored, and closed off. To appreciably extend human understanding often seems to require unfathomable intellectual leaps.

“My PhD students seem to have to spend three years just getting to the point where they understand what’s being asked of them,” he says. Once again, he looks pained. “We seem to be hitting problems that will require so many strands that one mind isn’t going to be able to pull them together.”

Which brings us to a relatively new presence in Du Sautoy’s world: artificial intelligence, and the deployment of huge computing power by mathematicians working at their subject’s cutting edge. This is the starting point for his new book, The Creativity Code, a lucid, endlessly interesting exploration of what AI may mean for maths, the arts and even our understanding of what it is to be human.

Unlike many of the mountain of books about tech, it is an essentially optimistic read, but it begins with a sharp pang of anxiety. “I am going through a very existential crisis,” Du Sautoy writes. “I have found myself wondering, with the onslaught of new developments in AI, if the job of mathematician will still be available to humans in decades to come. Mathematics is a subject of numbers and logic. Isn’t that what computers do best?”

As we sit down to chat, I ask him: does he have a vision of the world to come, possibly involving people like him passively watching machines work on impossibly complex problems, and usually being none the wiser?

He thinks for a few seconds. “I think that could well apply to everything,” he says.

Du Sautoy is an animated, Tiggerish presence, full of enthusiasm for his subject and for most of the stuff we tangentially spin into, from the US indie band Parquet Courts (whom he saw a few years ago at Glastonbury) to the philosophy of René Descartes. We talk for more than two hours; by the end, I have momentarily forgotten that I got a C in my maths O-level, grasped a handful of mathematical concepts and understood the intellectual journey that defines his new book. It is his seventh book, following on from The Great Unknown in 2017, which was about the outer frontiers of science, and dealt with questions that ranged from the nature of dark matter to whether or not the universe is infinite.

As the opening passages of The Creativity Code explain, Du Sautoy had a watershed experience in March 2016, when he watched AlphaGo – a program developed by the AI specialist DeepMind, which is based in London, and owned by Google – play several rounds of the ancient Chinese board game Go against the game’s South Korean champion, Lee Sedol. Unlike orthodox game-playing programs, AlphaGo had used the technique known as deep learning to essentially teach itself how to play the game. The key moment came during the second match, when it suddenly departed from a conventional strategy. Go is played on a 19x19 grid, with the two players competing to capture territory with their black or white counters, known as stones. Human players always spend the early part of the game concentrating on the board’s outer four lines, whereas, on move 37, AlphaGo decided to place a piece on the line five steps from the edge. Some observers thought it had made an awful mistake. But, as it turned out, an apparent flight of computerised fancy was the first inspired step towards AlphaGo winning the game, in an unprecedented way. “It’s not a human move,” said one awed witness. “So beautiful. Beautiful. Beautiful. Beautiful.”

In the past, Du Sautoy had watched computers thrash human beings at chess, but this was different. “Chess was never something that felt threatening if it was done by a computer,” he says. “It gets simpler as you go on; you remove pieces. But Go increases in complexity because the patterns and shapes that appear on the grid get more and more complicated. I watched those games obsessively on YouTube as they were going on. And, with move 37, it was like: ‘Holy shit! Is my world about to be invaded by these learning machines?’”

What he had glimpsed, he says, was a case study in AI leaving behind formulas established by human beings and doing something creative. In Du Sautoy’s field of maths, it held out the prospect of AI moving beyond dull, if complex, number crunching, into the kind of quintessentially human activities that define how the subject works: strategising, discriminating and “making choices about the interesting pathways to take”.

There are already mathematicians, he says, working on the basis that AI will do more and more of this stuff. But he also believes that there are aspects of human intelligence, well suited to maths, that are likely to remain ours alone.

Slackers should take note: the human aversion to hard work, it seems, is often nothing but a good thing. “I think human laziness is a really important part of finding good, new ways to do things,” he says. “I often look at things and think: ‘This is just getting too complicated – let me try to step back and figure out a shortcut.’ A computer will say: ‘Well, I’ve got these tools and I can just bash on, deep into the problem. But because it doesn’t get tired and it’s not going to be lazy, maybe it will miss things that our laziness takes us to. Perhaps that will be our saving grace. That’s an interesting thought: the idea that because we don’t have the ability to storm deep into things, we’re forced to find clever ways to do them.”

Maths is only the start of what his new book examines. Du Sautoy also looks at AI-generated art, and programs that have come up with superficially convincing works based on the techniques of such old masters as Rembrandt (“a horrible, tasteless, insensitive and soulless travesty of all that is creative in human nature”, reckoned Guardian art critic, Jonathan Jones). But perhaps the most interesting stuff he explores is centred on the relationship between technology and music.

Du Sautoy is an orchestral trumpet player, and has just taken up the cello; his musical universe takes in everything from Sibelius to Happy Mondays, whose music he used to blast out of his window when he was a postgraduate at the usually quiet Oxford college All Souls. In the past, he has devoted plenty of attention to music’s mathematic aspects, and the way that it is full of identifiable patterns and numerical relationships; this time, he makes the argument that, in following a finite set of musical options, many musicians behave just as algorithmically as computer software.

Now, cutting-edge AI is being used to seize on this similarity and produce increasingly sophisticated computer-generated music. Some of it, he agrees, is little more than muzak: stuff that imitates a particular band or composer and ends up sounding like “a Xerox of a Xerox of a Xerox”. But other examples of music authored by machines are much more promising. In both cases, he insists, what computers often highlight is that music is much less mystical and magical than some people think.

“Whenever I talk about maths and music, people get very angry because they think I’m trying to take the emotion out of it,” he says. “But when you talk to a composer … well, I once talked to Philip Glass. He said: ‘People respond emotionally to my music, but I don’t put any emotion in there. The emotion comes out afterwards. I’m interested in structure and rules.’ So I think that one of the points of this book is to take a lot of art forms, which everyone believes are something innately human that you’ll never be able to decode, and to show you a lot of these things already have structures that we can identify, hiding underneath them, which is what we’re responding to.”

When I ask him whether he thinks AI will, sooner or later, be able to come up with pieces of music that will amaze and move us just as much as any of the creative achievements pulled off by mere humans – somewhat arbitrarily, I mention the Beatles’ Hey Jude and Stravinsky’s The Rite of Spring – he says his gut feeling is that such feats will soon happen, but that isn’t quite the point.

There is no fundamental reason why at some point in the future we can’t make a machine that is conscious Marcus du Sautoy

The best musical use of AI, he says, is in partnership with human beings – something demonstrated by the Continuator, a device developed by a French AI specialist François Pachet, which can learn from a musician’s basic style and then suggest radical directions to take. In the book, Du Sautoy quotes a jazz pianist called Bernard Lubat, who has got used to playing duets with this new machine: “The system shows me ideas I could have developed, but that it would have taken me years to develop. It is years ahead of me, yet everything it plays is unquestionably me.”

This suggests the musical equivalent of the aforementioned move 37, and Du Sautoy thinks it says something profound about how human beings will interact with AI. “We often behave too like machines. We get stuck. I’m probably stuck in my ways of thinking about mathematical problems. And if AI can see that and say: ‘Well, there are also these possibilities,’ perhaps it can kick us out of behaving like machines – and, weirdly, make us more human again.”

He also believes that machines are likely to become more and more human – outwardly at least. In the book, he says he sees “no fundamental reason why at some point in the future we can’t make a machine that is conscious”.

He mentions the stirrings of self-awareness that happen in humans when they are between 18 months and two years old. “Something happens in the brain of a child where their consciousness shifts and changes,” he says. “And I think that there’s absolutely no reason why a network cannot reach a sufficient degree of complexity that it is able to encode itself and have a sense of self.” A pause. “And I think it would be able to have empathy as well.”

But would it? The reality, surely, would be a series of logical steps that may approximate empathy – but that’s not what empathy is. It’s something almost beyond explanation: a feeling we have towards other human beings and animals – and sometimes, inanimate objects, weirdly enough. How could circuitry and wires get near that?

“Your challenge is exactly right,” he says. “But this is the hard problem of consciousness. We will never be able to know whether empathy is just a matter of appearance, and the same applies to you. The Guardian may have just sent along this incredibly good avatar, and I’m just getting really emotionally excited talking to you. But how do I actually know that something’s going on?

“These things are already better at empathy than we are,” he says. “AI is able to recognise a false smile as opposed to a genuine smile better than a human can. And if we’re worried about a dystopian future, we should want an empathic AI – an AI that understands what it’s like to be human. And, conversely, we need to understand how it’s working – because it’s making decisions about our lives.”

This is one of his arguments for listening to AI-generated music, studying how computers do maths and, even if they are awful travesties, gazing at digitally produced paintings: to understand how advanced machines work at the deepest level, in order to make sure we know everything about the technology that is now built into our lives. It’s also, he says, the best case for reading his book: “We think we’re in control, and at the moment, we’re not. And unless we learn the ways that we’re being pushed and pulled around by algorithms, we’re going to be at their mercy.”

Once that happens, he suggests, perhaps humans and machines can move smoothly into a shared future as bright as his shoes. “There’s actually a lot to be hopeful about,” says Du Sautoy, before he picks up his yellow pad, briefly stares at all those shapes and equations, and prepares to get back to work.

The Creativity Code: How AI Is Learning to Write, Paint and Think by Marcus du Sautoy is published on 7 March by 4th Estate.