  Cavity resonators are promising resources for quantum technology, while
native nonlinear interactions for cavities are typically too weak to provide
the level of quantum control required to deliver complex targeted operations.
Here we investigate a scheme to engineer a target Hamiltonian for photonic
cavities using ancilla qubits. By off-resonantly driving dispersively coupled
ancilla qubits, we develop an optimized approach to engineering an arbitrary
photon-number-dependent (PND) Hamiltonian for the cavities while minimizing the
operation errors. The engineered Hamiltonian admits various applications
including canceling unwanted cavity self-Kerr interactions, creating
higher-order nonlinearities for quantum simulations, and designing quantum
gates resilient to noise. Our scheme can be implemented with coupled microwave
cavities and transmon qubits in superconducting circuit systems.
