0

Find an approximation of the following integral $$\int_{0}^{1}\frac{\sin\left(x\right)}{x}dx$$ With an error less than $10^{-5}$.


This is the first time I've been asked such a question and I don't know how to approximate a definite integral.

From the Taylor series of $\sin(x)$ I know that$$\sin(x)=\sum_{k\ge0}^{ }\frac{\left(-1\right)^{k}x^{2k+1}}{\left(2k+1\right)!}$$

And so for $x \ne 0$ we have that: $$\frac{\sin\left(x\right)}{x}=\sum_{k\ge0}^{ }\frac{\left(-1\right)^{k}x^{2k}}{\left(2k+1\right)!}$$

From here:

$$\int_{0}^{1}\frac{\sin\left(x\right)}{x}=\int_{0}^{1}\sum_{k\ge0}^{ }\frac{\left(-1\right)^{k}x^{2k}}{\left(2k+1\right)!}dx$$

Since $$\int_{0}^{1}\sum_{k\ge0}^{ }\left|\frac{\left(-1\right)^{k}x^{2k}}{\left(2k+1\right)!}\right|dx<\infty$$ So :

$$\int_{0}^{1}\frac{\sin\left(x\right)}{x}=\sum_{k\ge0}^{ }\frac{\left(-1\right)^{k}}{\left(2k+1\right)!}\int_{0}^{1}x^{2k}dx=\sum_{k\ge0}^{ }\frac{\left(-1\right)^{k}}{\left(2k+1\right)!\left(2k+1\right)}\le\sum_{k\ge0}^{ }\frac{\left(-1\right)^{k}}{\left(2k+1\right)!}=\sin\left(1\right)=0.841470984808$$

That was all I knew, but still I can't find the approximatin

masaheb
  • 918
  • 6
  • 16

2 Answers2

2

Perhaps you can remebr that if you have an decreasing sequence $u_n\geq 0$ such that $\lim u_n=0$ the series $\sum (-1)^k u_k$ converges to a limit $l$ and $\vert l-\sum _{k=1}^n (-1)^k u_k \vert \leq u_{n+1}$

In your case, $\int _0^1 {\sin x \over x} dx=\int _0^1 1- {x^2\over 3!}+ {x^4\over 5!}+ .. dx= 1-{1\over 2\times 2!}+ {1\over 5\times 5!}-{1\over 7\times 7!} +R_7$ with $\vert R_7\vert \leq {1\over 9\times 9!} \leq 10^{-7}$ .

Note that ${1\over 7\times 7!}= 2. 10^{-5}$ so this term cant be neglected.

Thomas
  • 7,470
0

Let me make the problem more general for $10^{-k}$.

As you wrote, the integration of the series gives $$\int_{0}^{1}\frac{\sin\left(x\right)}{x}dx=\sum_{n=0}^{p-1}\frac{(-1)^n}{(2 n+1) (2 n+1)!}+\sum_{n=p}^{\infty}\frac{(-1)^n}{(2 n+1) (2 n+1)!}$$ So, since it is an alternating series, you want to know $p$ such that $$R(p)=\frac{1}{(2 p+1) (2 p+1)!} \leq 10^{-k}\implies (2 p+1) (2 p+1)! \geq 10^k \tag 1$$ Tomake life easier, we shall use $$(2p+2)!\gt (2 p+1) (2 p+1)! \geq 10^k$$ and we face the problem of the inverse of the factorial function.

If you look at this question of mine, you will see a magnificent approximation by @robjohn. Applied to your case $$\color{red}{p \sim \frac12 e^{1+W(t)}-\frac 54} \qquad \text{with} \qquad \color{red}{t=\frac{2k \log (10)-\log (2 \pi )}{2 e}}$$ $W(t)$ being Lambert function.

For $k=5$, this would give $p=3.20872$ so $\lceil p \rceil=4$. To give you and idea of the accuracy, the exact solution of $(1)$ is $p=3.23842$ so the same $\lceil p \rceil$.

The iterest of that is that we can know if advance the number of terms to be added for a given maximum error. If coding, this remove all logical tests in the loop.

Let us try with $k=50$; the above formula will give $p=19.6467$ so $20$ terms. Checking $$R(19)=1.26 \times 10^{-48} > 10^{-50} \quad \text{while} \quad R(20)=7.29 \times 10^{-52} < 10^{-50}$$