# Derivative of ln(cos x): Formula, Steps and Examples

> The derivative of ln(cos x) is −tan x. See the chain rule steps, why it explains the integral of tan x, a graph, and ln(sin x) and ln(sec x).

Source: https://practicecalculus.com/derivatives/ln-cos-x
Updated: 2026-11-06

$$ \frac{d}{dx}\,\ln(\cos x) = -\tan x $$

## At a glance

- **Derivative:** $-\tan x$ where $\cos x > 0$
- **Second derivative:** $-\sec^2 x$
- **With absolute value:** $\dfrac{d}{dx}\ln\lvert\cos x\rvert = -\tan x$ where $\cos x \ne 0$
- **Related integral:** $\int\tan x\,dx = -\ln\lvert\cos x\rvert + C$
- **Companion:** $\dfrac{d}{dx}\ln(\sin x) = \cot x$

## Key takeaways

- The derivative of $\ln(\cos x)$ is $\frac{-\sin x}{\cos x} = -\tan x$.
- It follows the log chain rule: the derivative of the inside over the inside.
- Read backwards, it gives the standard integral $\int\tan x\,dx = -\ln\lvert\cos x\rvert + C = \ln\lvert\sec x\rvert + C$.
- $\ln(\cos x)$ is only defined where $\cos x > 0$, such as $-\frac{\pi}{2} < x < \frac{\pi}{2}$.

The **derivative of $\ln(\cos x)$ is $-\tan x$**. It is a short chain rule calculation, and it is the reason the integral of $\tan x$ involves a log.

$$\frac{d}{dx}\,\ln(\cos x) = -\tan x$$

## Step by step with the chain rule

For a log of a function, the [derivative of ln x](/derivatives/ln-x) together with the [chain rule](/rules/chain-rule) gives $\frac{d}{dx}\ln u = \frac{u'}{u}$. Here $u = \cos x$:

1. The inside is $u = \cos x$.
2. Its derivative is $u' = -\sin x$ (see the [derivative of cos x](/derivatives/cos-x)).
3. Divide: $\frac{u'}{u} = \frac{-\sin x}{\cos x} = -\tan x$.

## Where ln(cos x) is defined

A log only accepts positive inputs, so $\ln(\cos x)$ exists only where $\cos x > 0$. That is the interval $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$ and its copies shifted by $2\pi$. Where $\cos x < 0$, use $\ln\lvert\cos x\rvert$ instead. It has the same derivative, $-\tan x$, wherever $\cos x \ne 0$.

## Graph of ln(cos x) and its derivative

```graph
title: 'Graph of y = ln(cos x) and its derivative y = −tan x'
caption: 'The curve peaks at $(0, 0)$, where the slope $-\tan 0 = 0$. It drops toward $-\infty$ near $x = \pm\frac{\pi}{2}$, where $\cos x \to 0$.'
x: [-2, 2]
y: [-4, 4]
functions:
  - expr: ln(cos(x))
    label: y = ln(cos x)
    domain: [-1.5, 1.5]
  - expr: -tan(x)
    label: y = −tan x (derivative)
    dashed: true
    domain: [-1.3, 1.3]
points:
  - [0, 0, 'maximum (0, 0)']
```

Since $\cos x \le 1$, $\ln(\cos x) \le 0$, with the maximum value $0$ at $x = 0$. The second derivative is $-\sec^2 x$, which is always negative, so the graph is concave down everywhere it exists.

## Why this gives the integral of tan x

Flip the result around. Since $\frac{d}{dx}\ln\lvert\cos x\rvert = -\tan x$,

$$\int\tan x\,dx = -\ln\lvert\cos x\rvert + C = \ln\lvert\sec x\rvert + C$$

The two forms are equal because $-\ln\lvert\cos x\rvert = \ln\frac{1}{\lvert\cos x\rvert}$. The full method, with u-substitution, is on the [integral of tan x](/integrals/tan-x) page.

## Logs of other trig functions

| Function | Derivative |
| --- | --- |
| $\ln(\cos x)$ | $-\tan x$ |
| $\ln(\sin x)$ | $\cot x$ |
| $\ln(\sec x)$ | $\tan x$ |
| $\ln(\tan x)$ | $\frac{\sec^2 x}{\tan x} = \frac{1}{\sin x\cos x}$ |
| $\ln(\sec x + \tan x)$ | $\sec x$ |

The last row is the famous one behind $\int\sec x\,dx = \ln\lvert\sec x + \tan x\rvert + C$. Check it: the derivative of the inside is $\sec x\tan x + \sec^2 x = \sec x(\tan x + \sec x)$, and dividing by $\sec x + \tan x$ leaves $\sec x$.

## Worked examples

**Example 1.** $\frac{d}{dx}\ln(\cos 2x) = \frac{-2\sin 2x}{\cos 2x} = -2\tan 2x$.

**Example 2.** $\frac{d}{dx}\ln(\cos^2 x) = \frac{d}{dx}2\ln(\cos x) = -2\tan x$.

**Example 3: tangent line.** At $x = \frac{\pi}{4}$, $\ln\left(\cos\frac{\pi}{4}\right) = \ln\frac{\sqrt{2}}{2} = -\frac{\ln 2}{2} \approx -0.347$, and the slope is $-\tan\frac{\pi}{4} = -1$. The tangent line is $y = -\frac{\ln 2}{2} - \left(x - \frac{\pi}{4}\right)$.

## Common mistakes

1. **Writing $\frac{1}{\cos x}$.** That is $\sec x$, and it forgets the inside derivative $-\sin x$.
2. **Losing the minus sign.** The derivative of $\cos x$ is $-\sin x$, so the answer is $-\tan x$, not $\tan x$.
3. **Writing $-\frac{1}{\sin x}$.** You inverted the inside derivative instead of dividing by the inside.

Practise more trig chain rule problems with [derivatives of trig functions](/practice-problems/derivatives-of-trig-functions).

## Frequently asked questions

### What is the derivative of ln(cos x)?

The derivative of $\ln(\cos x)$ is $-\tan x$.

### What is the derivative of ln(sin x)?

It is $\frac{\cos x}{\sin x} = \cot x$, valid where $\sin x > 0$.

### What is the derivative of ln(sec x)?

It is $\frac{\sec x\tan x}{\sec x} = \tan x$. This matches the fact that $\ln(\sec x) = -\ln(\cos x)$.

### What is the derivative of ln(cos 2x)?

The inside derivative is $-2\sin 2x$, so the answer is $\frac{-2\sin 2x}{\cos 2x} = -2\tan 2x$.
