numerical integration $f\left( x\right) =1-4\left( x-\dfrac{1}{2}\right) ^{2}$

48 Views Asked by At

$$f\left( x\right) =1-4\left( x-\dfrac{1}{2}\right) ^{2}$$ I want to be integrated this. If you calculate normally, it will be like this $$\int ^{1}_{0}\left( 1-4\left( x-\dfrac{1}{2}\right) ^{2}\right) dx=\dfrac{2}{3}\approx 0.66667\ldots$$

But I must use numerical integration. $$\sum ^{n-1}_{i=0}0.5\times\left( f\left( x_{i}\right) +f\left( x_{i+1}\right) \right) \times d$$ If I use this calculate, I can answer the approximation of integration.


I think.

Put $n=100$ $$\begin{aligned}\sum ^{99}_{i=0}0.5\times \left( f\left( \dfrac{i}{100}\right) +f\left( \dfrac{i+1}{100}\right) \right) \times \dfrac{1}{100}\\ =\sum ^{99}_{i=0}0.5\times \left( 1-4\left( \dfrac{i}{100}-\dfrac{1}{2}\right) +1-4\left( \dfrac{i+1}{100}-\dfrac{1}{2}\right) \right) \times \dfrac{1}{100}\end{aligned}$$ $$=-\dfrac{6767}{5000}=-1.3534$$

Put $n=1000$ $$\sum ^{999}_{i=0}0.5\times\left( f\left( \dfrac{i}{1000}\right) +f\left( \dfrac{i+1}{1000}\right) \right)\times\dfrac{1}{1000}$$ $$=\sum ^{999}_{i=0}0.5\times \left( 1-4\left( \dfrac{i}{1000}-\dfrac{1}{2}\right) +1-4\left( \dfrac{i+1}{1000}-\dfrac{1}{2}\right) \right)\times\dfrac{1}{1000}$$ $$=-\dfrac{667667}{500000}= -1.335334$$

Obviously the approximation is wrong. Where I made a mistake, please tell me.

1

There are 1 best solutions below

2
On BEST ANSWER

As I wrote in a very early comment, it seems that you lost the squares and for $n=100$ the formula should be $$I=\sum ^{99}_{i=0}0.5\times \left( 1-4\left( \dfrac{i}{100}-\dfrac{1}{2}\right)^{\color{red}{2}} +1-4\left( \dfrac{i+1}{100}-\dfrac{1}{2}\right)^{\color{red}{2}} \right) \times \dfrac{1}{100}$$ Making it for general $n$ $$I=\sum ^{n-1}_{i=0}\frac 12\times \left( 1-4\left( \dfrac{i}{n}-\dfrac{1}{2}\right)^{2} +1-4\left( \dfrac{i+1}{n}-\dfrac{1}{2}\right)^{2} \right) \times \dfrac{1}{n}$$ Expanding $$I=\sum ^{n-1}_{i=0} \frac {2( n-1)+ 4( n-1)i-4 i^2 } {n^3}=\frac{2 \left(n^2-1\right)}{3 n^2}=\frac{2}{3}-\frac{2}{3 n^2}$$ So, for $n=100$, the error is $\frac{1}{15000}=0.000067$.