"},{"cell_type":"text","text":"Create a symbolic controlled-Y gate"},{"code":"CY10 = CGate(1, Y(0)); CY10\n","cell_type":"code","prompt_number":3},{"cell_type":"text","text":"Decompose it into elementary gates and plot it"},{"code":"CY10.decompose()\n","cell_type":"code","prompt_number":4},{"code":"circuit_plot(CY10.decompose(), nqubits=2)","cell_type":"code","prompt_number":5},{"cell_type":"text","text":"
Example 2
"},{"cell_type":"text","text":"Create a controlled-Z gate"},{"code":"CZ01 = CGate(0, Z(1)); CZ01\n","cell_type":"code","prompt_number":6},{"cell_type":"text","text":"Decompose and plot it"},{"code":"CZ01.decompose()\n","cell_type":"code","prompt_number":7},{"code":"circuit_plot(CZ01.decompose(), nqubits=2)","cell_type":"code","prompt_number":8},{"cell_type":"text","text":"
Example 3
"},{"cell_type":"text","text":"Create a SWAP gate"},{"code":"SWAP10 = SWAP(1, 0); SWAP10\n","cell_type":"code","prompt_number":9},{"cell_type":"text","text":"Decompose and plot it"},{"code":"SWAP10.decompose()","cell_type":"code","prompt_number":10},{"code":"circuit_plot(SWAP10.decompose(), nqubits=2)","cell_type":"code","prompt_number":11},{"cell_type":"text","text":"
All together now
"},{"code":"gates = [CGate(1,Y(0)), CGate(0,Z(1)), SWAP(1, 0)]","cell_type":"code","prompt_number":12},{"code":"for g in gates:\n dg = g.decompose()\n display(Eq(g, dg))\n circuit_plot(g, nqubits=2)\n circuit_plot(dg, nqubits=2) ","cell_type":"code","prompt_number":13},{"code":"%notebook save decompose.ipynb","cell_type":"code","prompt_number":30},{"code":"%notebook load gate_rules.ipynb","cell_type":"code","prompt_number":53}]}