# Integral of cot x: Formula, Derivation and Examples

> The integral of cot x is ln|sin x| + C. See the u-substitution with u = sin x, how it pairs with tan x, plus cot(ax), cot² x and definite integral examples.

Source: https://practicecalculus.com/integrals/cot-x
Updated: 2026-11-06

$$ \int \cot x\,dx = \ln\lvert\sin x\rvert + C $$

## At a glance

- **Antiderivative:** $\ln\lvert\sin x\rvert + C$
- **Equivalent form:** $-\ln\lvert\csc x\rvert + C$
- **Method:** Rewrite as $\dfrac{\cos x}{\sin x}$, then $u = \sin x$
- **Linear form:** $\int\cot(ax)\,dx = \dfrac{1}{a}\ln\lvert\sin(ax)\rvert + C$
- **Check:** $\dfrac{d}{dx}\ln\lvert\sin x\rvert = \cot x$

## Key takeaways

- The integral of $\cot x$ is $\ln\lvert\sin x\rvert + C$.
- Write $\cot x = \frac{\cos x}{\sin x}$. The top is the derivative of the bottom, so the answer is a log.
- Unlike $\tan x$, there is no minus sign: the derivative of $\sin x$ is $+\cos x$.
- It is not $-\csc^2 x$. That is the derivative of $\cot x$.

The **integral of $\cot x$ is $\ln\lvert\sin x\rvert + C$**. It comes from one substitution and is the mirror image of the [integral of tan x](/integrals/tan-x).

$$\int \cot x\,dx = \ln\lvert\sin x\rvert + C$$

## Graph of cot x and its antiderivative

```graph
title: 'Area under y = cot x from π/6 to π/2, with the antiderivative y = ln|sin x|'
caption: 'The shaded area is $\ln 2 \approx 0.693$. The dashed antiderivative reaches its maximum of $0$ at $x = \frac{\pi}{2}$, exactly where $\cot x$ crosses zero.'
x: [-0.2, 3.4]
y: [-3, 4]
functions:
  - expr: cot(x)
    label: y = cot x
    domain: [0.25, 2.9]
  - expr: ln(abs(sin(x)))
    label: y = ln|sin x| (antiderivative)
    dashed: true
    domain: [0.05, 3.09]
shade: {expr: cot(x), from: 0.5236, to: 1.5708}
points:
  - [1.5708, 0, '(π/2, 0)']
```

## Derivation, step by step

1. Rewrite: $\displaystyle\int\cot x\,dx = \int\frac{\cos x}{\sin x}\,dx$.
2. Let $u = \sin x$. Then $du = \cos x\,dx$.
3. Substitute: $\displaystyle\int\frac{du}{u} = \ln\lvert u\rvert + C$.
4. Put $u = \sin x$ back: $\ln\lvert\sin x\rvert + C$.

Step 3 is the [integral of 1/x](/integrals/1-over-x). Because $\ln\lvert\sin x\rvert = -\ln\lvert\csc x\rvert$, some books write the answer as $-\ln\lvert\csc x\rvert + C$. It is the same function.

## Check by differentiating

$$\frac{d}{dx}\ln\lvert\sin x\rvert = \frac{\cos x}{\sin x} = \cot x \checkmark$$

The forward direction is different: the [derivative of cot x](/derivatives/cot-x) is $-\csc^2 x$.

## Comparing tan and cot

| | $\tan x$ | $\cot x$ |
| --- | --- | --- |
| Rewrite | $\frac{\sin x}{\cos x}$ | $\frac{\cos x}{\sin x}$ |
| Substitution | $u = \cos x$, $du = -\sin x\,dx$ | $u = \sin x$, $du = \cos x\,dx$ |
| Integral | $-\ln\lvert\cos x\rvert + C$ | $\ln\lvert\sin x\rvert + C$ |
| Derivative | $\sec^2 x$ | $-\csc^2 x$ |

The minus sign shows up for $\tan x$ but not for $\cot x$, because $\cos x$ differentiates to $-\sin x$ while $\sin x$ differentiates to $+\cos x$.

## Definite integrals

$$\int_{\pi/6}^{\pi/2}\cot x\,dx = \ln 1 - \ln\frac{1}{2} = \ln 2$$

$$\int_{\pi/4}^{\pi/2}\cot x\,dx = 0 - \ln\frac{\sqrt{2}}{2} = \frac{1}{2}\ln 2$$

Starting at $x = 0$ gives a divergent improper integral, since $\ln\sin x \to -\infty$ as $x \to 0^+$.

## Substitution variants

$$\int\cot(ax + b)\,dx = \frac{1}{a}\ln\lvert\sin(ax + b)\rvert + C$$

**Example 1.** $\int\cot(4x)\,dx = \frac{1}{4}\ln\lvert\sin 4x\rvert + C$.

**Example 2.** $\int x\cot(x^2)\,dx = \frac{1}{2}\ln\lvert\sin(x^2)\rvert + C$, with $u = x^2$.

**Example 3: cot squared.** Use $\cot^2 x = \csc^2 x - 1$:

$$\int\cot^2 x\,dx = \int(\csc^2 x - 1)\,dx = -\cot x - x + C$$

Check: $\frac{d}{dx}(-\cot x - x) = \csc^2 x - 1 = \cot^2 x$.

**Example 4: a hidden cot.** $\int\frac{\cos x}{3\sin x + 2}\,dx = \frac{1}{3}\ln\lvert 3\sin x + 2\rvert + C$, with $u = 3\sin x + 2$.

## Common mistakes

1. **Answering $-\csc^2 x$.** That is the derivative of $\cot x$.
2. **Adding a minus sign by analogy with $\tan x$.** $-\ln\lvert\sin x\rvert$ has derivative $-\cot x$.
3. **Answering $\ln\lvert\cos x\rvert$.** The log goes on the denominator of $\frac{\cos x}{\sin x}$, which is $\sin x$.
4. **Dropping the absolute value.** $\sin x < 0$ on $(\pi, 2\pi)$.

Practise with [u-substitution problems](/practice-problems/u-substitution).

## Frequently asked questions

### What is the integral of cot x?

The integral of $\cot x$ is $\ln\lvert\sin x\rvert + C$.

### What is the integral of cos x / sin x?

That is $\cot x$, so the integral is $\ln\lvert\sin x\rvert + C$.

### What is the integral of cot(2x)?

It is $\frac{1}{2}\ln\lvert\sin 2x\rvert + C$.

### What is the integral of cot x from π/6 to π/2?

It is $\ln\sin\frac{\pi}{2} - \ln\sin\frac{\pi}{6} = 0 - \ln\frac{1}{2} = \ln 2 \approx 0.693$.
