# Integral of $n^x$

A simple high school math problem (It's been too long since I went there).

I need to find the average of the yearly output when the degredation of the yearly output is given by $100 \times 0.98^x$. I need to be able to find the average between $x_1$ and $x_2$ where $x_1 \geq 0$ and $x_1 \lt x_2 \lt 40$.

I needed it for a business case I need to be able to verify. The degredation is the expected degradation of solarpanels and the calculation will give an estimate of the scrap value of a solar panel power plant at year x

-
Hint: For $a>0$ and $a\not=1$, $a^x=e^{x\cdot ln(a)}$. –  user5137 Sep 9 '11 at 16:39
@Jack thanks for the hint. I was however hoping for a solution. No it's not homework :) –  Rune FS Sep 9 '11 at 16:48

Let $a = 0.98$. Then, we have $$\int a^x dx = \int e^{x \ln a} dx = \frac{e^{x \ln a}}{\ln a} + C = \frac{a^x}{\ln a} + C.$$ To evaluate the integral in between, we made the substitution $y = x \ln a$, and used $$\int e^y dy = e^y + C.$$ The $C$ is an arbitrary constant. For the purposes of computing the definite integral below, we can ignore the $C$.

So, the average output is given by: $$\frac{1}{x_2 - x_1} \int_{x_1}^{x_2} 100 a^x dx = \left. \frac{1}{x_2-x_1} \cdot \frac{100a^x}{\ln a} \right|_{x_1}^{x_2} = \frac{100}{\ln a} \frac{a^{x_2} - a^{x_1}}{x_2 - x_1},$$ writing it in a slightly nicer form. To make it easy to calculation, we can massage this answer to: $$\frac{100 \ \log_{10} e}{\log_{10} (.98)} \times \frac{0.98^{x_2} - 0.98^{x_1}}{x_2 - x_1}$$ Here, $e \approx 2.718\ldots$ is the famous Euler constant.

Note: Be careful with the signs a bit. Since $a < 1$, both $a^{x_2} - a^{x_1}$ and $\log_{10} a$ will turn out to be negative.

Added. The above formula is correct but not that great for numerical computations. I recommend using $$\frac{100 \ \log_{10} e}{\log_{10} (\frac{1}{0.98})} \times \frac{0.98^{x_1} \cdot (1 -0.98^{x_2 - x_1})}{x_2 - x_1}$$ instead. You will need to know some standard identities of exponential functions to derive this. Also, note that I have "corrected" the sign problem as well: all the terms will now be positive.

Discrete case. Though not asked by the OP, I will mention how to proceed when you have a discrete sequence of outputs, rather than a continuous function $f(x)$ (like, $a^x$). Specifically, imagine that the output in the starting year is $100$, and every subsequent year, this drops to $98 \%$ of the previous year.

In this case, the outputs for the first $40$ years form a geometric sequence $100, 100 a, 100 a^2, \ldots, 100 a^{40-1}$. Suppose you want to calculate the average of the outputs of all years between $n_1$th and $n_2$th year (both endpoints included). This is given by: $$\frac{100 a^{n_1 - 1} + 100 a^{n_1 + 1 - 1} + \ldots + 100 a^{n_2 - 1}}{n_2 - n_1 + 1}.$$ In this case, the numerator can be summed by geometric series formula. I will only mention the final answer without going into the details: $$\frac{100}{1-a} \times \frac{a^{n_1-1} \cdot (1 - a^{n_2 - n_1 +1})}{n_2 - n_1 +1}.$$ Notice the similarities between the two answers. Plugging in $a = 0.98$, we get: $$5000 \times \frac{0.98^{n_1-1} \cdot (1 - 0.98^{n_2 - n_1 +1})}{n_2 - n_1 +1}.$$

-
Well, since $\frac{d}{dx}\left(e^x\right)=e^x$, we have $\frac{d}{dx}\left(e^{ax}\right)=ae^{ax}$ by the chain rule. Thus, $\int e^{ax}\,dx=\frac{e^{ax}}{a}+C$ (for $a\not=0$, of course).
Thus, if I've done my number crunching correctly, the average value over $[0,40]$ of $f(x)=100\cdot 0.98^x$ is:
$\frac{1}{40}\int_0^{40} 100 \cdot 0.98^x\,dx=\frac{100}{40}\int_0^{40} e^{x\cdot ln(0.98)}\,dx=\frac{5}{2}\cdot \frac{1}{ln(0.98)}e^{x\cdot ln(0.98)}\big\vert_0^{40}$
$=\frac{5}{2\cdot ln(0.98)}\left(0.98^{40}-1\right)$.