# Numerical Method: Approximating an Integral

Let:

I $= \int_0^{1000} \dfrac{e^{-10x} \sin(x)}{x} dx$

Evaluate I to within $\pm 10^{-5}$

I've broken down the problem to simply evaluating the integral from zero to one (by way of the accuracy required and using a comparison), after that, however, I've no clue how to approach this - I know I could manually take derivatives and somehow discern the taylor series of the integrand, but this is a bad function to derive multiple times. Using a trapezoidal approximation would take way too many sub-intervals - is there another approach to this?

• You want to do it by hand, or program a computer to do it? – icurays1 Apr 4 '13 at 22:04
• By hand, but a calculator is permitted. – kvmu Apr 4 '13 at 22:08

## 3 Answers

First, notice that the expression to be integrated rapidly decreases as x increases. So, you only have to integrate from 0 to some $a$.
You can determine an upper bound for remaining part of the integral by excluding oscillating factor $\sin(x)$ and evaluating $\int_a^{1000}\frac{\exp(-10x)}{x}dx$ (it will require Ei function evaluation - from tables or somehow). Then take good enough $a$ so that this upper bound is less than specified tolerance of $10^{-5}$ and use any usual method such as trapezoid or rectangle approximation to evaluate $\int_0^a\frac{\exp(-10x)\sin(x)}{x}dx$.
From my checks it appeared sufficient to have $a=1$.

• I've already established that the integral from 0 to 1 is sufficient, however evaluating the integral is the difficulty. Also it needs to be shown that the accuracy is within the desired range. – kvmu Apr 4 '13 at 23:01
• @kvmu Well you can just expand $\frac{\sin(x)}{x}$ to series (where series up to $x^4$ term appears sufficient) and integrate symbolically. As for accuracy, I've already provided a means of checking that integral from 1 to 1000 is small enough, you only have to prove that $\text{sinc}(x)$ expansion up to 4th power is enough (e.g. finding $\sup_{x\in [0,1]}{\left(\text{sinc}(x)-\left(1-\frac{x^2}{6}+\frac{x^4}{120}\right)\right)}$ and proving it's smaller than some value. – Ruslan Apr 5 '13 at 7:17
• Thanks for the reply! Fortunately, I figured it out before the problem was due - I did something similar to what you describe here: 1) showed that it is sufficient to compute the integral from 0 to 1 2) expanded $\dfrac{sin(x)}{x}$ into a series of partial sums from k = 1 to n + an error term. Since the series is alternating, the |error term| is at least the next term in the series, ie. the n+1th term. Then I multiplied the exponential to the the series and the error term. – kvmu Apr 7 '13 at 3:32
• 3) Then I did a comparison to show that the |new error term| is at least some value and integrated it. After that, I solved the inequality to show that n = 2 is good enough (for the accuracy required). The integral I ended up solving was something in the form of: $\int_0^1 e^{-10x} -\dfrac{x^2e^{-10x}}{3!}dx$ – kvmu Apr 7 '13 at 3:55

Let $$I(y)=\int_0^y\frac{e^{-10x}\sin x}{x}\,\mathrm dx.$$ Then for $y>0$ we have $$\left|I(y)-I(\infty)\right|<\frac1y\int_y^\infty e^{-10x}\,\mathrm dx=\frac{e^{-10y}}{10y}.$$ Therefore $|I(1000)-I(1)|\le |I(1000)-I(\infty)|+|I(1)-I(\infty)|\approx 4.54\cdot 10^{-6}$ allows us to merely calculate $I(1)$ if we keep the numerical error below $5\cdot 10^{-6}$.

Note that $0<\frac{\sin x}{x}\le 1$ for $0\le x\le 1$ and $g(x):=\frac{\sin x}{x}$ is strictly decreasing. Therefore, if $0=x_0<x_1<\ldots <x_n=1$, then $$\sum_{k=1}^n g(x_{k})\int_{x_{k-1}}^{x_k}e^{-10x}\,\mathrm dx<I(1)<\sum_{k=1}^n g(x_{k-1})\int_{x_{k-1}}^{x_k}e^{-10x}\,\mathrm dx,$$ i.e. $$\sum_{k=1}^n g(x_k)\frac{e^{-10x_{k-1}}-e^{-10x_{k}}}{10}<I(1)<\sum_{k=1}^n g(x_{k-1})\frac{e^{-10x_{k-1}}-e^{-10x_k}}{10}.$$ We need to keep the difference $$\sum_{k=1}^n (g(x_{k-1})-g(x_k))\frac{e^{-10x_{k-1}}-e^{-10x_{k}}}{10}$$ small, which can be achieved by suitable chice of $x_k$. Note that the sequence can be chosen to grow quite rapidly because of the small eponential factor, except perhaps near $0$. But near $0$, the first factor $g(x_{k-1})-g(x_k)$ is approximately linear in $x_k-x_{k-1}$, for $x_{k-1}=0$ even quadratic.

• Your approximation is nice, but does not give I to $\pm 10^{-5}$ degree of accuracy (also this needs to be done by hand). For reference: I = 0.0996687 – kvmu Apr 4 '13 at 23:06

I would try to reduce it more, since when $x \gg 0$, we still have $e^{-10x} \ll 1$, and for small $x$, roughly $\sin x \approx x$ so the integrand becomes $e^{-10x}$, which is trivial to integrate.

• Good call, but I've already checked and it doesn't work. The value of $\int_0^{1} e^{-10x} dx$ is not in the range of the desired accuracy. – kvmu Apr 4 '13 at 23:18