1

Making An Algorithm An Algorithm—BBP

 3 years ago
source link: https://rjlipton.wpcomstaging.com/2010/07/14/making-an-algorithm-an-algorithm-bbp/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Making An Algorithm An Algorithm—BBP

July 14, 2010

Finding the bits of \pi in logspace

Chee Yap is one of the top experts in various aspects of computational geometry. He has worked on problems as diverse as upper and lower bounds for comparison problems, to algorithms in geometric complexity, to methods to control rounding errors in geometric computations. One of his specialties is in the area of numerical computation from a complexity viewpoint. He was a Ph.D. student of mine many years ago, so I may be biased in the following discussion.

Today I want to talk about a recent paper of Chee on a question I raised earlier here. He has solved the problem and I am quite happy to see that these discussions have helped raise some open problems that are getting solved.

The LEDA project was started by Kurt Mehlhorn years ago to implement geometric algorithms and data structures. It has grown into a major software system that is used by many in research, in education, and in companies.

Kurt told me he almost immediately ran into a serious problem with their first implementation project, which was to implement an algorithm for finding the convex hull in two dimensions. This algorithm takes any set of {n} points in the plane and finds their bounding convex hull in time {O(n \log n)}. The algorithm is due to Ron Graham and is really a type of sorting algorithm. Kurt’s group tested the algorithm on some examples. It worked, and they moved on to more complex algorithms.

Shortly after someone used their algorithm as a subroutine in a more complex computation—let’s call it C. They quickly noticed that C did not always work; sometimes it gave the right answer, but sometimes it did not.

What was going on? Kurt’s group looked into the problem and discovered an issue with their implementation of the convex hull: sometimes the “convex hull” returned was not convex. This is of course impossible—the hull by definition is convex. This meant that their implementation was incorrect. They quickly discovered the problem: certain examples caused the implementation of the algorithm to round incorrectly. Graham’s algorithm was fine, but it assumed infinite precision. They redesigned the implementation and fixed the bug. Now C worked fine.

Kurt said that this accuracy problem became a major issue for the whole LEDA project. They have to be sure that their implementations work given they only have finite precision. They use a variety of tricks: sometimes they use high precision, sometimes they check the answers, sometime they change the algorithms.

Let’s now turn to the problem Chee worked on, which is related to the difficulty that Kurt faced in LEDA.

The BBP Algorithm

In 1995, David Bailey, Peter Borwein, and Simon Plouffe discovered a beautiful algorithm–now called BBP–that computes the {n^{th}} bit of the number {\pi} without first computing any of the previous bits. From the viewpoint of complexity theory they showed that the problem of computing the {n^{th}} bit of {\pi} is in {\mathsf{SC}}. The latter is “Steve’s Class” named after Steve Cook and consists of problems computable in polynomial time and poly-logspace.

The BBP result was quite unexpected—see my previous discussion on their great algorithm.

The BBP Algorithm Is Not An Algorithm

Their algorithm is wonderful. Or is it? The following remarkable quote is from Wikipedia:

“There is a vanishingly small possibility that a particular computation will be akin to failing to add a small number (e.g. {1}) to the number {999999999999999} and that the error will propagate to the most significant digit, but being near this situation is obvious in the final value produced.”

Excuse me, this is nonsense. The statement “vanishingly small possibility” is a statement of probability theory. There is nothing random here at all. I agree that it seems that the problem may never arise in practice, but that is different. The last point of the quote is correct. But that means that the BBP is not really an algorithm.

For a theorist an algorithm must have two basic properties: it must always compute the correct answer and it must have a provable running time. I am leaving aside randomized algorithms, which have the above properties but with only probabilistic assurances. If your method works on “most” inputs or runs “fast” in practice, then it may be extremely useful, but it is not an algorithm is the strict sense. Thus the BBP algorithm is not an algorithm in our sense.

Yap’s Theorem

Chee has improved the BBP result in two fundamental ways. He shows that {\pi} can be computed in not just {\mathsf{SC}} but in logspace. Further he shows that his algorithm really works—not that it just works in practice. Note, Chee’s algorithm is different from BBP’s algorithm, and it remains open if BBP’s exact algorithm works as claimed.

What is neat is Chee uses the notion of irrationality measure to prove his algorithm works, which is an idea I suggested in the original discussion.

This is an inequality that bounds how closely the number can be approximated by rational numbers with small denominators. The rational numbers are dense, so given any irrational number {\alpha} there is a rational number {p/q} so that

\displaystyle  | \alpha -p/q|

is as small as desired. However, not all irrational numbers are created equal when it comes to how small this approximation can be. If

\displaystyle  | \alpha - p/q| > 1/q^3

for all {p} and {q}, this means to get a close approximation to {\alpha} one must have a large {q}.

The standard definition is that {\alpha} has irrationality measure {\kappa>0} provided

\displaystyle  | \alpha - p/q | \le 1/q^{\kappa}

has only a finite number of solutions {p} and {q}. We would prefer to have the above hold for all {p,q}. But we usually cannot prove this for all, so we settle in the definition for almost all—that is for all {q} large enough.

Theorem: Any number with a positive irrationality measure and a BPP series has an algorithm that computes its {n^{th}} bit in polynomial time and space {O(\log n )}.

See Yap’s paper for the details.

Open Problems

What numbers can be computed in logspace? Can Chee’s theorem be generalized? His paper solves an open problem from this blog and I hope there will be many more in the future.

Like this:

Loading...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK