0

I was curious about how to calculate an approximate value of a definite integral with the 2 point quadrature formula. So I did a test. We all know that: $$\int_{0}^{\pi} \sin(x)dx = 2$$

Now I tested the quadrature approximation with. $$\left(\frac{b-a}{2}\right)f\left(\frac{b-a}{2}\left(\frac{-1}{\sqrt{3}}\right)+\frac{b+a}{2}\right)+\left(\frac{b-a}{2}\right)f\left(\frac{b-a}{2}\left(\frac{1}{\sqrt{3}}\right)+\frac{b+a}{2}\right)$$

When I calculated this for $a=0$ and $b=\pi$

The value that I got was $4.9$

This is a pretty bad approximation in my opinion. I am wondering if I did something wrong. Can someone check my work?

Also, I used to be able to type in equations here with codecogs, but now I can only link to images. How do you write equations here at stack exchange?

Em.
  • 15,981
Erock Brox
  • 765
  • 1
  • 4
  • 14

1 Answers1

2

As dromastyx commented, you probably have a mistake somewhere since, using the formula as you wrote it, you should arrive, after simplifications, to $$\int_{0}^{\pi} \sin(x)dx \approx \pi \cos \left(\frac{\pi }{2 \sqrt{3}}\right)\approx 1.93582$$

For the fun, not knowing the values of the trigonometric functions, using this approximation $$\cos(x) \simeq\frac{\pi ^2-4x^2}{\pi ^2+x^2}\qquad (-\frac \pi 2 \leq x\leq\frac \pi 2)$$ you should arrive to $$\int_{0}^{\pi} \sin(x)dx \approx \frac{8 \pi }{13}\approx 1.93329$$