Tales from the Evil Empire

Bertrand Le Roy's blog


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff


Quantum computing done right

(c) 2004 Bertrand Le Roy I know as a good microsoftee I should be supportive of what my employer does no matter what it is, and I might get fired for this post, but Eilon’s latest article is wrong on so many levels I have to step up with whatever integrity I have left and fix this mess.

In his post, he exposes the new ShrödingOr<TDead, TAlive> type that will be introduced in .NET 5.0 as part of the System.QuantumEntanglement namespace. Well, let’s face it, the current implementation has nothing quantum about it.

Here’s how I would have written it:

namespace System.QuantumEntanglement {
    public class SchrödingOr<TDead, TAlive> {
        private Complex _howDead;
        private Complex _howAlive;

        public SchrödingOr(Complex howDead, Complex howAlive) {
            _howDead = howDead;
            _howAlive = howAlive;

        public Type Measure() {
            double howAliveSquareModulus =
                _howAlive.Real * _howAlive.Real +
                _howAlive.Imaginary * _howAlive.Imaginary;
            double howDeadSquareModulus =
                _howDead.Real * _howDead.Real +
                _howDead.Imaginary * _howDead.Imaginary;
            double probabilityOfBeingAlive = howAliveSquareModulus /
                (howAliveSquareModulus + howDeadSquareModulus);

            if ((new Random()).NextDouble() < probabilityOfBeingAlive) {
                _howAlive = new Complex(1, 0);
                _howDead = new Complex(0, 0);
                return typeof(TAlive);
            } else {
                _howAlive = new Complex(0, 0);
                _howDead = new Complex(1, 0);
                return typeof(TDead);

This way, the state really is a (complex) linear combination of the dead and alive types, which are the eigenstates of the system. Once you’ve created the state, you can never get it back unless you do a measurement. When you do that, the object collapses its state to one of the eigenstates based on probabilities determined by the actual quantum state of the system.

The first measurement is random but once you’ve measured it, the cat remains alive or dead forever (the entanglement is destroyed by the measure).

Here’s a little console app that creates a cat, puts it in the box and then opens the box:

static void Main(string[] args) {
    // put the cat in the box
    var cat = new SchrödingOr<DeadCat, LiveCat>(
        new Complex(1, 0), new Complex(1, 0));
    // Open the box
    Console.Write(cat.Measure() == typeof(DeadCat) ?
        "Cat is dead." : "Cat is alive");

This, I believe, is a much more realistic and useful implementation of SchrödingOr.

The code: http://weblogs.asp.net/blogs/bleroy/Samples/Quantum.zip

Eilon’s original article: http://weblogs.asp.net/leftslipper/archive/2009/04/01/the-string-or-the-cat-a-new-net-framework-library.aspx


joelvarty said:

Dude - you've totally lost me on the comparison betwen what you are talking about and Eilon was discussing, and frankly it doesn't seem the Eilon was really talking about quantum computing at all - just the fact that if the string is an input, it should be maintained along with the Type information that it was maintained with.

I agree that "fixing" the string as an input Type seems too simplified, but that might be a good thing, especially for asp.net, if the kinds of data conversion that make "human" sense with string can be allowed.

Another post to sort things out, or whatever, would be a good idea.  

I hope you don't get fired... ;)

# April 2, 2009 8:23 AM

Bertrand Le Roy said:

@Joel: I guess now that it's April 2nd, I can reveal that yesterday was in fact April 1st. :)

# April 2, 2009 11:58 AM

AI said:

LOL...at least you were able to trick someone..the poor fool.

"and I might get fired for this post" was a dead giveaway!

# April 3, 2009 4:32 PM

Ryan said:

I just saw this today, awesome :) I wouldn't have fallen for it on the first though. When I saw the System.QuantumEntanglement namespace I couldn't stop laughing.

# April 7, 2009 1:13 PM

joelvarty said:

lol.  didn't see the date in my rss reader.  That was fun.

# April 22, 2009 9:53 AM

AS said:

Remove hoaxes once it's out, otherwise you clug the searches with junk.

# May 9, 2009 12:13 PM

Bertrand Le Roy said:

@AS: no.

# May 11, 2009 12:47 PM