The first piece of art that Karen Green made after her husband, David Foster Wallace, took his own life on 12 September 2008, was a forgiveness machine. She is standing in the neat, white studio at her house at Petaluma, north of San Francisco, explaining to me how the machine worked and how it didn't.

"Before David died," she says, "I had been working on some machines, with a five-year old – the son of a friend who had a gallery down the road from mine." There had been a recreating-a-pig-from-bacon machine, and a prototype for a machine that cleverly pitted dates. The day that her husband hanged himself she had been working on a political machine that involved a bright-coloured circus tent, elephants and donkeys. For a long while after that, she says, she couldn't make any art at all, wondered if she ever would again, but eventually, tentatively, she developed the idea for her conciliatory Heath-Robinson. "The forgiveness machine was seven-feet long," she says, "with lots of weird plastic bits and pieces. Heavy as hell." The idea was that you wrote down the thing that you wanted to forgive, or to be forgiven for, and a vacuum sucked your piece of paper in one end. At the other it was shredded, and hey presto.

Green put the machine on display at a gallery in Pasadena near the Los Angeles suburb, Claremont, where she and Wallace had lived in the four years they had been married. She was fascinated by the effect that it had on people who used it. "It was strange," she suggests, "it all looked like fun, but then when the moment came for people to put their message actually in it, they became anxious. It was like: what if it works and I really have to forgive my terrible parent or whoever."

In the end, Green didn't use the machine herself, except to put a few tester messages through. "I couldn't give it my full attention," she explains. "I was worried it wouldn't even work for the full four hours of the show's opening. I was also kind of a mess about surviving the opening itself. Seeing people, chatting. Not 'kind of a mess' – a mess. I couldn't imagine doing it." She thought she would come back to visit the machine after the opening but instead she drove to her new home, not far from where she grew up, and stayed there. The machine was overwhelmed, too; it couldn't process all the requests and was eventually dismantled. "Forgiving is never as easy as we would like," she says. "Apparently quite a lot of people cried."

In her studio, now, Green smiles at that idea, with all the weariness of someone who has lately done far too much crying for one lifetime. She is full of spirited life, continually doing her utmost to laugh, even to attempt bad jokes when she talks about the last two and a half years, in an effort to deflect herself from the alternative. Her eyes tell different stories. "I don't know if David's parents have anger at him," she says. "Maybe because they were dealing with his illness, his depression, for such a very long time. But I have heard from other people who have lost spouses in this way, and fathers and mothers, and anger is perfectly appropriate. You can choose to be angry at the illness rather than the person, of course, but fury is completely appropriate: thus the forgiveness machine."

If the contraption didn't get the chance to work its home-made magic for Green herself, at least it had the effect of getting her back into her studio, where she has been trying to confront, or shore herself up against, what has become the fact of her life, the role she has found herself assigned by the ardent, obsessive readers of her late husband's books. "I think I'm supposed to buck up and be the professional widow," she says, with another quick laugh, "and I have found that very hard. Very hard. I mean one day you are a couple living in a little house and watching The Wire box-set for the third time, and letting the dogs do their antic stuff, and then suddenly you are supposed to be functioning as the great writer's widow. That wasn't how we lived when David was alive. I felt about him like I would if I had been married to a sweet school teacher. So I ignored everything for a long time. Until now, really."

The now is in part an acknowledgement of the fact that next week Wallace's unfinished novel The Pale King will be loudly published across the world. The Pale King was the "big thing" on which he had been working in the last decade of his life (he died at 46). It was planned as the much-anticipated follow-up to Infinite Jest, the teeming 1,000-page bleakly comic masterpiece that had established Wallace, at 34, as the man most likely to redefine the scope and voice of the American novel.

I had come here to California to meet Green after corresponding for a little while by email. We had written mainly about her art, which seemed to me a profound and raw expression of the extremes of grief and loss. Not surprisingly, for a woman who was married to a man widely considered to be the most gifted novelist of his generation – described by Jonathan Franzen as "our strongest rhetorical writer" and by Zadie Smith as having no "equal among living writers. He was an actual genius" – Green has been much concerned with language, and the point where it gives up its ghosts of meaning. "When the person you love kills himself time stops," she says at one point. "It just stops at that moment. Life becomes another code, a language that you don't understand."

Some of her most recent work is on the walls of her studio: watercolour landscapes almost bleached white, over which she has written, in layer upon layer of rice paper, meticulous lines and columns of words. The words come, she says – as I try to decipher them – from love letters and hate letters, imaginary sessions with a psychiatrist, fragments of Wallace's writing and her own diaries, bits of Goethe's The Sorrows of Young Werther, extracts from the dead language of hospital reports; they run into one another and continually cease to make sense. The words overlay the landscapes in which Green now lives, the river at the back of her studio, with its shells of abandoned warehouses, the profile of the favourite beach and headland where she goes alone to swim.

She tends to work on this series of paintings in the early mornings; night time is harder. She has always hunted out old letters from antique markets, little scraps of billets-doux and deeds of sale, faint tracings of forgotten human hope in copperplate, the ink faded to brown and grey. Now, she says, she has "plenty of fodder of my own". On a couple of the paintings she has added little bright splashes of MRI brain scans, the slices of frontal lobe and cerebellum abstracting into ghoulish faces. In the year before Wallace died when, having changed his medication, the depression from which he had suffered since a student returned with full vengeance, Green became an amateur expert on the diagrammatic language of psychiatric records: "That's a depressed person's brain," she says of a little grouping of Technicolor splashes. "It's coded differently."

It's tempting to see all this layering as a painstaking effort on Green's part to understand her husband's death, but it's clear she sees it more as an expression of the absence of meaning that has resulted from it, the wild and whirling words of grief. She resists the idea that suicide is in any sense a meaningful act, still less one understandable in terms of art – the myth of the romantic depressive –as many of the multitude of commentators on Wallace's death, grouping him with Kurt Cobain, have sometimes wanted to see it.

"It was a day in his life," she says, "and it was a day in mine. Problematic for me is that there is a post-traumatic stress that comes from finding someone you love like that, as I did. It's a real thing. A real change to your brain, on a cellular level, apparently. People tell me I should have been prepared, because of David's history with depression. But of course I wasn't prepared at all. I wouldn't have left him alone in the house, ever, if I thought that would happen. I still feel like it was a mistake that was made."

The very public appropriation of the ultimate private act made it less possible for her to cope with it. He was everywhere she looked. She still avoids Google: "What do you do when your husband's autopsy report is on the internet and is deemed a subject worthy of fucking literary criticism?"

The only other time she has talked to a newspaper was at the opening of her last art show when she spoke to a journalist from the New York Times. "I did it on the basis that her story would not include the words "hanging" or "discovered body," she says now. "I'm an idiot, of course they did all that. I know journalism is journalism and maybe people want to read that I discovered the body over and over again, but that doesn't define David or his work. It all turns him into a celebrity writer dude, which I think would have made him wince, the good part of him. It has defined me too, and I'm really struggling with that."

She's talking to me now, she says, in part because she feels something of a duty to support the publication of The Pale King, and in part because she has a sense that talking about her experience might be of help to other people who have been left behind to live with the knock-kneed fact of suicide.

She is not sure about many things concerning the death of her husband but she is certain about one thing, the first thing I ask her: that Wallace wanted The Pale King to be published, even in its unfinished state. "The notes that he took for the book and chapters that were complete, were left in a neat pile on his desk in the garage where he worked. And his lamps were on it, illuminating it. So I have no doubt in my mind this is what he wanted. It was in as organised a state as David ever left anything."

In the immediate shock of grief, Green and Wallace's long-time agent, Bonnie Nadell, went through what else he had written that seemed to fit with the manuscript. All this – hard drives, files, notebooks, floppy disks – were also handed over to Michael Pietsch, the novelist's friend and editor, at the American publisher Little, Brown who took it away in a duffel bag and two bulging sacks. "I know he wanted Michael to edit it," Green says. "And if you had seen those other pages, then the presence of the book in the world is sort of a miracle. Not all of them were typed. Michael came and got it all very early on and I totally trusted him. When I gave it to him I just said to him: 'Have a nice divorce.'"

Green had only read the book, as I had, the week before we met. She had tried before but only got to page two, and had found it so unnerving that she had been unable to leave the house for three days. This time around she went through it in a couple of days almost without a pause. "It was actually fun to feel him around the place again, in my head. And of course it was sad because I wondered where it would have gone."

The theme of The Pale King is boredom and the ways in which a group of young Americans mitigate its effects to get through their working life (Wallace was never a writer to duck a challenge). Most of it is set in the offices of the Internal Revenue Service at Peoria in Illinois. "Maybe dullness is associated with psychic pain," Wallace wrote at one point, "because something that's dull or opaque fails to provide enough stimulation to distract people from some other, deeper type of pain that is always there, if only in an ambient low-level way, and which most of us spend nearly all our time and energy trying to distract ourselves from."

Most of the book is written in the highly charged, wildly discursive register that Wallace had established as his own: one in which no detail of experience goes unexamined, in which brilliant observation, and comic aside, and satirical nuance and existential theorising tumble over each other for the reader's attention all the time. In its unfinished state the book resists – even in comparison to the author's earlier fiction – anything much in the way of narrative. Some of its totally immersive parts are far greater than the whole. Occasionally those parts, a long section, for example on the embarrassments caused by the inopportune sweating of one character (a condition that plagued the headscarf-wearing author), Wallace seems to step out from his shapeshifting voice and to be writing fully autobiographically, making direct eye-contact with the reader. In these sections the book is as alive and affecting as anything Wallace wrote.

He hadn't shared all of his plans for the book with Green, though she had seen bits of it, talked to him about it. Knowing its substance, and the fact that he started it before they met, she had wondered if it might have dwelt on the changes their relationship had brought to his life, but she did not find that in the book. "I'd have been interested to hear what he might have done with the idea of boredom in marriage, though," she says, with a smile. "He was really getting the hang of the marriage thing, after four years. He would say: 'I remembered to put the water on for your tea when I knew you were coming home', stuff like that. Having been quite feral, he was proud of his domestication."

The standard criticism of Wallace's work is that for all its peerless pyrotechnics, it lacked heart. It was writing for young men too clever for their own good, by a youngish man way, way too clever for his. Like all caricatures this one is unjust – no one could have accused Wallace's writing of not being intimately concerned, second by second, with a human pulse – but it contains a pinch of truth. When I ask Green if she felt the best of him always made its way into his writing, she thinks for a moment. She is sitting cross-legged in a favourite chair, cradling a mug of herbal tea.

"I guess it depends how you define best," she says eventually. "But in my opinion, no. The writer's voice took on a life of its own, which I think he found very constraining. I think part of what he was struggling with was how to change that voice. Cleverness, particularly for someone as clever as David, is the hardest thing to give up. It's like being naked, or getting married as opposed to having one-night stands. People don't want to be thought of as sentimental. Writers don't anyway."

Green and Wallace used to have a long-running jokey argument along these lines, about whether Wallace should allow his "inner sap" into his prose. "I thought the inner sap should be allowed out sometimes," she recalls. "It was quite a wonderful thing. I'd argue that sometimes when a piece of writing, or a piece of artwork is too clever it loses that ability to connect. David was obviously trying some of that, and it's those bits of the book I loved the most. But I'm a sap. I should have learned better than that by now."

It was her art that first brought Karen Green into contact with David Foster Wallace, their first interaction setting the tone for what followed. She wanted to rewrite him, to give him the potential for happy endings.

"I came across his book Brief Interviews with Hideous Men in a thrift store for a dollar," she recalls. "At the time I was doing these art pieces in which I'd take someone's text and chop it up in panels and make it something else, change the story using their words. I read David's story "The Depressed Person" in that book and I thought, my God! And I wanted to make one of these pieces out of it."

Wallace had first been hospitalised with depression while a student of English and philosophy at Amherst College; his first published story, "The Planet Trillaphon as It Stands in Relation to the Bad Thing", written for the Amherst magazine was, like much of his later work, a several-steps-removed account of his own relationship with depressive illness. Trillaphon was a name for an antidepressant, the bad thing was the mostly indescribable interior sense of being constantly underwater with no surface, or of "every cell in your body being sick to its stomach". "The Depressed Person", which Wallace wrote for Harper's magazine in 1998, was an even more claustrophobic development of that idea, told from inside the head of an unnamed young woman, who is kept going day to day by a support system of friends who she knows cannot bear her phone calls. Green was struck by a powerful need to redeem the fiction in some way, to allow the depressed person to breathe. She faxed Wallace to see if he would mind. He faxed back saying he didn't, at the same time correcting her grammar.

When she had finished the piece Green took it to show him in LA. "He liked being edited in this way by some stranger, I think," she says. "He was very lovely about it, I mean I'd really haiku'd the hell out of that thing. It was recast in teeth shapes, 32 teeth on a grid. I'd really struggled. There was nothing happy in that story; there was nothing you could turn around and make into something beautiful."

How did she end it?

"I can't remember the last line exactly," she says, "but I believe it was something like: 'And then she felt like laughing and fucking…'" She laughs. "That was honestly the best I could do…" After that, she says, "we were friendly for a while, and then we got really friendly."

She knew it was love when Wallace agreed to go to Hawaii with her early in their relationship. Hawaii represented two of many phobias: air travel, and the possibility of swimming with sharks. While Green was in the ocean, Wallace would routinely stand on the shore, yelling anecdotal statistics about shark attacks at her. In 2004, Wallace and Green were married in Urbana, Illinois, his home town, in front of his parents, and her grown-up son from a previous marriage. Wallace had by then accepted a creative writing teaching appointment, at Pomona College, in Claremont, California. They chose a ranch house nearby and moved in.

For a long while Green seemed to have had a comparable effect on Wallace as she had on the depressed person in his story. In July, 2005, he wrote an email to his friend Jonathan Franzen, which was about as close as he ever came to owning up to contentment: "Karen is killing herself rehabbing the house. I sit in the garage with the AC blasting and work very poorly and haltingly and with (some days) great reluctance and ambivalence and pain. I am tired of myself, it seems: tired of my thoughts, associations, syntax, various verbal habits that have gone from discovery to technique to tic. It's a dark time workwise, and yet a very light and lovely time in all other respects. So overall I feel I'm ahead and am pretty happy."

Franzen was one of very few literary figures with whom Wallace kept in touch. They had both been beset by similar doubts about their work, and about the future of the American novel, which they had attempted to resolve in different ways; Franzen committing himself to "old-fashioned" storytelling in The Corrections, Wallace persisting with his sense that fiction had to be frenetically alive to the way "experience seemed to barrage me with input".

Green recalls their rivalry with a smile. "They were really great together, you know like two kids in the back seat of the car, squabbling, it was really delightful to see them together. Jon has lost that neck-and-neck competitor, his soccer-field pal."

In one corner of the room where we are talking is a beautiful guitar given to Green by Franzen, which she is learning to play: Leonard Cohen and Rufus Wainwright. "Jon was one of David's very, very few writing friends," she says. "He was sort of like a god to David and I think Jon maybe felt something the same about David. And he has been an incredible friend to me since it happened. He feels like a brother."

One of the things that Wallace occasionally emailed to his friend was his fantasy of giving up on writing. He talked with Green too, often, about the possibility of not doing the novel; not sitting in his air-conditioned garage labouring at "the big thing". He was very attached to his two dogs; some days he wondered if he should open a dog sanctuary instead. Most of all, it seems, he wanted to stop the endless process of qualification and revision and analysis that his mind was at work at, and which found expression in his books.

"He talked about it a lot," Green recalls. "I think he had certainly lost a lot of joy. He had a good relationship with his students at Pomona, he liked that. But there is that place you can get to when you are writing or making some art, which is a perfectly human place. A connected place. With David's brain and the way it was wired and the way it worked, it was very hard for him to access that place. He had so many Jiminy Crickets on his shoulders. Sometimes a quick deadline helped. He wrote a piece about Roger Federer [for the New York Times] which he really enjoyed doing, but that was rare for him."

Wallace often seemed so desperate to protect himself from the world, I wonder if he'd experienced death or loss close up at any point?

Green shakes her head: "No – his grandfather, his aunt – but no. He couldn't bear the idea of the dogs dying. And he used to say to me all the time, at night: 'Don't die.'" She pauses for a long time. "That's a hard thing to think about," she says. "It is hard to remember tender things tenderly."

At the back of the house where Green now lives there is a river, which is bordered by old farming and industrial machinery and sheds. Petaluma used to be the egg-producing capital of California. We walk along there and she points out some of the places that she has painted in her watercolours. She talks about her son, a ballet dancer, who recently got married, and about her work, the things that have kept her going. She wasn't sure why she ended up here, after it happened, but she needed to get away from Claremont. She has slowly made friends, one of whom owns the restaurant where we go to eat, and where she explains how things began to unravel for Wallace.

By 2007 he had been on the same medication, Nardil, for 20 years. He believed the pills were starting to have bad side-effects; he was finding it hard to eat, but also he believed that the drug might be getting in the way of his writing. On the advice of a doctor, he stopped taking Nardil. He quickly became very unstable. "He was scared out of his mind," Green recalls. "There was a healthy person in there who wanted to come off the meds. There was a perfectionist who wanted to be a good husband. And there was a sick person that wanted to see how much he could rock the boat."

Looking back now, she says, she can line up all the mistakes of that period, but at the time every decision that was made was an effort to get Wallace well. Different drugs did not work. Nardil, when he returned to it, seemed to have lost its effect. In desperation he turned to electroconvulsive shock treatment, which had helped him through some of the worst of his illness in his early 20s.

Green was with him all the time through the months of treatment, on one occasion not leaving the house for nine days. "It was terrible," she recalls. "I think he was so panicked that it was not working that it was self-defeating in a way."

One of the bleaker ironies, she suggests, is that she now knows exactly how that panic feels. "I have these visual cues where it all comes back to me, and if there is any way you can make that stop then you will do. If it means bashing your head against the wall, or whatever. The fear that you won't get out of it is worse than the thing itself. I think that is where he was that afternoon. He couldn't see a way to be."

One of Green's many fears for the publication of The Pale King is that it will be read as an extended suicide note, as an explanation for the ending that Wallace gave himself. At one point in our conversation I wonder if she thought that the illness and the writing came out of the same place, that you couldn't have had one without the other?

"I don't think that is the case," she says, though she gets the emails from readers who want to believe this stubborn myth of the tormented genius, want the pain to be a prerequisite for the creativity, want to turn Wallace into some literary James Dean. "People don't understand how ill he was. It was a monster that just ate him up. And at that point everything was secondary to the illness. Not just writing. Everything else: food, love, shelter…"

Wallace once said, in a quote often employed in the obituaries, that he would attempt to "communicate what it felt to be human or he would die trying". Is writing, art, ever worth more than life? From this close up of course it never is. The following day I email Green a couple of questions to clarify some things she had said. She emails back quickly, from her studio, where she is back at work on her intricate paintings, and with what I imagine she would like to believe was her last word on the subject: "David's work is extraordinary and cause for celebration, but not from me. Does his death make it more poignant? Yes. Do I think, if he had lived, he could have made it as poignant as he saw fit? I do. Which is why I can't 'celebrate' it…"

And then her email closes with a reminder of their first meeting, the hope of other fates. "You know, I still," she suggests, "have a different ending (for him, for me): it's the one where he controls his own damn poignancy, and also kisses me goodnight…"