remove possibility of singular matrix in cost fn and grad cost fn, what to do for large R with correlations though?