Reader, I read the wrong books ... Amanda Drew as Emma and Simon Thorp as Rodolphe in Oxford Playhouse's 2003 production of Madame Bovary. Photograph: PR

Reading Madame Bovary for the first time was one of the most terrifying experiences of my life - at least up to that point. I was a very young woman - not even eighteen. I was au pair in the French provinces in the 1950s, and I read Madame Bovary in French, sitting in the furrow of a vineyard. I was like Emma Rouault before she became Madame Bovary, someone whose most intense life was in books, from which I had formed vague images of passion and adventure, love and weddings, marriage and children. I was afraid of being trapped in a house and a kitchen.

Madame Bovary opened a vision of meaninglessness and emptiness, which was all the more appalling because it was so full of things, clothes and furniture, rooms and gardens. The worst thing of all was that it was the books that were the most insidious poison. Recently Madame Bovary appeared in a British newspaper listing of the 'fifty best romantic reads.' It was, and is, the least romantic book I have ever read. If I have come to love it , it is because now I am half a century older, and not trapped in a house and kitchen, I can equably sympathise with the central person in the book, who is its author - endlessly inventive, observant, and full of life.

Madame Bovary was published in 1856-7 and is at the centre of any discussion of the European realistic novel of bourgeois life - especially provincial life. The nineteenth-century novel, however much it criticises the bourgeoisie, is a bourgeois form that grew up with the prosperous middle classes who had time for reading, and were interested in precise discriminations of social relations and moral and immoral behaviour. It comes after the chivalric epic with its codes of honour and courtly love, and after the religious epic, Paradise Lost, the Divine Comedy, religious dramas of the nature of the human soul in the mythic cosmology. The dense social novel flourished in countries with large cities - London, Paris, St Petersburg, Moscow - in which populations were in a state of rapid change - and provincial societies in which old orders and hierarchies and habits persisted and change was slower. The novel was interested in the structures of societies - from money to education, from religious habits to kinship and marriages, from ambition to failure. Fairy tale images, the hopes of princesses and kitchenmaids, of youngest sons and poor old women, are contained in but also corrected by the realist novel. Fairy stories end with the lovers marrying and living happy ever after. Jane Austen's novels keep that pattern. The great realist novels study at length what happens after marriage, within marriages, within families and businesses. One of the great subjects of the realist novel is boredom - narrow experiences in small places and unsympathetic groups. There is no greater study of boredom than Madame Bovary - which is nevertheless never boring, but always both terrifying and simultaneously gleeful over its own accuracy.

Madame Bovary is also at the centre of any discussion of literary descriptions of adultery. Denis de Rougemont, in his book, Love in the Western World, observed that 'to judge by literature, adultery would seem to be one of the most remarkable occupations in both Europe and America'. He discussed the great lovers of mediaeval Romance - Lancelot and Guinevere, Tristan and Iseult - and pointed out that the difficulty and unlawfulness of their love is part of the essence of their passion. Marriage is so to speak the social and normal framework of the human story - adultery is the great act of individual self-assertion and longing. In terms of mediaeval Romance which takes place in a world of dynastic marriages and chivalric devotion, such transgressions are doomed and glorious. In terms of bourgeois monogamous society they are different. Engels believed that 'individual sex love' is a recent concern in human societies, and in our modern capitalist monogamous world is more difficult for women than for men - for men are not condemned and ostracised for promiscuity as women are. Anna Karenina and the heroines of Henry James and Edith Wharton suffer for their desires; their souls are battlefields between good and evil, their fates are tragic. The outward events of Emma Bovary's life are a petit bourgeois version of the doom of Anna Karenina - with important differences. Both heroines have sexually unappealing husbands, and lives that leave them dissatisfied. Both take lovers and both, in their ways, are betrayed or let down by their lovers. Both are sensual and vulnerable and both commit suicide. It might even be said that both are physically attractive to the men who invented and trapped them in their stories, and that both are punished by their authors, as well as by society. Anna Karenina is tragic almost despite Tolstoy. But if Emma Bovary - who is small-minded and confused and selfish - is tragic, it is not in a romantic way, and not because her readers share her feelings or sympathise with her. Our sympathy for her is like our sympathy for a bird the cat has brought in and maimed. It flutters, and it will die.

When Emma Rouault marries Charles Bovary - the fairy tale happy ending - she becomes the third Madame Bovary in the book, after her living mother-in-law and Charles Bovary's dead first wife, whose decaying wedding bouquet she finds in her drawer. Her name, and the title of the novel, define her as a person who is expected to behave in certain ways, fitting her station and function. She loses what individual identity she had. She herself has had vague conventional expectations of marriage, and Flaubert wonderfully describes her sexual disappointment, her reluctance to let go of the idea that she is experiencing post-wedding bliss. He also describes her fairytale, women's magazine attempts to make her house and clothes conform to an idea she has of decorum and elegance. What makes it impossible for her to inhabit her house or her marriage is her romantic sense that there is something more, some more intense experience, some wider horizon if she could only find it. Her desires are formed by her reading and her education.

In the convent where she was educated her dreamy spiritual ecstasies are succeeded by dreamy visions of happiness derived from novels, good and bad. She is like that other archetypal reading hero, Don Quixote, in that her reading habits corrupt her vision of the world and her conduct of her life. They are both Romantics. Don Quixote desires to make provincial La Mancha into a battlefield of giants, demons and ladies in distress. Emma Bovary desires to be happy in lovely clothes in swift carriages, dancing at balls, being admired. The psychoanalyst, Ignès Sodré, wrote an illuminating paper on Madame Bovary, entitled 'Death by Daydreaming' in which she used Freud's essay on 'Creative Writers and Daydreaming' to discuss the particular daydreams of Emma Bovary. According to Freud, daydreams are related to children's play, in which the toys and objects they arrange are, like 'castles in the air', symbols of what they desire in their lives. Freud's interest in this essay is not, he explicitly says, in the great authors of epics and tragedies whose material springs from the myths and history of their world. He is interested precisely in the writers of consoling fantasy tales, minor fictions in which the reader can bathe in narcissistic fantasies of being perfectly brave and beautiful, beloved and successful. Folk tales, Freud says, are the daydreams of a culture.

In 1856 George Eliot wrote one of the funniest critical essays of her time on 'Silly Novels by Lady Novelists'. In her mock accounts of the heroines of what she calls the 'mind-and-millinery' novel she describes its heroine as surrounded by men who 'play a very subordinate part by her side.' 'Ostensibly the final cause of their existence is that they may accompany the heroine on her 'starring' expedition through life. They see her at a ball and are dazzled; at a flower-show, and they are fascinated; on a riding-excursion and they are witched by her noble horsemanship; at church and they are awed by the sweet solemnity of her demeanour. She is the ideal woman in feelings faculties and flounces.' Emma's daydreams derive from this pattern. In fact her lovers tire of her and desert her, and it is she who is subordinate.

Freud also makes the point that the hero or heroine of the daydream is in a narcissistic solitary world. Emma Bovary's romantic desires are little scenes in which she plays the heroine. She prefers to dream about her first lover, Léon, rather than to see him. Her moment of ecstasy after she has been seduced by Rodolphe is when she is able to tell herself in a mirror, 'J'ai un amant. J'ai un amant.' When she decides to set out on the fatal riding expedition with him, it is not desire, let alone love, which propels her - it is Charles Bovary's promise of a riding habit, an 'amazone'. 'L'amazone la décida.' She is, as other writers have pointed out, not only a romantic reader, but a bad reader. Flaubert is very precise about the lethal vagueness of her fantasies, as they sap the reality from her world, and simultaneously lay her open to the financial depredations of Lheureux, who sells her the concrete toys - the riding whip and cigar-case - to act out her daydreams. And to destroy the lives of her husband and child.

It is not a nice story. So why is it one of the greatest novels of all time? To answer that, it is necessary to look at the history of its writing, and Flaubert's ideas about what he was trying to achieve.

Flaubert was born in 1821 in Rouen, where his father was the chief surgeon at the Hôtel-Dieu hospital. His father hoped that Gustave would also be a doctor but the son seems always to have known that he wanted to write. He lived most of his life in Normandy, though he travelled often to Paris and in 1851 travelled with his friend Maxime du Camp in Egypt, the Near East and the Mediterranean. He contracted syphilis on this journey, and was also subject to severe epileptic fits. He never married, and lived close to his mother. He had a long, unsatisfactory affair with Louise Colet, eleven years older than he was, and also a writer, who saved his splendid letters. He had himself a Romantic interest in the distant and strange, both in space and in time. In 1849 Flaubert finished writing La Tentation de Saint Antoine, inspired by a painting by Brueghel he had seen in Genoa in 1845, which depicted the ascetic saint in the desert beset by demons and fleshly temptations. He did a great deal of research on fourth century beliefs, pagan, Christian and heretical, and staged his tale as an exotic drama of ideas. In 1849, just before setting out for Egypt with Du Camp, he spent - according to Du Camp - thirty-two hours reading the text aloud to him and his other great friend Louis Bouilhet. Also according to Du Camp, Bouilhet, when Flaubert finally demanded his opinion of the work, said 'I think you should throw it into the fire and never speak of it again.' Flaubert was understandably distressed by this response. In 1851 he abandoned various other romantic and exotic projects - Une Nuit de Don Juan, Anubis - and embarked on his novel of provincial life. The immediate inspiration for the plot was the death of a local doctor in Normandy, Eugène Delamare, whose second wife, Delphine, had caused scandal by taking lovers and running up huge debts. But already at the age of sixteen Flaubert had written a tale based on a news story in the Rouen newspapers. He called it Passion et Vertu. Its central character is a woman who poisons her husband and children in order to join her lover in America, and commits suicide when the lover rejects her. Flaubert gave his murderess and suicide romantic tastes as motivation, whereas the original woman seems to have been driven more by money and a desire to evade trial and execution.

Flaubert's published letters - especially those to Louise Colet about the writing of Madame Bovary - are some of the most fascinating accounts of the writing process that exist. He tells her he is 'two distinct persons: one who is infatuated with bombast, lyricism, eagle flights, sonorities of phrase and lofty ideas; and another who digs and burrows into the truth as deeply as he can, who likes to treat a humble fact as respectfully as a big one, who would like to make you feel almost physically the things he reproduces.' And early in the writing of the novel he says 'The entire value of my book, if it has any, will consist of my having known how to walk straight ahead on a hair, balanced above the two abysses of lyricism and vulgarity (which I want to fuse in a narrative analysis.) When I think of what it can be, I am dazzled.' He wrote also that his new novel would be 'a book about nothing, a book dependent on nothing external, which would be held together by the external strength of its style, just as the earth, suspended in the void, depends on nothing external for its support; a book which would have no subject, or at least in which the subject would be almost invisible, if such a thing is possible.' He was both excited and exhausted by the difficulty of the enterprise - Bovary, he told Louise in July 1852, 'will have been an unprecedented tour de force (a fact of which I alone shall ever be aware): its subject, characters, effects etc. - are all alien to me. Writing this book I am like a man playing the piano with lead balls attached to his knuckles.'

The supreme importance of style is something to which he returns again and again. He believed he lived in a time when it was not possible to create great types, like Don Quixote or the characters of Shakespeare who 'was not a man, he was a continent; he contained whole crowds of men, entire landscapes. Writers like him do not worry about style: they are powerful in spite of all their faults and because of them. When it comes to us, the little men, our value depends on finished execution.' Flaubert himself is famous for the struggle with every sentence, for the length of time it took him to orchestrate and finish a scene. His style, he wrote, should be 'lisse comme un marbre et furieux comme un tigre' 'chaud en dessous et splendide à la surface.' Prose, he said, should be stuffed with things 'et sans qu'on les aperçoive.'

The prose of Madame Bovary depends for many of its most startling effects on its accurate rendering of things. Flaubert told Louise that he wanted to make his reader feel his world 'almost physically' and the emotion and feeling of the novel are embedded in things, from Charles's uncouth cap in the first chapter, to Emma's delicate presentation of her meals, to her presents to Rodolphe.

This is an image of Emma making herself an image of domestic finesse and elegance, slightly absurdly beyond the limitations of her, and Charles's social situation. Her whole world is imbued with her sensations - we experience her most intensely through them, because she does not think clearly or well in abstract language, but only with images. Occasionally Flaubert's choice of comparison carries with it a lyric charge. Here is his description of Emma's vision of her garden in winter, when she has become bored and disillusioned. She is seeing a winter world through windows heavily frosted, whose whitish light remained unvaried throughout the day. She goes into the garden