# Implementing the HHL algorithm with negative eigenvalues (Cirq)

How do I implement the HHL with negative eigenvalues?

This paper (https://arxiv.org/abs/1803.01486) says that:

what if $$\lambda<0$$? This problem actually does not hard to solve, since we can choose $$t$$ small enough, such that $$|\lambda t| < \pi$$. So if $$2 \pi y/N > \pi$$, then we believe that $$\lambda t = 2 \pi y/N − 2\pi=−2\pi (N−y)/N$$.

However, doing so introduces a problem at $$\lambda = 0$$, where the solution diverges.

Note 1: In Cirq, the code only works where eigenvalues of the Hamiltonian is positive. How do I adjust this code so it also works with negative eigenvalues? https://github.com/quantumlib/Cirq/blob/master/examples/hhl.py

Note 2: in Qiskit,the quantum phase estimation EigsQPE has an input negative_evals. It seems this adds one more ancilla qubit. What do that they do here? https://qiskit.org/documentation/stubs/qiskit.aqua.components.eigs.EigsQPE.html