The QuantunNewtonRaphson allows to offload the gradient calculation of the Newton-Raphson algorithm to a variety of quantum linear solvers.
To install quantum_newton_raphson from GitHub repository, do:
git clone git@github.com:QuantumApplicationLab/quantumnewtonraphson.gitcd quantumnewtonraphsonpython -m pip install .fromqiskit.primitivesimportEstimator, Samplerfromquantum_newton_raphson.newton_raphsonimportnewton_raphsonfromquantum_newton_raphson.hhl_solverimportHHL_SOLVERdeffunc(input):
"""non linear function to be solved: func(x) = 0."""
...
returnoutputestimator=Estimator()
sampler=Sampler()
# define the linear solver with the reorder solversolver=HHL_SOLVER(estimator=estimator, sampler=sampler)
# Solve the newton raphson problemres=newton_raphson(
func, np.random.rand(2), linear_solver=solver, verbose=True, max_iter=25
)If you want to contribute to the development of quantum_newton_raphson, have a look at the contribution guidelines.
This package was created with Cookiecutter and the NLeSC/python-template.
