I'm aware there's a few questions about CCCRY gate composition on here but I still have a few questions. I'm following Frank Zickert's book on qiskit and he has defined a CCRY gate as
def ccry(qc, theta, control1, control2, controlled): qc.cry(theta/2, control2, controlled) qc.cx(control1, control2) qc.cry(-theta/2, control2, controlled) qc.cx(control1, control2) qc.cry(theta/2, control1, controlled)
This makes sense to me given the circuit diagram of what's going on:
Taking Zickert's approach, could I construct a CCCRY gate? I'm aware I'm now needing 3 control qubits but I'm struggling beyond that. I did also see another answer that used
CCCRY = RYGate(a).control(3) but I don't know how to implement that because I haven't been using
qc.append(). For those unfamiliar with his book, it's going through the Titanic dataset and using qubits for ML; I wanted to try and add another category which means going from a CCRY gate to a CCCRY gate.