The cosine function; in ML papers usually cosine similarity, a cosine schedule, or positional encodings.
In ML papers
cosx is the cosine of an angle x in radians, between −1 and 1. Three uses dominate ML papers:
Cosine similarity: cos(u,v)=∥u∥∥v∥u⊤v, the cosine of the angle between two vectors: 1 if they point the same way, 0 if orthogonal, −1 if opposite. Contrastive losses and embedding search use it.
Cosine schedules: the learning rate decays along half a cosine wave, as in SGDR (Loshchilov & Hutter 2017); diffusion models use a cosine noise schedule (Nichol & Dhariwal 2021). And with sin, it builds positional encodings and rotary embeddings.
How to type it
LaTeX
Shows
\cos
cos
\arccosinverse cosine
arccos
A worked example
u=(1,0),v=(1,1):cos=1×21≈0.707
The two vectors are 45 degrees apart, and arccos(0.707)=4π.
Common confusions
Cosine similarity is often written sim(u,v) or with no function at all, as u^⊤v^ on unit vectors.