Skip to content
ihateDesmos

Derivative of x cos x

Updated 6 November 2026 · Checked numerically by the ihateDesmos engine
The derivative of x cos x
ddx(xcos(x))=cos(x)−xsin(x)

The derivative of x cos x is cos x − x sin x. The product rule gives two terms, and the minus sign comes from the derivative of cosine.

−55−10100
Open in calculator
y=xcos(x)
in blue and its derivative
y=cos(x)−xsin(x)
in red.

How to find the derivative of x cos x

Method: product rule.

  1. 1
    Use the product rule, with f = x and g = cos x.
  2. 2
    f′ = 1 and g′ = −sin x.
  3. 3
    So the derivative is 1 · cos x + x · (−sin x).
  4. 4
    That is cos x − x sin x.

What it means on the graph

x cos x grows in amplitude as x increases. At x = 0, the slope is exactly 1, which is why the curve looks like y = x near the origin.

In the window shown, the derivative is zero at 8 points in this window. Those are the points where the graph of x cos x has a horizontal tangent.

Table of values

The derivative column uses the formula. The last column estimates the slope directly from the original function, as an independent check.

Values of x cos x and its derivative
xx cos xcos x − x sin xSlope, measured
−ππ−1−1
−π/20−π/2−π/2
0011
π/20−π/2−π/2
π−π−1−1

Second derivative

Differentiating once more gives:

d2dx2(xcos(x))=−2sin(x)−xcos(x)

The second derivative tells you which way the graph bends: positive means it curves upward, and negative means it curves downward.

Common mistakes

  • Dropping the minus sign on the second term.

Frequently asked questions

What is the derivative of x cos x?
The derivative of x cos x is cos x − x sin x.
What is the second derivative of x cos x?
Differentiate cos x − x sin x again to get the second derivative. The result is shown on this page under “Second derivative”.

Keep going

Differentiate any function

Type your own function into the derivative calculator and see every rule applied, step by step.

Open the derivative calculator