practicecalculus
Exponential and log derivatives

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).

Exponential and log derivatives Updated 2 min read

At a glance

\frac{d}{dx}\,\ln(\cos x) = -\tan x
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
On this page
  1. Step by step with the chain rule
  2. Where ln(cos x) is defined
  3. Graph of ln(cos x) and its derivative
  4. Why this gives the integral of tan x
  5. Logs of other trig functions
  6. Worked examples
  7. Common mistakes

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 together with the 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).
  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 of y = ln(cos x) and its derivative y = −tan x
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.

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 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 it now

Chain rule: trig

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

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.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.