Class 12 Maths, Worked in Full Past papersGet updates
Chapter 5 · Continuity and Differentiability

Exercise 5.5 · Q10: Differentiate xxcos⁡x+x2+1x2−1x^{x\cos x}+\frac{x^2+1}{x^2-1}

Exercise 5.5Logarithmic differentiation · Section 5.5
The question

Differentiate the following function w.r.t. xx⁠:

xxcos⁡x+x2+1x2−1.x^{x\cos x} + \frac{x^2+1}{x^2-1}.
Exam answer

Let y=u+vy = u + v⁠, where u=xxcos⁡xu = x^{x\cos x} and v=x2+1x2−1v = \frac{x^2 + 1}{x^2 - 1}⁠. Then dydx=dudx+dvdx\frac{dy}{dx} = \frac{du}{dx} + \frac{dv}{dx}⁠.

Taking log on both sides of u=xxcos⁡xu = x^{x\cos x}⁠,

log⁡u=xcos⁡xlog⁡x\log u = x\cos x\log x

Differentiating both sides w.r.t. xx⁠,

1ududx=(cos⁡x−xsin⁡x)log⁡x+xcos⁡x⋅1x=cos⁡x (1+log⁡x)−xsin⁡xlog⁡x∴ dudx=xxcos⁡x[cos⁡x (1+log⁡x)−xsin⁡xlog⁡x]\begin{aligned} \frac1u\frac{du}{dx} &= (\cos x - x\sin x)\log x \\ &\qquad + x\cos x\cdot\frac1x \\ &= \cos x\,(1 + \log x) \\ &\qquad - x\sin x\log x \\ \therefore\ \frac{du}{dx} &= x^{x\cos x}\big[\cos x\,(1 + \log x) \\ &\qquad - x\sin x\log x\big] \end{aligned}

By the quotient rule,

dvdx=2x(x2−1)−(x2+1)2x(x2−1)2=−4x(x2−1)2\begin{aligned} \frac{dv}{dx} &= \frac{2x(x^2 - 1) - (x^2 + 1)2x}{(x^2 - 1)^2} \\ &= \frac{-4x}{(x^2 - 1)^2} \end{aligned}

Hence, for x>0x > 0⁠, x≠1x \ne 1⁠, dydx=xxcos⁡x[cos⁡x (1+log⁡x)−xsin⁡xlog⁡x]−4x(x2−1)2\begin{aligned} \dfrac{dy}{dx} &= x^{x\cos x}\big[\cos x\,(1 + \log x) \\ &\qquad - x\sin x\log x\big] \\ &\quad - \dfrac{4x}{(x^2 - 1)^2} \end{aligned}

Want the reason behind every step, the basics and the checks?

The one idea this problem is built on

The function is a sum of two different kinds of term. The first, xxcos⁡xx^{x\cos x}⁠, has a variable base and a variable exponent, so it needs logarithmic differentiation. The second is an ordinary quotient. Logarithms do not split sums, so we never take the log of the whole function: we differentiate each term on its own and add.

Given, to find, and the plan
Given
y=xxcos⁡x+x2+1x2−1y = x^{x\cos x} + \dfrac{x^2+1}{x^2-1}⁠.
To find
dydx\frac{dy}{dx}⁠, and where the formula holds.
Plan
(1) Find where yy is defined and split it as y=u+vy = u + v⁠. (2) Take logs of uu only. (3) Differentiate log⁡u\log u⁠. (4) Get dudx\frac{du}{dx}⁠. (5) Find dvdx\frac{dv}{dx} by the quotient rule. (6) Add.

Basics you need

1Logarithmic differentiation

If u>0u > 0⁠, then ddxlog⁡u=1ududx\frac{d}{dx}\log u = \frac1u\frac{du}{dx}⁠, so dudx=u⋅ddx(log⁡u)\frac{du}{dx} = u\cdot\frac{d}{dx}(\log u)⁠. The book stresses that the function and its base must be positive, "as otherwise their logarithms are not defined" (Section 5.5). Basics: exponentials and logarithms

2Product and quotient rules

(fg)′=f′g+fg′(fg)' = f'g + fg' and (fg)′=f′g−fg′g2\left(\frac{f}{g}\right)' = \frac{f'g - fg'}{g^2} where g≠0g \ne 0 (Section 5.3). Basics: derivative rules

3Standard derivatives

(cos⁡x)′=−sin⁡x(\cos x)' = -\sin x (Table 5.3), (log⁡x)′=1x(\log x)' = \frac1x (Theorem 5), (xn)′=nxn−1(x^n)' = nx^{n-1}⁠. Basics: derivative rules

Solution

  1. Where is the function defined? Split it into two terms

    Put

    u=xxcos⁡x,v=x2+1x2−1,u = x^{x\cos x}, \qquad v = \frac{x^2+1}{x^2-1},

    so y=u+vy = u + v⁠. The power uu has the variable exponent xcos⁡xx\cos x⁠, so its base must be positive: x>0x > 0⁠. The fraction vv needs x2−1≠0x^2 - 1 \ne 0⁠, that is x≠1x \ne 1 and x≠−1x \ne -1⁠. Together:

    x>0,x≠1.x > 0, \quad x \ne 1.

    On this set u>0u > 0⁠. By the sum rule, dydx=dudx+dvdx\frac{dy}{dx} = \frac{du}{dx} + \frac{dv}{dx}⁠.

    A power such as xxcos⁡xx^{x\cos x} with a non-integer, varying exponent is only defined (in this chapter) for a positive base; Section 5.5 says u(x)u(x) "must always be positive". We split the sum because log⁡(u+v)\log(u + v) cannot be broken into simpler pieces: the log laws handle products, quotients and powers, never sums.
    Sum rule (u+v)′=u′+v′(u + v)' = u' + v' (Section 5.3); positivity requirement (Section 5.5). Lesson: logarithmic differentiation
  2. Take logarithms of uu

    For x>0x > 0⁠, u>0u > 0⁠, and the law log⁡pn=nlog⁡p\log p^n = n\log p gives

    log⁡u=xcos⁡x⋅log⁡x.\log u = x\cos x\cdot\log x.
    The log brings the awkward exponent xcos⁡xx\cos x down as an ordinary factor. The right side is now a product of three familiar functions, xx⁠, cos⁡x\cos x and log⁡x\log x⁠, which the product rule can handle.
    log⁡bpn=nlog⁡bp\log_b p^n = n\log_b p (Section 5.4). Basics: exponentials and logarithms
  3. Differentiate both sides

    Left side: by the chain rule (outer log⁡\log⁠, inner uu⁠), ddxlog⁡u=1ududx\frac{d}{dx}\log u = \frac1u\frac{du}{dx}⁠.

    Right side: treat it as (xcos⁡x)⋅log⁡x(x\cos x)\cdot\log x⁠. First, by the product rule,

    ddx(xcos⁡x)=1⋅cos⁡x+x(−sin⁡x)=cos⁡x−xsin⁡x.\begin{aligned} \frac{d}{dx}(x\cos x) &= 1\cdot\cos x + x(-\sin x) \\ &= \cos x - x\sin x. \end{aligned}

    Then, by the product rule again,

    ddx[(xcos⁡x)log⁡x]=(cos⁡x−xsin⁡x)log⁡x+xcos⁡x⋅1x=cos⁡xlog⁡x−xsin⁡xlog⁡x+cos⁡x=cos⁡x (1+log⁡x)−xsin⁡xlog⁡x.\begin{aligned} &\frac{d}{dx}\big[(x\cos x)\log x\big] \\ &= (\cos x - x\sin x)\log x + x\cos x\cdot\frac1x \\ &= \cos x\log x - x\sin x\log x + \cos x \\ &= \cos x\,(1 + \log x) - x\sin x\log x. \end{aligned}

    So

    1u⋅dudx=cos⁡x (1+log⁡x)−xsin⁡xlog⁡x.\frac1u\cdot\frac{du}{dx} = \cos x\,(1 + \log x) - x\sin x\log x.
    A product of three factors is handled by grouping two of them. In the last line, xcos⁡x⋅1x=cos⁡xx\cos x\cdot\frac1x = \cos x (allowed because x≠0x \ne 0⁠), and the two cos⁡x\cos x terms are collected as cos⁡x (1+log⁡x)\cos x\,(1 + \log x)⁠, which is the form the book's answer uses.
    Product rule; (cos⁡x)′=−sin⁡x(\cos x)' = -\sin x (Table 5.3); (log⁡x)′=1x(\log x)' = \frac1x (Theorem 5). Basics: derivative rules
  4. Multiply by uu

    dudx= xxcos⁡x[cos⁡x (1+log⁡x)−xsin⁡xlog⁡x].\begin{aligned} \frac{du}{dx} = \ &x^{x\cos x}\big[\cos x\,(1 + \log x) \\ &\quad - x\sin x\log x\big]. \end{aligned}
    The left side of Step 3 was 1ududx\frac1u\frac{du}{dx}⁠; multiplying by u=xxcos⁡xu = x^{x\cos x} isolates dudx\frac{du}{dx}⁠. This holds for every x>0x > 0⁠.
    Logarithmic differentiation: u′=u⋅(log⁡u)′u' = u\cdot(\log u)'⁠. Lesson: logarithmic differentiation
  5. Differentiate vv by the quotient rule

    Numerator x2+1x^2 + 1 has derivative 2x2x⁠; denominator x2−1x^2 - 1 has derivative 2x2x⁠. For x≠±1x \ne \pm 1⁠:

    dvdx=2x(x2−1)−(x2+1)⋅2x(x2−1)2=2x[(x2−1)−(x2+1)](x2−1)2=2x⋅(−2)(x2−1)2=−4x(x2−1)2.\begin{aligned} \frac{dv}{dx} &= \frac{2x(x^2-1) - (x^2+1)\cdot 2x}{(x^2-1)^2} \\ &= \frac{2x\big[(x^2-1) - (x^2+1)\big]}{(x^2-1)^2} \\ &= \frac{2x\cdot(-2)}{(x^2-1)^2} = \frac{-4x}{(x^2-1)^2}. \end{aligned}

    A quick second route: v=1+2x2−1v = 1 + \frac{2}{x^2-1}⁠, so dvdx=−2⋅2x(x2−1)2\frac{dv}{dx} = -\frac{2\cdot 2x}{(x^2-1)^2}⁠, the same.

    No logs are needed for vv⁠: it is a quotient of polynomials. Taking out the common factor 2x2x makes the cancellation x2−1−x2−1=−2x^2 - 1 - x^2 - 1 = -2 easy to see. The second route rewrites vv as (x2−1)+2x2−1\frac{(x^2 - 1) + 2}{x^2-1} and uses the chain rule on 2(x2−1)−12(x^2-1)^{-1}⁠.
    Quotient rule, valid where the denominator is not zero (Section 5.3). Basics: derivative rules
  6. Add the two derivatives

    dydx= xxcos⁡x[cos⁡x (1+log⁡x)−xsin⁡xlog⁡x]−4x(x2−1)2,\begin{aligned} \frac{dy}{dx} = \ &x^{x\cos x}\big[\cos x\,(1 + \log x) \\ &\quad - x\sin x\log x\big] - \frac{4x}{(x^2-1)^2}, \end{aligned}

    for x>0x > 0⁠, x≠1x \ne 1⁠.

    This is the sum rule from Step 1 with Steps 4 and 5 put in. The condition combines x>0x > 0 (needed for uu⁠) with x≠1x \ne 1 (needed for vv⁠); x=−1x = -1 is already excluded by x>0x > 0⁠.
    Sum rule (Section 5.3). Basics: derivative rules
Result

For x>0x > 0⁠, x≠1x \ne 1⁠:

dydx= xxcos⁡x[cos⁡x (1+log⁡x)−xsin⁡xlog⁡x]−4x(x2−1)2.\begin{aligned} \frac{dy}{dx} = \ &x^{x\cos x}\big[\cos x\,(1 + \log x) \\ &\quad - x\sin x\log x\big] - \frac{4x}{(x^2-1)^2}. \end{aligned}

(Textbook answer: the same expression.)

Check it with numbers

At x=2x = 2⁠: cos⁡2=−0.4161468\cos 2 = -0.4161468⁠, sin⁡2=0.9092974\sin 2 = 0.9092974⁠, log⁡2=0.6931472\log 2 = 0.6931472⁠.

  • u=22cos⁡2=2−0.8322937=0.5616356u = 2^{2\cos 2} = 2^{-0.8322937} = 0.5616356⁠.
  • Bracket: cos⁡2 (1+log⁡2)\cos 2\,(1 + \log 2) =−0.7045978= -0.7045978 and 2sin⁡2log⁡2=1.26055392\sin 2\log 2 = 1.2605539⁠, so the bracket is −1.9651517-1.9651517⁠.
  • dudx=0.5616356×(−1.9651517)\frac{du}{dx} = 0.5616356 \times (-1.9651517) =−1.1036992= -1.1036992⁠.
  • dvdx=−89=−0.8888889\frac{dv}{dx} = -\frac{8}{9} = -0.8888889⁠.

Total: dydx=−1.9925881\frac{dy}{dx} = -1.9925881⁠. The central difference y(2.00001)−y(1.99999)0.00002\frac{y(2.00001) - y(1.99999)}{0.00002} gives −1.9925881-1.9925881⁠, the same to 7 decimal places.

Common mistakes
  1. Taking the log of the whole sum, as if log⁡(u+v)=log⁡u+log⁡v\log(u + v) = \log u + \log v⁠. It is not; differentiate the terms separately.
  2. Using the power rule on xxcos⁡xx^{x\cos x}, getting xcos⁡x⋅xxcos⁡x−1x\cos x\cdot x^{x\cos x - 1}⁠. The exponent varies, so the power rule does not apply.
  3. Missing a factor in the product xcos⁡xlog⁡xx\cos x\log x⁠: all three factors must be differentiated in turn.
  4. Forgetting to multiply back by uu at the end of the log step.
  5. Not stating the domain: the formula needs x>0x > 0 and x≠1x \ne 1⁠.
What to take away
  1. For a sum, split first; use logs only on the terms that need them.
  2. For x>0x > 0⁠: ddx xg(x)=xg(x)[g′(x)log⁡x+g(x)x];\frac{d}{dx}\,x^{g(x)} = x^{g(x)}\left[g'(x)\log x + \frac{g(x)}{x}\right]; here g(x)=xcos⁡xg(x) = x\cos x⁠.
  3. The domain of the answer is the intersection of the domains of the terms.

Every fact used, and where it comes from

FactUsed inSource
Sum, product and quotient rulesSteps 1, 3, 5, 6Algebra of derivatives, Section 5.3
Bases of variable powers must be positiveStep 1Section 5.5 (Lesson: logarithmic differentiation)
log⁡pn=nlog⁡p\log p^n = n\log pStep 2Section 5.4
ddxlog⁡x=1x\frac{d}{dx}\log x = \frac1xStep 3Theorem 5, Section 5.4
Chain ruleSteps 3, 5Theorem 4, Section 5.3.1
(cos⁡x)′=−sin⁡x(\cos x)' = -\sin x⁠; (xn)′=nxn−1(x^n)' = nx^{n-1}Steps 3, 5Table 5.3, Section 5.3
Found an error, or want more?

Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →