Cosine formula and identities