note that cotangent is actually 1/2 cotangent