updated to include gramschmidt and matrix inversion