# Swapping QODE methods for the same linear problem **English** · 简体中文 This example considers `u'=-u`. We represent the generator via a BE of `-I`, prepare the initial state with a single X gate, and then choose LCHS and Schrödingerization respectively. The generator is written as {obj}`scale ` applied to {obj}`identity `, and the problem, together with its initial state, is packed into a {obj}`QODEProblem `. ```{testcode} from oracq import Bits, Builder, QODEProblem, identity, scale from oracq.algorithms.qode.ode import linear_qode from oracq.algorithms.common.hamiltonian import taylor_hamiltonian from functools import partial b = Builder("initial_one", {"q": Bits(1)}) b.x(b["q"]) problem = QODEProblem(scale(-1, identity(1)), b.finish(), dissipative=True, initial_norm=1.0) kernel = partial(taylor_hamiltonian, degree=1) lchs = linear_qode("lchs", hamiltonian_function=kernel) schrodinger = linear_qode("schrodingerization", hamiltonian_function=kernel) assert lchs.check(problem, time=0.05).ok assert schrodinger.check(problem, time=0.05).ok first = lchs.solve(problem, 0.05) second = schrodinger.solve(problem, 0.05) print(first.width, second.width) print(len(first.operation.program().modules), len(second.operation.program().modules)) assert first.width == second.width == 1 ``` ```{testoutput} 1 1 31 28 ``` Both entry points are generated by {obj}`linear_qode ` from the method name and share {obj}`taylor_hamiltonian ` as the approximate simulation kernel. The printed results show: the two generators give the same target width `1` but differ in the number of internal modules (31 for LCHS, 28 for Schrödingerization), corresponding to different ancilla registers, approximation schemes, and recovery conditions. What this example checks is the assembly interface; a finite first-order Taylor kernel does not mean an arbitrary-accuracy solution of the differential equation has been obtained. `dissipative=True` is part of the problem declaration. LCHS's problem-level entry requires it to be stated explicitly; Schrödingerization relies on other mathematical conditions, in particular the choice of a suitable auxiliary window and recovery channel. ## Starting from a PDE A linear PDE first goes through spatial discretization into a {obj}`DiscretePDE(generator, initial) `, which is then handed to {obj}`make_qpde(qode) `. A nonlinear polynomial PDE can be turned into a {obj}`PolynomialODE `; Carleman generates the lifted system, which then calls the same three-argument linear-solver protocol. Complete heat-equation, Burgers-equation, and various given-oracle examples live in: ```bash uv run python examples/ode_input_models.py ``` ## Related pages - Manual: [Implementing QPDE/QODE](../manual/differential-equations.md) (symbols, scales, and applicability preconditions of each method) - Algorithm pages: QODE problem objects and protocol, LCHS, Schrödingerization, Carleman linearization - API reference: [QODE assembly interface](../api/algorithms/qode/ode.rst), [PDE models and adaptation](../api/algorithms/qpde/pde.rst), [Carleman linearization](../api/algorithms/qnlss/carleman.rst) - Continue with: [Scientific computing workflows](scientific-workflows.md) (the full walkthrough from open coefficients and batched binding to different data paths)