Skip to content

Book incorrect on table 7.3 entry #31

Description

@mik3hall

Not a problem with the code examples.

I was referring back to the book to see the explanation there for ancilla qubits and reversibility.

One entry in table 7.3 doesn't appear correct.

It shows |101> resulting in |100> but without both control bits flipped there should be no change?

import org.redfx.strange.Program;
import org.redfx.strange.Qubit;
import org.redfx.strange.QuantumExecutionEnvironment;
import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
import org.redfx.strange.Result;
import org.redfx.strange.Step;
import org.redfx.strange.gate.Toffoli;
import org.redfx.strange.gate.X;

public class ToffoliTest {

public static void main(String... args) {
	QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
	System.out.println("|101> -> |101>");
    Program p = new Program(3,
       new Step(new X(2),new X(0)),
       new Step(new Toffoli(2,1,0)));
    Result res = simulator.runProgram(p);
    Qubit[] qubits = res.getQubits();
    for (int i=0; i<qubits.length; i++) {
    	System.out.println(i + " " + qubits[i].measure());
    }
}

}

ToffoliTest
|101> -> |101>
0 1
1 0
2 1
(base) mjh@MacBook-Pro-2 quantumjava

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions