Cosine in LaTeX (\cos)

cos⁡\cos
LaTeX command
\cos
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Cosine function, typeset upright as a named math operator like \sin.

\cos appears in the law of cosines c^2 = a^2 + b^2 - 2ab\cos C, in Euler's formula e^{i\theta} = \cos\theta + i\sin\theta, and in the angle form of the dot product, where cosine similarity in machine learning comes from. Typing cos without a backslash gives italic letters and wrong spacing. Write \cos^2\theta for the square of the cosine; \cos\theta^2 means the cosine of theta squared, which is a different quantity. The command takes no argument itself, so group compound arguments with parentheses, as in \cos(\omega t + \phi).

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab \cos C
\documentclass{article}
\begin{document}
Cosine: $\cos$

\[ c^2 = a^2 + b^2 - 2ab \cos C \]
\end{document}

Related symbols

All Goniometrie →

Frequently asked questions

How do I write Cosine in LaTeX?
Type \cos in math mode, for example $c^2 = a^2 + b^2 - 2ab \cos C$. It works in plain LaTeX without loading any package.
Which package do I need for \cos?
None. \cos is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \cos in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\cos$ in running text.
Math poweredSchrijf LaTeX met AI

Beste AI LaTeX Editor, Overleaf Alternatief

Octree helpt onderzoekers van 15+ universiteiten sneller onderzoeksartikelen schrijven met AI

  • Genereer mooie TikZ-diagrammen met AI
  • Upload afbeelding en converteer naadloos naar LaTeX
  • Krijg directe hulp bij het schrijven en opmaken van onderzoeksartikelen