Quantum Algorithms · Search
Grover search (statevector)
Simulate Grover's search on up to 20 qubits and get the exact success probability plus seeded measurement counts.
Evolve a transverse-field Ising chain with a first- or second-order product formula and measure the error against exact dynamics.
Officially provided by KetQat — method by Trotter (1959), Suzuki (1976) and others. KetQat prepares, verifies and maintains this product; it does not claim to have invented the method. Read the origin statement.
Simulates time evolution under the transverse-field Ising Hamiltonian H = -J sum Z_i Z_{i+1} - h sum X_i on your machine, two ways. The Trotter circuit (first-order Lie-Trotter or second-order Strang/Suzuki splitting) is applied gate by gate to the amplitudes of |0...0>; the exact state exp(-iHt)|0...0> is computed by diagonalising the dense Hamiltonian. The two paths share no code, so their difference is the Trotter error itself, measured rather than bounded. The product reports the fidelity between the two states, the survival probability and the average Z magnetisation on both, and optionally fits the exponent of the infidelity against the step count, which theory fixes at -2 for first order and -4 for second.
For students checking that product formulas converge at the rate the textbooks state, and for researchers who want an exact, reproducible reference for a small Hamiltonian-simulation circuit.
Installs the KetQat SDK from commit 2cedabbd814f, the exact version whose product definition this page shows. The SDK is not on PyPI yet, so pip install ketqat alone will not work.
pip install "ketqat[algorithms] @ git+https://github.com/ketqat/ketqat-sdk@2cedabbd814fd199b1989c8ceb1e9efa1744c2c0#subdirectory=python"Save it as example.py and run python example.py. Or use the CLI: ketqat catalog run [email protected].
import json
from ketqat_runner import catalog
record = catalog.run("[email protected]", seed=7, qubits=4, time=1.0, steps=10, order=1)
result = record.result
print(json.dumps({
"status": record.status,
"fidelity": round(result["fidelity"], 6),
"survival_probability_exact": round(result["observables"]["survival_probability"]["exact"], 6),
"fitted_slope": round(result["scaling"]["slope"], 2),
"expected_slope": result["scaling"]["expected_slope"],
}))
{
"status": "succeeded",
"fidelity": 0.995078,
"fitted_slope": -2.03,
"expected_slope": -2,
"survival_probability_exact": 0.210729
}Verified with
ketqat report RUN_ID sends an opt-in usage report: product, version, succeeded/failed, time and SDK version only. It shows you the exact payload first and needs an API token from Settings. Nothing is sent unless you run it.
| Name | Type | Default | Allowed values | Description |
|---|---|---|---|---|
| qubits | integer | 4 | maximum: 12; minimum: 1 | Chain length n. The dense 2^n x 2^n Hamiltonian is diagonalised, so requests above 10 qubits are refused with the memory they would need. |
| coupling | number | 1 | maximum: 100; minimum: -100 | J, the Z Z coupling. |
| field | number | 1 | maximum: 100; minimum: -100 | h, the transverse field. |
| time | number | 1 | maximum: 100; minimum: 0 | Evolution time t. |
| steps | integer | 10 | maximum: 10000; minimum: 1 | Trotter steps r; each step evolves by t/r. |
| order | integer | 1 | enum: 1, 2 | 1 for Lie-Trotter, 2 for the symmetric Strang (Suzuki) splitting. |
| periodic | boolean | false | — | Close the chain into a ring (adds the bond between the last and first qubit; a 2-site ring is left open). |
| fit_scaling | boolean | true | — | Also evolve at each of scaling_step_counts and fit the log-log slope of infidelity against steps. |
| scaling_step_counts | integer[] | [4,8,16,32,64] | minItems: 2; itemMaximum: 10000; itemMinimum: 1; uniqueItems: true | Step counts for the scaling fit. |
| Name | Type | Description |
|---|---|---|
| fidelity | number | |<exact|trotter>|^2 between the Trotterized and the exact state at time t; infidelity is 1 minus it. |
| state_distance | number | Norm of the difference between the two states, up to a global phase. |
| observables | object | survival_probability (|<0...0|psi(t)>|^2) and average_magnetization_z ((1/n) sum <Z_i>), each on the Trotter and the exact state. |
| scaling | object | When fit_scaling: step_counts, infidelities, the fitted slope, expected_slope (-2 or -4) and the intercept; null with scaling_note when the terms commute and there is no error to fit. |
4-qubit chain, J = h = 1, t = 1, 10 first-order steps: fidelity 0.995078 with the exact state (survival probability 0.2088 Trotter vs 0.2107 exact); the infidelity over 4..64 steps fits a slope of -2.03 against the theoretical -2.
Generated with
{"time":1,"field":1,"order":1,"steps":10,"qubits":4,"coupling":1,"periodic":false,"fit_scaling":true,"scaling_step_counts":[4,8,16,32,64]}{
"time": 1,
"field": 1,
"model": "H = -J sum_<i,j> Z_i Z_j - h sum_i X_i",
"order": 1,
"steps": 10,
"qubits": 4,
"scaling": {
"note": "Infidelity ~ steps^-2.03. Theory gives amplitude error O(t^2/steps^1), and infidelity is its square, so the expected slope is -2.",
"slope": -2.02771039075,
"intercept": -0.625421648931,
"step_counts": [
4,
8,
16,
32,
64
],
"infidelities": [
0.032899952131,
0.007752494869,
0.001904256842,
0.000473393413,
0.000118112715
],
"expected_slope": -2
},
"coupling": 1,
"fidelity": 0.995078196614,
"periodic": false,
"execution": "statevector simulation of the Trotter circuit; exact reference by dense eigendecomposition",
"reference": "exp(-iHt) by eigendecomposition, exact up to floating point",
"splitting": "first-order Lie-Trotter: exp(-iH_ZZ dt) exp(-iH_X dt) per step",
"infidelity": 0.004921803386,
"observables": {
"survival_probability": {
"exact": 0.21072880398,
"trotter": 0.208798179005
},
"average_magnetization_z": {
"exact": 0.135077479856,
"trotter": 0.132944995786
}
},
"scaling_note": null,
"initial_state": "|0...0> (all spins up along Z)",
"state_distance": 0.070198820305
}convergence exponent
Through the product, the fitted log-log slope of infidelity against step count on 4 qubits is within 0.15 of -2 for first order and -4 for second order, the exponents product-formula theory predicts, and second order has lower infidelity than first at equal step count.
python/tests/test_catalog_products.py::test_trotter_error_scales_with_the_expected_order
analytic dynamics
Without coupling the chain is n independent spins and the survival probability is cos(ht)^(2n) in closed form; without a field |0...0> is an eigenstate and the survival probability is 1. The product's Trotter and exact values match these to 1e-12, and the fidelity between them is 1.
python/tests/test_catalog_products.py::test_trotter_matches_closed_forms_when_the_terms_commute
resource guard
More than 10 qubits is refused with the memory the dense Hamiltonian would need, and a step budget estimated above the time ceiling is refused with the estimate.
python/tests/test_catalog_products.py::test_trotter_refuses_large_chains_with_a_memory_estimate
example execution
The example code is executed verbatim in a clean virtual environment with only the algorithms extra installed.
1.0.01 Nov 2026currentShown on this page
Needs SDK 0.3.0 or later with extras: algorithms.
KetQat implementation of published methods
The product formula is due to Trotter (1959) and its symmetric higher-order generalisation to Suzuki (1976); their use for simulating quantum dynamics on a quantum computer was proposed by Lloyd (1996), and the error theory is reviewed by Childs, Su, Tran, Wiebe and Zhu (2021). KetQat wrote this NumPy implementation (trotter.py), the exact eigendecomposition reference, the scaling fit, the validation tests and this catalog entry. KetQat did not invent the method.
Apache-2.0 — see Licensing.
People credited for this product. KetQat publishes and maintains it; contributors are credited for their work and are not sellers.
No usage reports yet
Distinct signed-in accounts that chose to send at least one usage report (ketqat report) for this product in the last 90 days. KetQat staff, test and bot accounts are excluded. Reports are opt-in, so this is not a count of all users.
Computed 10 Nov 2026, 17:34 UTC.
Not yet rated
Be the first to rate this product after you run it.
Mean of visible reviews. Hidden reviews and reviews by KetQat staff, test and bot accounts are excluded. Pro status gives no extra weight.
Sign in to review this product. One review per person; you can edit it later.
No reviews yet.