Skip to content

Parameters

Some of the Classiq engine's built-in functions can work on parameters (for example, rotation gates).
This page describes to provide and use them.

Using Strings

Provide the parameters to the functions using str.

Single Parameter Example

You can provide a single parameter.

    {
      "functions": [
          {
            "name": "main",
            "body": [
                {
                    "function": "RZGate",
                    "function_params": {
                        "phi": "x"
                    }
                }
            ]
          }
      ]
    }
from classiq import Model, synthesize
from classiq.builtin_functions import RZGate

model = Model()
rz_params = RZGate(phi="x")
model.RZGate(rz_params)
quantum_program = synthesize(model.get_model())

 Parametrized_Rotation example

Parameter Expression Example

You can also provide parameter expressions.

    {
      "functions": [
        {
          "name": "main",
          "body": [
              {
                  "function": "RZGate",
                  "function_params": {
                      "phi": "(2 * (x + y)) / 3"
                  }
              }
          ]
        }
      ]
    }
from classiq import Model, synthesize
from classiq.builtin_functions import RZGate

model = Model()
rz_params = RZGate(phi="(2 * (x + y)) / 3")
model.RZGate(rz_params)
quantum_program = synthesize(model.get_model())

 Parametrized_Rotation example

Using SymPy

You can define parameters using SymPy. Note that SymPy can be used only in the SDK.

SymPy Example

import sympy

from classiq.builtin_functions.exponentiation import PauliOperator
from classiq.builtin_functions import SuzukiTrotter
from classiq.builtin_functions.suzuki_trotter import SuzukiParameters
from classiq import Model, synthesize

model = Model()
x = sympy.Symbol("x")
trotter_params = SuzukiTrotter(
    pauli_operator=PauliOperator(pauli_list=[("XXZ", 1), ("YXZ", 0.5)]),
    evolution_coefficient=x,
    suzuki_parameters=SuzukiParameters(order=1, repetitions=1),
)
model.SuzukiTrotter(trotter_params)
quantum_program = synthesize(model.get_model())

 Suzuki_Trotter_Example

SymPy Mathematical Expressions Example

With SymPy, you can use mathematical expressions naturally. See Supported Expressions

import sympy

from classiq.builtin_functions.exponentiation import PauliOperator
from classiq.builtin_functions import SuzukiTrotter
from classiq.builtin_functions.suzuki_trotter import SuzukiParameters
from classiq import Model, synthesize

model = Model()
x = sympy.Symbol("x")
y = sympy.Symbol("y")
trotter_params = SuzukiTrotter(
    pauli_operator=PauliOperator(pauli_list=[("XXZ", 1), ("YXZ", 0.5)]),
    evolution_coefficient=(x + y) / 2,
    suzuki_parameters=SuzukiParameters(order=1, repetitions=1),
)
model.SuzukiTrotter(trotter_params)
quantum_program = synthesize(model.get_model())

 Suzuki_Trotter_Example

Automatically Generated Parameters

Some functions include many automatically generated parameters. You can provide the parameter_prefix for the parameter names.

The following functions are HVA, UCC, and HardwareEfficientAnsatz.

The Classiq engine regards the parameters of two functions with the same parameter_prefix as equivalent.