# Numerically solving linear equation and optimization

I have to solve for $x$ in the linear equation $Ax=B$. However, $A$ has singular values that are close to zero (very small). So direct inversion is not a good idea. I wanted to solve for $x$ using one of the numerical equation solvers? Does any one know which is the best one I could use? I used conjugate gradient method but the convergence is not achieved. Any better method?

-