Skip to content
Calculus Solver

How to Find the Derivative of a Function (Step-by-Step Guide with Examples)

Finding a derivative is a skill you can learn as a repeatable process. This guide starts with what a derivative means, shows the limit definition once so you know where the rules come from, then gives a step-by-step method that works on any function you'll meet in a first calculus course. Seven fully worked examples follow.

Published:

What the derivative of a function tells you

The derivative of a function f measures how fast f(x) changes as x changes. At any point, it equals the slope of the tangent line to the graph. If f(t) is the position of a car at time t, then f′(t) is its velocity; if C(q) is the cost of producing q items, C′(q) is the marginal cost.

You will see three common notations. They all mean the same thing:

f′(x)dydxddx[f(x)]f'(x) \qquad \frac{dy}{dx} \qquad \frac{d}{dx}\big[f(x)\big]

f′(x) (“f prime of x”) is Lagrange's notation. dy/dx is Leibniz's notation, which is handy when y is defined by an equation such as y = x². The operator d/dx[…] means “take the derivative of what's in the brackets with respect to x”.

Method 1: Find the derivative from the definition

The derivative is defined as a limit of slopes of secant lines, taken as the two points move together:

f′(x)=lim⁡h→0f(x+h)−f(x)hf'(x) = \lim_{h \to 0} \frac{f(x + h) - f(x)}{h}

Using this definition directly is called differentiating “from first principles”. It always follows the same four steps:

  • Step 1: Write out f(x + h) by replacing every x with (x + h).
  • Step 2: Subtract f(x) and simplify. Every term without an h should cancel.
  • Step 3: Divide by h. Factor h out of the numerator first if needed.
  • Step 4: Let h → 0. Whatever is left is f′(x).

Here is the method applied to f(x) = x² + 3x. Step 1:

f(x+h)=(x+h)2+3(x+h)=x2+2xh+h2+3x+3hf(x + h) = (x + h)^{2} + 3(x + h) = x^{2} + 2xh + h^{2} + 3x + 3h

Step 2: subtract f(x) = x² + 3x. The x² and 3x terms cancel:

f(x+h)−f(x)=2xh+h2+3hf(x + h) - f(x) = 2xh + h^{2} + 3h

Steps 3 and 4: divide by h, then let h approach 0:

2xh+h2+3hh=2x+h+3  →  h→0    2x+3\frac{2xh + h^{2} + 3h}{h} = 2x + h + 3 \;\xrightarrow{\;h \to 0\;}\; 2x + 3

So f′(x) = 2x + 3. This method is worth doing a few times, because it shows why the rules work. In practice, though, nobody uses it for every problem: the differentiation rules below give the same answers in a fraction of the time.

Method 2: A step-by-step process using the rules

This six-step process handles every function built from powers, roots, exponentials, logarithms and trig functions:

  • Step 1: Rewrite. Turn roots and fractions into powers (√x = x^(1/2), 3/x² = 3x^(−2)) and simplify anything that can be simplified.
  • Step 2: Find the outermost operation. Ask what the last thing you'd do is if you evaluated the function by hand: add, multiply, divide, raise to a power, or apply a function such as sin.
  • Step 3: Apply the rule that matches that operation (see the table below).
  • Step 4: Repeat for the inner pieces. Each rule leaves you with smaller derivatives to find; handle them the same way.
  • Step 5: Simplify. Collect like terms, factor where it helps, and write the answer neatly.
  • Step 6: Check. Plug in a value, or compare with a numerical estimate or a calculator.

Step 2 is where most mistakes happen. In sin(x²), the last operation is taking the sine, so the chain rule comes first. In x²·sin(x), the last operation is multiplying, so the product rule comes first.

Which differentiation rule should you use?

Choosing a differentiation rule from the form of the function
The function looks likeRuleDerivative
c (a constant)c \text{ (a constant)}Constant rule\text{Constant rule}00
xnx^{n}Power rule\text{Power rule}nxn−1n x^{n-1}
c f(x)c\,f(x)Constant multiple\text{Constant multiple}c f′(x)c\,f'(x)
f(x)±g(x)f(x) \pm g(x)Sum / difference\text{Sum / difference}f′(x)±g′(x)f'(x) \pm g'(x)
f(x) g(x)f(x)\,g(x)Product rule\text{Product rule}f′g+fg′f'g + fg'
f(x)g(x)\dfrac{f(x)}{g(x)}Quotient rule\text{Quotient rule}f′g−fg′g2\dfrac{f'g - fg'}{g^{2}}
f(g(x))f\big(g(x)\big)Chain rule\text{Chain rule}f′(g(x)) g′(x)f'\big(g(x)\big)\,g'(x)
ex, ln⁡xe^{x},\ \ln xExponential, log\text{Exponential, log}ex, 1xe^{x},\ \dfrac{1}{x}
sin⁡x, cos⁡x\sin x,\ \cos xTrig\text{Trig}cos⁡x, −sin⁡x\cos x,\ -\sin x
u(x)v(x)u(x)^{v(x)}Logarithmic differentiation\text{Logarithmic differentiation}uv(v′ln⁡u+v u′u)u^{v}\left(v'\ln u + \dfrac{v\,u'}{u}\right)

For each rule explained in detail, with its own examples and the derivatives of every trig and inverse trig function, see our guide to derivative rules.

Rewrite before you differentiate

A minute spent rewriting often turns a quotient rule or chain rule problem into a simple power rule problem. These rewrites come up constantly:

x=x1/21x3=x−34x=4x−1/2x2+xx=x+1 (x≠0)ln⁡(x3)=3ln⁡x (x>0)\sqrt{x} = x^{1/2} \qquad \frac{1}{x^{3}} = x^{-3} \qquad \frac{4}{\sqrt{x}} = 4x^{-1/2} \qquad \frac{x^{2} + x}{x} = x + 1 \ (x \neq 0) \qquad \ln\left(x^{3}\right) = 3\ln x \ (x > 0)

For example, d/dx[1/x³] by the quotient rule takes several lines. Rewritten as x^(−3), the power rule gives −3x^(−4) = −3/x⁴ immediately.

Finding the derivative at a point (and the tangent line)

To find the slope at a specific point, find f′(x) first, then substitute. Never substitute first: f(2) is a constant, and the derivative of a constant is 0. Take f(x) = x³ − 2x at x = 2:

f′(x)=3x2−2⇒f′(2)=3(4)−2=10f'(x) = 3x^{2} - 2 \quad\Rightarrow\quad f'(2) = 3(4) - 2 = 10

The slope of the graph at x = 2 is 10. Since f(2) = 8 − 4 = 4, the tangent line passes through (2, 4), and point–slope form gives its equation:

y−4=10(x−2)⟹y=10x−16y - 4 = 10(x - 2) \quad\Longrightarrow\quad y = 10x - 16

Second and higher-order derivatives

The second derivative f″(x) is the derivative of f′(x). It measures how the slope itself is changing: f″ > 0 means the graph curves upward (concave up), and for a position function, f″ is acceleration. To find it, simply differentiate the simplified first derivative again.

f′′(x)=d2ydx2=ddx[f′(x)]f''(x) = \frac{d^{2}y}{dx^{2}} = \frac{d}{dx}\big[f'(x)\big]

Simplify f′(x) fully before differentiating again; it makes the second step much shorter. Third and higher derivatives work the same way.

The second derivative is also how you tell a local maximum from a local minimum. To find and classify those points for any function, use the critical points calculator.

How to check your derivative

A quick numerical check catches most mistakes. Pick a value such as x = 1 and compute the symmetric difference quotient with a small step, for example h = 0.001:

f′(1)≈f(1.001)−f(0.999)0.002f'(1) \approx \frac{f(1.001) - f(0.999)}{0.002}

For f(x) = x² + 3x, this gives (4.005001 − 3.995001) / 0.002 = 5.000, which matches f′(1) = 2(1) + 3 = 5. If the two numbers disagree, recheck your work. You can also graph f and f′ together: wherever f is increasing, f′ should be positive, and wherever f has a peak or valley, f′ should be zero.

To compare every step with your own working, enter the function in the derivative calculator.

Common mistakes to avoid

  • Stopping the chain rule too early: d/dx[cos(5x)] is −5 sin(5x), not −sin(5x).
  • Differentiating a product factor by factor: d/dx[x·eˣ] is eˣ + x·eˣ, not 1·eˣ.
  • Swapping the quotient rule numerator: it is f′g − fg′, in that order.
  • Using the power rule on exponentials: d/dx[2ˣ] is 2ˣ ln 2, not x·2ˣ⁻¹. The power rule needs the variable in the base, not the exponent.
  • Substituting a number before differentiating, which always gives 0.
  • Forgetting that the derivative of a constant, including π, e and ln 2, is 0.

Worked examples

Example 1

Power rule after rewriting

ddx(4x3−2x+5x)\frac{d}{dx}\left(4x^{3} - \frac{2}{x} + 5\sqrt{x}\right)
  1. Rewrite every term as a power of x.

    4x3−2x−1+5x1/24x^{3} - 2x^{-1} + 5x^{1/2}
  2. Apply the power rule term by term.

    12x2+2x−2+52x−1/212x^{2} + 2x^{-2} + \frac{5}{2}x^{-1/2}
  3. Rewrite the negative and fractional powers.

Answer

12x2+2x2+52x12x^{2} + \frac{2}{x^{2}} + \frac{5}{2\sqrt{x}}

Example 2

Product rule

ddx[(x2+1)sin⁡x]\frac{d}{dx}\Big[\left(x^{2} + 1\right)\sin x\Big]
  1. The outermost operation is multiplication. Let f = x² + 1 and g = sin x, so f′ = 2x and g′ = cos x.

  2. Apply (fg)′ = f′g + fg′.

    2xsin⁡x+(x2+1)cos⁡x2x\sin x + \left(x^{2} + 1\right)\cos x

Answer

2xsin⁡x+(x2+1)cos⁡x2x\sin x + \left(x^{2} + 1\right)\cos x

Example 3

Quotient rule

ddx 3x−1x2+1\frac{d}{dx}\,\frac{3x - 1}{x^{2} + 1}
  1. Top f = 3x − 1, so f′ = 3. Bottom g = x² + 1, so g′ = 2x.

    3(x2+1)−(3x−1)(2x)(x2+1)2\frac{3\left(x^{2} + 1\right) - (3x - 1)(2x)}{\left(x^{2} + 1\right)^{2}}
  2. Expand the numerator: 3x² + 3 − 6x² + 2x = −3x² + 2x + 3.

Answer

−3x2+2x+3(x2+1)2\frac{-3x^{2} + 2x + 3}{\left(x^{2} + 1\right)^{2}}

Example 4

Chain rule

ddx(2x2−5)4\frac{d}{dx}\left(2x^{2} - 5\right)^{4}
  1. The outermost operation is raising to the 4th power. The inner function is u = 2x² − 5, with u′ = 4x.

  2. Power rule on the outside, times the derivative of the inside.

    4(2x2−5)3⋅4x4\left(2x^{2} - 5\right)^{3}\cdot 4x

Answer

16x(2x2−5)316x\left(2x^{2} - 5\right)^{3}

Example 5

Product rule and chain rule together

ddx[e2xcos⁡(3x)]\frac{d}{dx}\Big[e^{2x}\cos(3x)\Big]
  1. Product rule first. Each factor then needs the chain rule: (e^(2x))′ = 2e^(2x) and (cos 3x)′ = −3 sin 3x.

    2e2xcos⁡(3x)+e2x⋅(−3sin⁡(3x))2e^{2x}\cos(3x) + e^{2x}\cdot\big(-3\sin(3x)\big)
  2. Factor out e^(2x).

Answer

e2x(2cos⁡(3x)−3sin⁡(3x))e^{2x}\big(2\cos(3x) - 3\sin(3x)\big)

Example 6

Logarithmic differentiation

ddx xsin⁡x\frac{d}{dx}\,x^{\sin x}
  1. The variable is in both the base and the exponent, so take logs: if y = x^(sin x), then ln y = sin x · ln x.

  2. Differentiate both sides (product rule on the right):

    y′y=cos⁡x ln⁡x+sin⁡xx\frac{y'}{y} = \cos x\,\ln x + \frac{\sin x}{x}
  3. Multiply both sides by y = x^(sin x).

Answer

xsin⁡x(cos⁡x ln⁡x+sin⁡xx)x^{\sin x}\left(\cos x\,\ln x + \frac{\sin x}{x}\right)

Example 7

Second derivative

d2dx2(x4−3x2+ln⁡x)\frac{d^{2}}{dx^{2}}\left(x^{4} - 3x^{2} + \ln x\right)
  1. First derivative:

    f′(x)=4x3−6x+1xf'(x) = 4x^{3} - 6x + \frac{1}{x}
  2. Differentiate again. Rewrite 1/x as x^(−1), whose derivative is −x^(−2).

    f′′(x)=12x2−6−1x2f''(x) = 12x^{2} - 6 - \frac{1}{x^{2}}

Answer

12x2−6−1x212x^{2} - 6 - \frac{1}{x^{2}}

Questions about this topic

What is the easiest way to find the derivative of a function?

Rewrite the function using powers, identify its outermost operation, and apply the matching rule: power, product, quotient or chain. Repeat for the inner pieces, then simplify. With practice, most derivatives take only a few lines.

Do I need to use the limit definition every time?

No. The limit definition explains what a derivative is and is often required on a test when the question says “from first principles” or “using the definition”. Otherwise, use the differentiation rules, which are derived from the definition and give the same answers faster.

Is f′(x) the same as dy/dx?

Yes. If y = f(x), then f′(x) and dy/dx are two notations for the same derivative. Leibniz's dy/dx is convenient for the chain rule and related rates; f′(x) is shorter when you need to evaluate at a point, as in f′(2).

How do I know when to use the chain rule?

Use the chain rule whenever a function is applied to something other than plain x: sin(3x), e^(x²), (x² + 1)⁵ or ln(cos x). If you'd write parentheses with more than just x inside, you almost certainly need it.

Can a function fail to have a derivative?

Yes, at specific points. |x| has a sharp corner at x = 0, the cube root of x has a vertical tangent at 0, and any function with a jump or hole has no derivative there. Everywhere else, these functions can still be differentiated normally.

Practice what you learned

Try the worked examples above in the calculator and compare each step with your own. You can also use the main Calculus Solver for every operation in one place.

Check your answers with the Derivative Calculator