### P = NP

June 9, 2014 By your many years of attempting to impress your professors, you've learned the art of cocktail party conversation. Masters of this art will be able to talk grandly on most topics up to a limit of about a minute, at which time the conversation has hopefully changed subject. It's much more entertaining than just talking about the weather. Things are a little harder when you're talking among your scientific peers, whose depth of knowledge transcends that of the typical Sangria sipper. In that case, you meed to haul out the big guns. Among computer people, a casual mention of the Entscheidungsproblem is usually all you need to gain your listener's respect without worrying about follow-up questions. It's a subject of which everyone has heard, because of its historical significance and association with Alan Turing, but very few have actually studied. Since the early center of science and mathematics was Europe, including Germany, many fundamental problems have German names. These range from the simple Aufbauprinzip (Aufbau principle) to the tongue-twisting Entscheidungsproblem. This might be expected from a country where the research foundation is called Deutsche Forschungsgemeinschaft. The "halting problem," as it's known in English, is a computer science version of the cinema scientist's lament that "there are things that Man was not meant to know." Possibly the best statement of the halting problem was written in 1935 by mathematician, Alonzo Church, who was considering what it means for a function to be calculable. He decided that the function would contain an algorithm, and you would know when the algorithm terminated; that is, the algorithm yields an answer. In computer science terms, this means knowing that your program, for a particular input, will eventually halt, or goes on forever. Alan Turing, in his 1937 paper, "On Computable Numbers With an Application to the Entscheidungsproblem," addressed the problem by first constructing a universal computer, his Turing machine. He proved that it wasn't possible to decide whether a program on such a machine will halt, effectively proving that there are things that computer scientists are not meant to know.*A physical Turing machine, built by Mike Davey.You can see its operation in a YouTube video.(Photograph by "GabrielF," via Wikimedia Commons.Click for larger image.)*

Deciding which problems are too hard to tackle is one task of an effective scientist. He might not know that his research will lead to a dead end, but the referees of his research proposal likely will. The halting problem notwithstanding, computers have been successfully performing many of our calculations for years. Despite these successes, there are some calculations that are very difficult. One simple example of such a problem (simple enough to be presented in the cartoon shown below) is the subset sum problem. If you have a set of numbers, is it possible for members of the set to add to a particular number? There's no algorithm to do this; and, if you have many numbers in the set, you need to try a lot of combinations to see whether it's possible.

*A cartoon from **Randall Munroe's xkcd Comics, licensed under a Creative Commons Attribution-NonCommercial 2.5 License. (xkcd comic 287.)*

The complexity of this calculation increases at a rate that's not known to be polynomial in time; that is, it's "nondeterministic polynomial" (NP) in time. Verification of the answer happens in polynomial time (P). A polynomial execution time for calculations involving N elements would be something like N

^{1}, N

^{2}, or N

^{3}, and so on. NP execution, however, would be something like 2

^{N}, which becomes very large for large N. It would be nice if every problem with a quickly verified solution would have an algorithm that allows its quick computation as well. In the language of computer science, we would like to have P=NP, rather than the converse, P≠NP. This P

__vs__NP problem is an open problem that's important enough to have been designated one of the seven, million dollar, Millennium Prize Problems selected by the Clay Mathematics Institute. Its solution would be important to such diverse areas as cryptography and economics. Public key cryptography involves the idea that it's easy to multiply two huge prime numbers to get an even larger number, but it's very difficult to factor that large number into its prime components. The factoring is NP. Nearly every NP problem is NP-complete, a terminology expressing the fact that a polynomial solution of any one of those can be easily applied to the rest.[1] The traveling-salesman problem, which I wrote about in a previous article (The Traveling Salesman Problem, March 1, 2013), is NP-complete. The problem expressed in the above cartoon is NP-complete, but there are so few elements that the solution can be found by inspection, or just a few computer calculations. When the cartoonist, Randall Munroe, created the cartoon, he didn't realize that the problem had more than one solution.[2] These are seven mixed fruit orders and the combination of one order of mixed fruit, two orders of hot wings, and one sampler plate. One web site has a few elegant programs for the efficient solution of this particular problem.[3] My computer solution is not at all elegant, although it is very general. I used a the Monte Carlo method, and you can view my C language source code, here. In the Monte Carlo method, you try random combinations of multiples of the items until you find one that works. There's some method to the madness, since you purposely don't select multiples of any one item that will go over the limit ($15.05, in this case), as shown in the table.

So, how well does this approach work? As can be seen in the histogram, the program often finds a solution after just a few random selections. If you just multiply the maximum numbers in the table, you get 3360, so you should expect to find a solution somewhat close to that number of random selections, if a solution exists. You'll note, also, that there are still cases for which a solution is found at our patience limit, which was 30,000 random selections.

Item Maximum Number Mixed Fruit 7 French Fries 5 Side Salad 4 Hot Wings 4 Mozzarella Sticks 3 Sampler Plate 2

*Histogram of the number of random selections required to get a Monte Carlo solution to xkcd cartoon 287.30,000 trials were attempted.(Gnumeric.)*

### References:

- Larry Hardesty, "Explained: P vs. NP," MIT News Office, October 29, 2009.
- Explain 287: NP-Complete, Explain xkcd Web Site.
- Solving the NP-complete problem in XKCD, Stack Overflow Web Site.

*Permanent Link to this article*

Linked Keywords: Professor; cocktail party; conversation; entertainment; entertaining; weather; science; scientific; peer; knowledge; Sangria; computer scientist; computer people; halting problem; Entscheidungsproblem; history; historical; Alan Turing; science; mathematics; Europe; Germany; German language; Aufbau principle; Aufbauprinzip; research; foundation; Deutsche Forschungsgemeinschaft; English language; computer science; film; cinema; scientist; lament; mathematician; Alonzo Church; function; calculation; calculable; algorithm; computer programming; program; On Computable Numbers With an Application to the Entscheidungsproblem; Turing machine; Mike Davey; YouTube video; Wikimedia Commons; peer review; referee; research proposal; cartoon; subset sum problem; set; number; addition; NP Complete, xkcd comic no. 287; Randall Munroe; xkcd Comics; Creative Commons Attribution-NonCommercial 2.5 License; polynomial; time; nondeterministic polynomial; polynomial time; converse; P __vs__ NP; open problem; Millennium Prize Problem; Clay Mathematics Institute; cryptography; economics; public key cryptography; multiplication; multiply; prime number; factorization; factor; NP-complete; terminology; traveling salesman; efficiency; efficient; elegance; elegant; Monte Carlo method; C programming language; source code; randomness; random; method to the madness; histogram; Gnumeric.

### Google Search

Free Downloads:

STEM artwork

for your holiday gifts

Latest Books by Dev Gualtieri

Thanks to Cory Doctorow of BoingBoing for his favorable review of Secret Codes!

Other Books

- Ultra-pure Green Light - November 20, 2017

- High Energy Cosmic Rays - November 13, 2017

- Advanced Aluminum Alloys - November 6, 2017

- Joseph Polchinski - October 30, 2017

- Our Magnetic Universe - October 23, 2017

- Cavitation - October 16, 2017

- Pell Numbers - October 9, 2017

- Miniature Antennas - October 2, 2017

- Fizzy Graphene - September 25, 2017

- The First Angiosperm - September 18, 2017

- Noise Thermometry and the Boltzmann Constant - September 11, 2017

- Walking in the Rain - September 4, 2017

- Agitated Atoms - August 28, 2017

- Partial Solar Eclipse at New Jersey - August 24, 2017

- Magnetocapacitive Tunnel Junctions - August 21, 2017

- Tardigrades - August 14, 2017

- Roman Concrete - August 7, 2017

- Solar Spicules - July 31, 2017

- Schroeder Diffuser - July 24, 2017

- Rough Microparticles - July 17, 2017

- Robot Musicians - July 10, 2017

- Walter Noll (1925-2017) - July 6, 2017

- cosmogony - July 3, 2017

- Crystal Prototypes - June 29, 2017

- Voice Synthesis - June 26, 2017

- Refining Germanium - June 22, 2017

- Granular Capillarity - June 19, 2017

- Kirchhoff–Plateau Problem - June 15, 2017

- Self-Assembly - June 12, 2017

- Physics, Math, and Sociology - June 8, 2017

- Graphene from Ethylene - June 5, 2017

- Crystal Alignment Forces - June 1, 2017

- Martian Brickwork - May 29, 2017

- Carbon Nanotube Textile - May 25, 2017

- The Scent of Books - May 22, 2017

- Patterns from Randomness - May 18, 2017

- Terpene - May 15, 2017

- The Physics of Inequality - May 11, 2017

- Asteroid 2015 BZ509 - May 8, 2017

- Fuzzy Fibers - May 4, 2017

- The Sofa Problem - May 1, 2017

### Deep Archive

Deep Archive 2006-2008

**Blog Article Directory on a Single Page**