Taylor Truncation
Taylor truncation based Hamiltonian simulation (https://arxiv.org/abs/1412.4687) has many clear advantages. It has better complexity dependence on the precision and allows a greater range of Hamiltonians to be simulated.
The package provides circuits for five kinds of problems:
- Unitary Taylor simulation
- Non-unitary Taylor simulation
- Unitary QuLDE Problem
- Non-unitary QuLDEProblem
- Solution by linearising a non-linear differential equation
To simulate the following the algorithm, simulates the Taylor expansion of $e^{iHt}$ upto $k$ orders.
We have,
where $M = ||M||\mathcal{M} = iH$
There are two cases to consider:
- $\mathcal{M}$ is unitary. In addition to the vector state register, we have $T = log_{2}(k+1)$ ancillary bits. The ancilla is in $|0⟩$ to begin with. The
VS1
block acts on the ancilla register to generate an appropriate superpostion
Multiplication of $\mathcal{M}^{j}$ block is controlled by $|j⟩$ in the ancilla register. VS1'
, the adjoint of VS1
, un-computes the ancilla registers. The desired result is obtained when the resulting state is projected onto $|0\rangle$ ancilla state.
- $\mathcal{M}$ is non-unitary. $\mathcal{M}$ is expressed as a linear combination of four (at most) unitary i.e. $\mathcal{M} =\sum_{i} \frac{1}{2} F_{i}$. We have two registers of sizes $k$ and $2k$.These registers participate in control-multiplications, as control bits.
VS1
behaves differently to that in the unitary case. In the first register, states with $j$ $1$'s (where $j \in \{0,1,...,k\}$) are raised to probability amplitudes equal to the term with the $j^{th}$ power in the summation above, while rest of the states are given zero probability. The mappings used is $m = 2^{k} - 2^{j}$ , $m$ corresponds to the basis state in the first register. This register governs the the power $F_i$s need to be raised to. The second register is superposed byVT
, where each new state corresponds to a $F_i$. When un-computed and measured in the zero ancilla state, we obtain the desired result.
QuDiffEq.TaylorParam
— Type.TaylorParam(k::Int, t::L, H::Matrix, x::Array{CPType,1})
TaylorParam(k::Int,t::L,prob::QuLDEProblem{uType, tType, isinplace, F, P, T})
Assigns values to parameters required for Taylor series based Hamiltonian simulation.
* k : sets order of Taylor series expansion
* t : time of evolution
* H : Hamiltonian
* x : intial vector
* prob : wrapper for Linear differential equation problems (contains H, x, b)
QuDiffEq.circuit_ends
— Method.circuit_ends(n::Int, blk::TaylorParam{CPType, false}, VS1::AbstractMatrix, VS2::AbstractMatrix, VT::AbstractMatrix)
Generates the part of circuit that computes and decomputes the superposition of the ancilla bits, in non-unitary H quldecircuit
QuDiffEq.circuit_ends
— Method.circuit_ends(n::Int, blk::TaylorParam{CPType, false}, VS1::AbstractMatrix, VT::AbstractMatrix)
Generates the part of circuit that computes and decomputes the superposition of the ancilla bits, in non-unitary H taylorcircuit
QuDiffEq.circuit_ends
— Method.circuit_ends(n::Int, blk::TaylorParam{CPType, true}, VS1::AbstractMatrix, VS2::AbstractMatrix)
Generates the part of circuit that computes and decomputes the superposition of the ancilla bits, in unitary H quldecircuit
QuDiffEq.circuit_ends
— Method.circuit_ends(n::Int, blk::TaylorParam{CPType, true}, VS1::AbstractMatrix)
Generates the part of circuit that computes and decomputes the superposition of the ancilla bits, in unitary H taylorcircuit
QuDiffEq.circuit_intermediate
— Method.circuit_intermediate(n::Int, c::Int, blk::TaylorParam{CPType, false})
Generates the intermediate part of the circuit for non-unitary H.
QuDiffEq.circuit_intermediate
— Method.circuit_intermediate(n::Int, c::Int, blk::TaylorParam{CPType, true})
Generates the intermediate part of the circuit for unitary H.
QuDiffEq.taylorcircuit
— Method.taylorcircuit(n::Int, blk::TaylorParam, VS1::Matrix, VT::Matrix) ->-> ChainBlock{n}
Generates circuit for a non-unitary H input.
QuDiffEq.taylorcircuit
— Method.taylorcircuit(n::Int, blk::TaylorParam, VS1::Matrix) -> ChainBlock{n}
Generates circuit for a unitary H input.
QuDiffEq.taylorsolve
— Method.taylorsolve(H::Array{CPType,2}, x::Vector{CPType}, k::Int, t::Real) -> ArrayReg, CPType
Simulates a Hamiltonian using the Taylor truncation method. Returns the state register and inverse probability of finding it.
QuDiffEq.v
— Method.v(n::Int,c::Int, T::Int, V::AbstractMatrix) -> ChainBlock{n}
Builds T input block. n : total number of qubits V : T input matrix c : starting qubit
QuDiffEq.v
— Method.v(n::Int,c::Int, j::Tuple, T::Int, V::AbstractMatrix) -> ControlBlock{n}
Builds a T input, j - control block. n : total number of qubits V : T input matrix c : starting qubit j : control bits tuple
QuDiffEq.calc_vs1
— Method.calc_vs1(blk::TaylorParam, x::Vector{CPType}, opn::Real) -> Matrix{CPType}
Calculates VS1 block for Taylor circuit.
QuDiffEq.calc_vs2
— Method.calc_vs2(blk::TaylorParam, x::Vector{CPType}, opn::Real) -> Matrix{CPType}
opn: operator norm of the input matrix.
Calculates VS2 block for Taylor circuit.
QuDiffEq.calc_vt
— Method.calc_vt(::Type{CPType}) -> Matrix{CPType}
Generates VT block for non-unitary Taylor circuit.
QuDiffEq.unitary_decompose
— Method.unitary_decompose(H::Array{T,2}) -> Array{Array{T,2},1}
Generates a linear compostion of unitary matrices for argument H.
Quantum Linear Differential Equation
A linear differential equation is written as
$M$ is an arbitrary N × N matrix, $x$ and $b$ are N dimensional vectors.
The modified version of the taylorcircuit
is employed here. The transformation over $x$ is the same as in the taylorcircuit
, but there is simultaneous transformation over b
as well. There is an additional ancillary bit that allows the distinction between $x$ and $b$. This superpostion is brought about by V
matrix. Like VS1
in taylorcircuit
, VS2
facilitates the transformation on $b$ in the simulation.
QuDiffEq.quldecircuit
— Method.quldecircuit(n::Int,blk::TaylorParam,VS1::AbstractMatrix,VS2::AbstractMatrix,VT::AbstractMatrix) -> ChainBlock{n}
Generates circuit for solving linear differental equations for a non-unitary H input.
QuDiffEq.quldecircuit
— Method.quldecircuit(n::Int,blk::TaylorParam,VS1::AbstractMatrix,VS2::AbstractMatrix) -> ChainBlock{n}
Generates circuit for solving linear differental equations for a unitary H input.
Quantum Non-linear Differential Equation
The non-linear solver constitutes two sub-routines. Firstly, the function transform sub-routine, which employs of the taylorcircuit
. The function transform lets us map $z$ to $P(z)$, where $P$ is a quadratic polynomial.
Secondly, the forward Euler method. The polynomial here is : $z + hf(z)$. $f$ is the derivative .
QuDiffEq.euler_matrix
— Method.euler_matrix(A::Matrix{CPType},b::Vector{CPType},h::Real) -> Matrix
Generates matrix for forward Euler iteration.
QuDiffEq.euler_matrix_update
— Method.euler_matrix(A::Matrix{CPType},b::Vector{CPType},h::Real) -> Matrix
Updates euler matrix for forward Euler iteration.
QuDiffEq.func_transform
— Function.func_transform(A::Matrix, x::Vector, k::Int) -> ArrayReg, <: Complex
Function transform sub-routine. Returns state register and inverse probability of finding it.
QuDiffEq.make_hermitian
— Method.make_hermitian(A::Matrix) -> Matrix
Returns hermitian matrix containing A.
QuDiffEq.make_input_vector
— Method.make_input_vector(x::Vector{T}) -> Vector{T}
Generates input vector for QuNLDE
iterations.