On the other side of his bed is a personal computer ("the stuff any hacker might use") that ties in through telephone lines to $20 million supercomputers in suburban New York and Minnesota.

It was often from this bed, usually until 3 and 4 a.m., that Gregory Chudnovsky worked on a project that consumed him and his brother David for nearly a year: computing pi to one billion digits.

That's 3.14159265358214808651 . . . and on and on and on - 1,200 miles, to Lawrence, Kan., if written out in digits the size of this type.

Gregory's wife, Chris, was often an unwilling participant in the project. ''I got woken up a number of times," she says, "by beeps and" - when the system crashed - "things I can't repeat."

Gregory, 36, and David, 41, both mathematics researchers at Columbia University, just a few weeks ago completed their record-shattering work.

Why? you might ask. Why bother?

Simply defined, pi is the ratio of a circle's circumference to its diameter. But attempts to solve it have produced an infinite string of random numbers, with no apparent pattern. Trying to calculate its exact value has challenged mathematicians from the Egyptians and Babylonians to Archimedes and Newton.

For all its mystery, pi is a building block of math and science, indispensable to everything from simple geometry to modern astronomy to Einstein's particle theory.

"Another value of pi," says David, "would mean a totally different universe."

"But of course," counters his brother, "pi is pi."

Reaching one billion digits has little practical value. "A sideshow," as one scientist put it. What mattered was how the Chudnovskys reached it. They

devised new formulas and new methods for multiplying immense numbers, formulas with applications in fields as diverse as oil exploration, weather forecasting and intelligence coding.

A WORKOUT FOR A COMPUTER

The Chudnovskys' calculation of pi also gave the world's most advanced computers an intense, exhausting workout. What the brothers did to supercomputers is reminiscent of old movies in which a mad professor so confounds a poor computer that it begins to shake, sirens wail and steam pours out.

"Calculating a billion digits of pi," says David, "is really the ultimate stress test - a cardiogram for a computer."

Most of all, though, the Chudnovsky brothers tackled pi because they love mathematics. They love the challenge - to borrow from Star Trek - of taking math where it has never been before.

"There is a principle that beautiful math produces beautiful formulas and beautiful equations," says David. "Math reflects the beauty of the world."

William Gosper, a California computer specialist who once held the pi record himself, at a mere 17.5 million digits, first met the brothers in 1984, at a conference at New York University. He was giving a presentation on hypergeometric functions. "I had showed some formulas that I thought might be of general interest," he recalled, "and then to show off how powerful my techniques were, I showed the group a totally weird batch of identities, some stuff from Mars, really.

'JUMPING UP AND DOWN'

"Instead of being freaked out, the Chudnovskys started jumping up and down, literally, and said this is totally relevant to their work in transcendental number theory. They proceeded to hand me a paper they had done, and I couldn't understand a thing."

Added Gosper: "I don't understand most of what they do. Well, nobody does. . . . It's tremendously hard to keep up with them."

A Japanese computer scientist, by the way, is trying. Earlier this summer, using two more powerful computers but an inferior set of equations, Yasumasa Kanada computed pi to a half-billion digits. He had sole use of new supercomputers at the University of Tokyo for eight days and nights.

The Chudnovskys had to scrap for time, competing with commercial users all over the country.

"Fourth of July weekend was a great time," says Gregory. "And we had the greatest possible time just on the New Year Eve."

"Yes!" echoed David. "We had the machine virtually all to ourselves."

*

The Chudnovsky brothers arrived in New York 11 years ago with their parents. All four were Soviet Jews who had lost their teaching positions when they applied to emigrate. David worked at the Ukrainian Academy of Sciences, Gregory at Kiev State University. Both mother and father were engineering professors.

At a time when refuseniks were routinely punished, "their mother had her arm broken and collarbone broken," said Richard Askey, a friend and mathematics professor at the University of Wisconsin. "David was hit on the head and knocked unconscious by the KGB." The family was denied needed medical attention - especially important for Gregory, who suffers from the debilitating muscle disease myasthenia gravis, which is part of the reason he spends so much time in bed.

After more than two years of intense pressure from the Western math and science community, the family was allowed to leave the Soviet Union. They came to New York, moving into the same apartment near Columbia University where Gregory, his wife and mother, Malka, 78, now live.

Their father, Volf, died a few years ago. He wanted them to become engineers, to build bridges.

"Our father wanted us to build real things," says Gregory. "I mean real things."

"Things we build you can see only on the screen," says David. "You cannot touch."

In conversation, the brothers repeatedly finish each other's thoughts. Likewise in math. "It's not worthwhile to try and separate them into two," says Herbert Robbins, professor emeritus at Columbia and a longtime friend.

Both Chudnovsky brothers are warm, generous and funny. Gregory balances the family checkbook in his head, yet, according to his wife, cannot remember his wedding anniversary.

And, you might wonder, how many digits of pi can each brother recite from memory?

Both consider such a question foolish. After all, over on the coffee table they have a computer printout as thick as a telephone book. "This is peanuts," Gregory says, "a couple million digits."

When pushed, he says, "I remember the basic 10." He then counts to

himself, and changes his answer. "Eleven! I remember 11."

David is more pessimistic. "I probably don't even remember 10," he says. He starts counting under his breath in what sounds like Russian. A few seconds later, he says with no particular relish, "Eight. I can remember eight."

David, whose wife works at the United Nations, lives a few blocks away now. He is rounder than his younger brother, who is frail and thin and must use a cane because of his disease. Gregory met his wife when she headed a student committee at Columbia on Soviet Jewry. "I don't understand much of this," Chris says of his work. "I know how to add and subtract, multiply and divide. . . . I'm a lawyer."

Gregory has thick dark hair with traces of gray ("from the pi project," he says) and a long beard.

"It's as though Dostoevsky had created Gregory," said Robbins. "He's right out of the 19th-century Russian novel. He's got this burning purity of intellect, and he's completely cultured. He knows everything that's going on, and from his bed. This is pure intellect. There's nothing like it in the world."

Gregory, with the help of David, has moved to the living room, where a visitor is seated on a folding chair, between two sets of computers, both with multicolored screens that are racing through complicated geometric patterns.

On one machine, the brothers have set in motion a complex computer simulation they are designing known as "Galaxy in a Box." Working with an astrophysicist on a new, wildly powerful supercomputer being tested by IBM, they are trying to simulate the evolution of stars within a galaxy.

Doing it in real life just takes too long.

The computer screen looks like a view of deep space, with what appear to be millions of tiny stars. Somewhat like a radarscope, a line sweeps across the screen every few seconds, and the image changes slightly.

"Each sweep is another 10 million years," says David. "We can cover about two billion years in an hour."

"The only way you can do it," says David, "is actually play your own God."

Gregory then presses a few keys and his galaxy vanishes. On the screen appear groups of numbers. He and his brother have begun to analyze their billion digits of pi, to search for an elusive pattern that may not even exist.

In the first million digits - what they refer to as "a slice of pi" - they have found 99,959 zeroes; in the last million digits, 99,347 zeroes. They found 99,750 ones in the first million; 100,250 ones in the last million. And so on.

IS PI 'NORMAL'?

"One of the things we want to know," says Gregory, "is whether pi is 'normal.' Can you prove, for example, that all the digits appear in the expansion of pi with equal frequency? That's normal. We don't know this. We need more data, more digits."

The Chudnovskys' formula allows them to begin the pi calculation at any point - "to grow the tail," says David - without having to start from the beginning. This means several computers could work on the problem at once.

In fact, they hope to start a "pi chain letter" to rack up billions of digits.

"We need at least 10 billion," says Gregory.

"Just to get a rough estimate," says David.

The conversation races higher through the mathematical stratosphere.

"Pi should not be really random for a very simple reason: the fact that you can compute it," Gregory is explaining. "You see, if pi would really be absolutely random, no system whatsoever would be able to calculate it. So it's not random in the highest philosophical sense."

Thankfully, dinner is served.

Malka Chudnovsky, a small woman who understands but speaks little English, has prepared dinner. She has devoted the late years of her life to helping her sons, but even she can tire of their mathematical obsessions. "Our mother once said that she would gladly change two mathematicians for two football players," David recalls. "Less trouble."

Dinner is schnitzel, kasha, lentil pilaf and chicken soup, with dark bread and a mushroom salad. "This is a good Jewish house, I'm sorry," says David. ''And nobody leaves here without being well-fed." Or without a book - in this case, a collection by the French poet Arthur Rimbaud.

WORN OUT

It is late, and the brothers are tired. Soon they will go to bed. A year on the pi project has worn them out. The Chudnovskys know that the pi race will continue, that their Japanese counterpart will top them eventually. But they are bowing out for a while.

Because their calculations also wear out computers, they have had to nurse the machines along, all the time worrying about storage space or a computer crash. "We need half a gigabyte just for storage!" says Gregory. And they must always worry about errors. With so many digits to compute, errors are bound to happen. Their system has a self-checking component, but constant vigilance is required.

Then, too, there are cosmic particles to deal with.

"Even if you keep your computer 20 miles under the surface, you cannot keep them out," says David. "They pass through everything. The computer is a physical design. Anything that is physical can fail. And a single wrong bit, a speck of dust in the wrong place, a 4 changes to a 3 and you are dead."

As the evening winds down, and dinner ends, the brothers are asked if they realize that 99.99 percent of New Yorkers probably have no concept of what they do.

"But that's fine," laughs Gregory. "Neither can we understand what 99.99 percent of people in New York are doing. Is that so unusual?"