How to Compute $\frac{d}{dx}\left(\left(1+x^2\right)^x\right)$?

This is what I worked out:

Let $y = (1 + x^2)^x$ and let $a = 1 + x^2$

Then, by the chain rule of differentiation:

$\frac{dy}{dx} = \frac{dy}{da}\cdot\frac{da}{dx} = a^x\cdot ln(a) \cdot 2x$

$\frac{dy}{dx} = (1 + x^2)^x \cdot ln(1 + x^2) \cdot 2x $

But when I try to verify the result on WolframAlpha, I get this.

What have I done wrong?

Solutions Collecting From Web of "How to Compute $\frac{d}{dx}\left(\left(1+x^2\right)^x\right)$?"

The problem is, that $y$ does not only depend on $a$, but also on $x$. Note that you have $y = a^x = g(a,x)$, that is $y$ is not a function of $a$, you have $g(a(x), x)$, not $g(a(x))$, as you must have for an application of the one variable chain rule.

What you can do are two different things:
(1) If you know the multivariable chain rule, you can use it, giving
$$ \frac{dy}{dx} = \frac{\partial y}{\partial a}\frac{da}{dx} + \frac{\partial y}{\partial x} $$

(2) If you do not know it (or are not allowed to use it anyway), then look at $\log y = x\log(1+x^2)$. By the (single-variable) chain and the product rule, you get
$$ \frac{y’}y = (\log y)’ = \bigl(x\log(1+x^2)\bigr)’ = \log(1 + x^2) + \frac x{1+x^2} \cdot 2x $$

Your mistake here is that you have used a formula where $a$ is taken to be a constant. So if $a$ is a variable like your case, you cannot use that formula anymore.

Better use this:
$$y=(1+x^2)^x$$
$$\ln y=\ln (1+x^2)^x$$
$$\ln y=x\ln (1+x^2)$$
$$\frac{y’}{y}=\ln (1+x^2)+\frac{2x^2}{1+x^2}$$
$$y’=(1+x^2)^x\left(\ln (1+x^2)+\frac{2x^2}{1+x^2}\right)$$

In case you still want to substitute, use the multivariable chain rule as mentioned by martini.

I think you have a wrong thought about the composition you made! 🙂 A more general form of your function is

$$y = {\left[ {f(x)} \right]^x}$$

Can you write this in form of a composition? I don’t think so! The only way is to take the derivative directly! Hence you can get

$$\eqalign{
& \ln y = x\ln f(x) \cr
& {{y’} \over y} = \ln f(x) + x{{f'(x)} \over {f(x)}} \cr
& y’ = \left( {\ln f(x) + x{{f'(x)} \over {f(x)}}} \right)y \cr
& \,\,\,\,\,\, = \left( {\ln f(x) + x{{f'(x)} \over {f(x)}}} \right){\left[ {f(x)} \right]^x} \cr} $$

In order to calculate $\frac{d}{dx}\left(\left(1+x^2\right)^x\right)$ then this expression can be placed into the form
\begin{align}
\frac{d}{dx} \left(\left(1+x^2\right)^x\right) &= \frac{d}{dx}\left[ e^{x \, \ln(1+x^2)} \right] \\
&= e^{x \, \ln(1+x^2)} \, \left[ x \, \frac{d}{dx} \ln(1+x^2) + \ln(1+x^2) \right] \\
&= (1+x^2)^{x} \, \left[ \frac{2 \, x^2}{1+x^2} + \ln(1+x^2) \right]
\end{align}

The rule you are using is only valid for constant $a$.

It is generally true for functions $f$ and $g$ of $x$ that

$$\left(f^g\right)’ = gf^{g-1}\cdot f’ + f^g\log f\cdot g’$$
(you can derive this by taking logs and then differentiating, and rearranging the result).

Addendum: I would always encourage my students to memorize this. It’s actually quite easy, if you look at the two pieces being added up. The first piece $$\underbrace{gf^{g-1}}\cdot f’$$ is like the rule for constant exponents, and the second piece $$\underbrace{f^g\log f}\cdot g’$$ is like the rule for constant bases. If either $f$ or $g$ is really constant, then the corresponding $f’$ or $g’$ is zero and so one of the terms disappears, leaving you with the classical formula for constant base or constant exponent.

Addendum 2: Here is the simple derivation. We seek $y’$, given that $y=f^g$ (here $f$ and $g$ are functions of $x$ and the “prime” denotes differentiation with respect to $x$).
$$y=f^g$$
$$\log y = g\cdot\log f\tag{take logs}$$
$$(\log y)’ = (g\cdot\log f)’\tag{take deriv.}$$
$$\frac{y’}y = (g\cdot\log f)’\tag{deriv. of $\log y$}$$
$$\frac{y’}y = g\cdot(\log f)’ + g’\cdot\log f\tag{product rule}$$
$$\frac{y’}y = g\cdot\left(\frac{f’}f\right) + g’\cdot\log f\tag{deriv. of $\log f$}$$
$$y’ = \frac{gy}f \cdot f’ + y\log f\cdot g’\tag{mult. by $y$, rearrange}$$
$$y’ = \frac{gf^g}f\cdot f’ + f^g\log f\cdot g’\tag{defn. of $y$}$$
$$y’ = \boxed{gf^{g-1}\cdot f’ + f^g\log f\cdot g’}\tag{combine powers of $f$}$$