Skip to content

Parameters

Some of Classiq's built-in functions can work on parameters (for example, rotation gates).
This guide describes how they can be provided and used.

Using strings

The parameters can be provided to the functions using str.

Example

A single parameter can be provided:

    {
        "logic_flow": [
            {
                "function": "RZGate",
                "function_params": {
                    "phi": "x"
                }
            }
        ]
    }
from classiq import ModelDesigner
from classiq.builtin_functions.standard_gates import RZGate

model_designer = ModelDesigner()
rz_params = RZGate(phi="x")
model_designer.RZGate(rz_params)
model_designer.synthesize()

 Parametrized_Rotation example


Also, parameter expressions can be provided.

Example

    {
        "logic_flow": [
            {
                "function": "RZGate",
                "function_params": {
                    "phi": "(2 * (x + y)) / 3"
                }
            }
        ]
    }
from classiq import ModelDesigner
from classiq.builtin_functions.standard_gates import RZGate

model_designer = ModelDesigner()
rz_params = RZGate(phi="(2 * (x + y)) / 3")
model_designer.RZGate(rz_params)
model_designer.synthesize()

 Parametrized_Rotation example

Using Sympy

Parameters can also be defined by sympy. Note that sympy can be used only in the SDK.

Example

```python
import sympy

from classiq.interface.chemistry.operator import PauliOperator
from classiq.interface.generator.suzuki_trotter import SuzukiParameters, SuzukiTrotter
from classiq import ModelDesigner

model_designer = ModelDesigner()
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_designer.SuzukiTrotter(trotter_params)
model_designer.preferences.draw_at_level = 4
model_designer.synthesize()
```

 Suzuki_Trotter_Example


When using sympy, mathematical expressions can be used naturally.

Example

```python
import sympy

from classiq.interface.chemistry.operator import PauliOperator
from classiq.interface.generator.suzuki_trotter import SuzukiParameters, SuzukiTrotter
from classiq import ModelDesigner

model_designer = ModelDesigner()
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_designer.SuzukiTrotter(trotter_params)
model_designer.synthesize()
```

 Suzuki_Trotter_Example