Skip to content

User-defined Functions

The basic description of quantum algorithms in the Classiq platform is best expressed as the logic flow of quantum functions. When you describe the circuit model at the functional level, you are invited to leave the countless design possibilities and optimizations to the synthesis engine, so you can focus instead on the functional flow of the algorithm and not on the gate-level implementation.

Classiq provides many useful built-in functions (see built-in function library), but to create novel quantum algorithms, you can use your own functions. A function can be any sub-circuit: a single gate, a quantum adder, an oracle, or even a fully functioning quantum circuit.

Arithmetic operations, state preparation, local Hamiltonian terms, and QFT are all good examples of functions. Each function can have multiple implementations, make use of auxiliary qubits, have different numbers of input and output registers, require inputs to some of the registers, have a certain level of accuracy, and more. The more data you provide about the function, the better the synthesis engine creates and optimizes the quantum circuits.

In addition, you can use your own composite functions. Composite functions contain a functional description of the quantum algorithm it implements, using other functions as building blocks. This enables the development of increasingly complex functions, while you only need to describe the gate-level implementation of the most basic functions.

To begin, add a simple function of your own based on the explanations below. From there, the possibilities are endless.