change lossfxn to use matrices
don't use numerical analysis to solve problem