# Using Maple to Approximate an Integral

Use Maple to approximate the value of $b$ that solves the following equation:

$$\int_1^b \frac1x\,dx= 1$$

I picked two values $b$ such that one over approximates the integral and one which that under approximates the integral. Then I try to interpolate to obtain a new value of $b$. I was gonna try to repeat until four or five decimals remain the same. It did not work. Please help. Thanks.

• $\log(b)=1$ at $b=e$, that you may approximate through $$e = \sum_{n\geq 0}\frac{1}{n!}$$ – Jack D'Aurizio Mar 19 '17 at 21:26
• Or through the Beuker-like integrals $$\int_{0}^{1} x^{n}(1-x)^n e^{-x}\,dx$$ For instance, at $n=6$ you get $$e\approx \frac{1084483}{398959}$$ that is an extremely accurate approximation. – Jack D'Aurizio Mar 19 '17 at 21:29
• Can you put that as an answer? I want to give you credit. Thanks – jackson blackson Mar 19 '17 at 21:32
• All right, done (with more details and an extra insight). – Jack D'Aurizio Mar 19 '17 at 21:57
• The method of interpolation that you're suggesting is basically the secant method (en.wikipedia.org/wiki/Secant_method), used to find a root of the function $f(b) = \int_1^b 1/x \: dx - 1$. Of course to do what you're suggesting requires having good numerical integration routines. – Michael Lugo Mar 20 '17 at 3:48

The equation $\int_{1}^{b}\frac{dx}{x}=1$ is equivalent to $\log(b)=1$, hence the problem boils down to find accurate approximations for $e$. Since $e^x$ is a solution of the differential equation $f'=f$, $$e^{x}=\sum_{n\geq 0}\frac{x^n}{n!}$$ holds for every $x\in\mathbb{C}$. In particular $e$ can be approximated through $$\sum_{n=0}^{N}\frac{1}{n!}\qquad\text{or}\qquad \left(\sum_{n=0}^{N}\frac{(-1)^n}{n!}\right)^{-1}$$ for some large $N\in\mathbb{N}$. A more efficient alternative is to perform an explicit integration of functions like $x^N(1-x)^N e^{-x}$ over $(0,1)$, where such such functions are positive but pretty small. For instance, by considering $N=6$ we have
$$\frac{1}{2^{12}}\geq \int_{0}^{1} x^6(1-x)^6 e^{-x}\,dx = 720 \left(398959-\frac{1084483}{e}\right)$$ from which we have the extremely accurate approximation $e\approx \frac{1084483}{398959}$ (the error is less than $10^{-12}$). With a similar approach, i.e. by replacing the polynomials $x^N (1-x)^N$ with the shifted Legendre polynomials $P_N(2x-1)$, we may also compute the whole continued fraction of $e$: $$e=[2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10, 1, 1, 12, 1, 1, 14,\ldots]$$ allowing us to compute approximations with an arbitrary accuracy.
restart;

• The question said to use Maple, and so this is a fine answer. To be clear, the output from the first step is just e (or exp(1) in Maple's parlance). And the straightforward, efficient way to approximate that in Maple is just to apply its evalf command. This is then a hybrid symbolic-numeric approach. A much less efficient (and quite naive), purely numeric approach might be: fsolve(Int(1/x, x = 1 .. b) = 1,b=1..3) though naturally that slows down terribly when higher accuracy is attempted. – acer Mar 20 '17 at 2:49