From the course: Quantum Computing Fundamentals

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Toffoli gate with Qiskit

Toffoli gate with Qiskit

- [Instructor] To demonstrate the toffoli gate with qiskit, lets add toffoli gate to the simple three-qubit circuit. To do that I'll type circuit.toffoli(0) for the first control qubit. (1) for the second control qubit and (2) for the target qubit. I'll click the run all button to run all the notebook cells and we can see that all three simulated bloch spheres are unchanged, and still in the initial 0 state. That makes sense because the control qubits are 0 so the toffoli gate wouldn't do anything. Let's try inserting an X gate, in front of the first control qubit. I'll press Shift Enter twice to run all those cells again and now the first qubit is flipped to 1 but the target qubit is still 0. Remember that the toffoli gate doesn't flip the target unless both control qubits are 1. So, let's insert another X gate, in front of the second control qubit. Run those cells again and now since both controls are 1 the target…

Contents