Skip to content
Derivative Calculator
Resources

Chain rule and parentheses: read the expression first

−x^2 and (−x)^2 look similar in a short line of text, but their derivatives have opposite signs. I resolve that distinction before applying any differentiation rule. In the first expression, the power acts on x and the minus acts on the result. In the second, the parenthesized negative quantity is the base of the power. A calculator can only differentiate the expression it actually parsed.

What is the derivative of −x² compared with (−x)²?

At x = 2, the first function is −4 and has slope −4. The second function is 4 and has slope 4. The inputs differ by two parentheses, not by a small rounding choice. If your expected answer disagrees by a sign, inspect the parsed function before adding more parentheses at random or switching the derivative order.

Enter −x^2 in the derivative calculator, then compare it with (−x)^2. The parsed-function panel makes grouping visible. I also look at the function graph: a downward parabola and an upward parabola give an immediate independent clue about which expression was entered. The graph is a useful check on the notation, although it is not a proof of the derivative.

How do I apply the chain rule to a composite function?

For a composite function f(g(x)), the chain rule is f′(g(x))*g′(x). The factor g′(x) measures how fast the input to the outer function changes. Omitting it is the common mistake that turns a correct derivative rule into a wrong answer. I identify the final operation performed on the input, then work inward one layer at a time.

For sin(x^2), the outer operation is sine and the inner expression is x^2. Differentiate sine to cosine while keeping its argument; then multiply by 2*x. The result is cos(x^2)*2*x. At x = 0.5, the argument is 0.25 radians, the inner derivative is 1 and the derivative value is approximately 0.9689124217.

For sin(3*x^2+1), the outer step is unchanged, but the inner derivative is 6*x. The answer is cos(3*x^2+1)*6*x. Substituting x = 0 makes the derivative zero because the inner expression is momentarily stationary, even though cosine itself is not zero there. I use this kind of point check to catch a forgotten chain factor.

How do I differentiate a logarithm of a function?

Consider ln(x^2+1). The derivative of ln(u) is u′/u where u is positive. Here u = x^2+1 and u′ = 2*x, so the answer is (2*x)/(x^2+1). The argument is positive for every real x. At x = 2, the derivative is 4/5, or 0.8. Writing only 1/(x^2+1) would account for the outer logarithm and miss the changing argument.

Now compare ln(x^2−1). The same formal pattern gives (2*x)/(x^2−1), but the original real function exists only where x^2−1 > 0: x < −1 or x > 1. The denominator condition alone is weaker. It would wrongly allow points between −1 and 1, where the logarithm has a negative argument.

In this calculator, ln and log both mean natural logarithms. Log10 uses base ten and introduces the factor ln(10) in the denominator. For log10(2*x), the derivative is 2/(2*x*ln(10)), which simplifies to 1/(x*ln(10)) only on the original domain x > 0. I keep the base and the domain next to the symbolic answer.

How do I combine the product, quotient and chain rules?

In x*sin(x^2), the final operation is multiplication. Apply the product rule first: 1*sin(x^2) + x*(cos(x^2)*2*x). The second term contains its own chain rule. The result can be written sin(x^2) + 2*x^2*cos(x^2). Trying to treat the entire expression as a single sine would lose the independent factor x.

For sin(x)/x, the quotient rule gives (x*cos(x)−sin(x))/x^2 on x ≠ 0. Dividing the derivatives, cos(x)/1, is not the quotient rule. At x = 2, the numerator is about −1.74159110 and the slope is approximately −0.435397775. The original denominator prevents evaluation at zero even though a related continuously extended function can be studied there.

A quotient inside a logarithm requires both rules. For ln((x+1)/(x−1)), you can differentiate the inner quotient and divide by it, then simplify with care. Before doing any of that, require (x+1)/(x−1) > 0 and x ≠ 1. This gives x < −1 or x > 1. I establish those intervals before using a graph to examine the formula.

Is sqrt(x²) equal to x or abs(x)?

The expression (x^2)^0.5 demonstrates why apparently harmless algebra can erase a real branch. The square root returns the nonnegative root, so sqrt(x^2) equals abs(x). It agrees with x for positive inputs and with −x for negative inputs. Its derivative is therefore 1 for x > 0 and −1 for x < 0; at zero there is a cusp.

At x = −2, the original function value is 2. The chain calculation gives 0.5*(x^2)^−0.5*(2*x), which evaluates to −1. The calculator can also use the real identity sqrt(x^2) = abs(x) before differentiating; it names that step explicitly. Flattening the exponents to x^(2*0.5) would produce x and a derivative of 1. That shortcut changes both the value and the slope on the negative side, so the engine only rewrites powers when the identity preserves the real branch.

Not every expression with a fractional power is supported as a real root on negative inputs. The numerical evaluator does not reinterpret a negative base raised to a noninteger power as a signed cube root. A symbolic rule and a real evaluation convention are different decisions. If your problem relies on such roots, state the real-root convention and analyze the domain outside this tool.

Nested square and square root with positive and negative branches
The square root of x squared is the absolute value, with different slopes on either side of zero.

How do I check that I entered the right expression?

I use the following sequence when a derivative seems surprising. It keeps notation, calculus and numerical evidence separate, so a graph or a decimal value does not hide a parsing mistake. Repeating the sequence is usually faster than comparing two long formulas character by character.

After obtaining the derivative, choose a point well inside the domain and compare its first-derivative value with forward and centered slopes. For x^2 at a = 2, h = 0.1 gives 4.1 and 4 respectively, against the exact slope 4. Changing h helps reveal truncation error. Reducing h excessively can instead introduce cancellation error; a smaller interval is not automatically a better test.

The OpenStax chain-rule chapter develops the composition rule used here. For the separate issues of a tangent, a secant and an undefined point, continue with Tangents, secants and real-domain restrictions. Keep the original expression in your notes alongside every simplified derivative. For repeated differentiation or functions with parameters, read Higher and partial derivatives.

  1. Inspect the original expression and its grouping.
  2. Identify the real domain and assign any parameters.
  3. Apply the appropriate rules, including every chain factor.
  4. Evaluate the function and first derivative at a valid point.
  5. Compare one-sided and centered changes without treating them as proof.
FunctionFirst derivativeOriginal real domain
sin(x^2)2*x*cos(x^2)All real x
ln(x^2+1)2*x/(x^2+1)All real x
(x^2)^0.5−1 or 1All real x; derivative excludes zero

Quick answers

Why is −x^2 different from (−x)^2?

The power is evaluated before a leading minus. In (−x)^2 the minus is inside the base, so the function and derivative have the opposite signs.

What is the missing factor in the chain rule?

For f(g(x)), multiply the derivative of the outer function evaluated at g(x) by g′(x). For sin(x^2), that extra factor is 2*x.

Can I rewrite sqrt(x^2) as x?

Only when x is nonnegative. For all real x, the correct expression is abs(x), and its derivative does not exist at zero.

Use the derivative calculator now

Keep reading