# Differentiating a Logarithm or Exponential

By now, you've seen how to differentiate simple polynomial functions, and perhaps a few other special functions (like trigonometric functions). In this lesson, we'll see how to differentiate logarithmic and exponential functions.

While there are whole families of logarithmic and exponential functions, there are two in particular that are very special: the natural logarithm and natural exponential function.

### Review of Logarithms and Exponentials

First, let's clarify what we mean by the natural logarithm and natural exponential function. The natural exponential function is defined as

$$f(x)=e^x$$

where e is Euler's number

$$e=2.71828...$$

We'll see one reason why this constant is important later on.

Remember that a logarithm is the inverse of an exponential. When we take the logarithm of a number, the answer is the exponent required to raise the base of the logarithm (often 10 or e) to the original number. For example log base 10 of 100 is 2, because 10 to the second power is 100. Therefore, the natural logarithm of x is defined as the inverse of the natural exponential function:

$$\large ln(e^x)=e^{ln(x)}=x$$

In general, the logarithm to base b, written $$\log_b x$$, is the inverse of the function $$f(x)=b^x$$. Take a moment to look over that and make sure you understand how the log and exponential functions are opposites of each other.

This means that there is a “duality” to the properties of logarithmic and exponential functions. Look at some of the basic ways we can manipulate logarithmic functions:

$$ln(x*y)=ln(x)+ln(y)\text{, and }e^{x+y}=e^x*e^y$$ $$ln(x^y)=y*ln(x)\text{, and }e^{xy}=(e^x)^y$$

And in fact, these identities are true no matter what the base is:

$$\log_b(x*y)=\log_b(x)+\log_b(y)\text{, and }b^{x+y}=b^x*b^y$$ $$\log_b(x^y)=y*\log_b(x)\text{, and }b^{xy}=(b^x)^y$$

From this we can derive the exponential “base-change” rule:

$$\large a^x=e^{x*ln(a)}$$

And the logarithmic “base-change” rule:

$$\large \log_b(x)=\frac{ln(x)}{ln(b)}$$

These identities are the ones we will need for this lesson.

### Derivatives of Logarithms and Exponentials

The derivatives of the natural logarithm and natural exponential function are quite simple. The derivative of $$ln(x)$$ is just $$\frac{1}{x}$$, and the derivative of $$e^x$$ is, remarkably, $$e^x$$.

$$\large \frac{d}{dx}(ln(x))=\frac{1}{x}$$ $$\large \frac{d}{dx}(e^x)=e^x$$

(In fact, these properties are why we call these functions “natural” in the first place!)

From these, we can use the identities given previously, especially the base-change formula, to find derivatives for most any logarithmic or exponential function. Let's see a couple of examples:

### Example 1

Problem: Find $$\frac{d}{dx}(4^x)$$

Solution: By the base-change formula, we know that $$4^x=e^{x*ln4}$$. So we must compute $$\frac{d}{dx}(e^{x*ln4})$$. This we can do by the chain rule:

$$f(x)=e^x$$; $$g(x)=x*ln4$$

$$\frac{d}{dx}(f(g(x)))=ln4*e^{x*ln4}=ln4*4^x$$

### Example 2

Problem: Find $$\frac{d}{dx}(\log_2x)$$

Solution: Again by the base change formula we know that

$$\large \log_2x=\frac{lnx}{ln2}$$

So, just take the derivative of that function instead. Remember that ln(2) is just a constant -- so we can simplify slightly:

$$\large \frac{d}{dx}(\log_2x) = \frac{d}{dx}(\frac{lnx}{ln2})=\frac{d}{dx}(lnx\frac{1}{ln2})$$

Since the derivative of ln(x) is just 1/x, all we have to do is multiply by that constant term and we're done!

$$\large \frac{d}{dx}(\log_2x)=\frac{1}{xln2}$$