compute R
got the inverse working