# Trapezoidal Rule Accuracy

For this formula $$f(x)=2 \cos \left(\frac{\pi}{4} x\right)+2$$

How come if we use the trapezoidal rule for 2 separate parts,

i.e. the area of $$y=f(x)$$ for the interval $$[0,2]$$ and adding it to the area of $$y=f(x)$$ for the interval $$[2,4]$$,

why does this not give the same value as finding the area of $$y=f(x)$$ for the interval $$[0,4]$$?

Furthermore, why does taking the area between the interval $$[0,4]$$ give the exact same answer to $$\int_{0}^{4} f(x) d x$$?

• What are your results? I can find that both approximate result (integral) and exact result (integral) are the same... May 21 '20 at 8:47
• taking the area for the interval $[0,4]$ using the trapezoidal rule with 4 “trapeziums” results in the answer 8 which is the same value as the exact area May 21 '20 at 8:50
• Yeah, I found that too... May 21 '20 at 8:51
• however, when i find the area of the intervals $[0,2]$ and $[2,4]$ (each with 2 "trapeziums") using the trapezoidal rule, the sum of the error percentage should equal 0 shouldn't it? May 21 '20 at 8:55
• I found this: the approximate area under the curve above $[0, 2]$ + the approximate area under the curve above $[2, 4]$ is again same, and equal $8$. For approximate area I also used trapezoidal rule, with 2 trapeziums... May 21 '20 at 9:04

For your final question, the reason the trapezoidal rule gives the exact area under this curve is that this particular curve is symmetric about its midpoint $$(2,2)$$. So the shortfall from the true curve on the left side is exactly matched by the excess above the true curve on the right. If the interval chosen had not been one for which the curve was symmetric (say [0,3] or [0,5]), the trapezoidal rule would not give the exact value.

Now The area of the 4 trapeziums are $$\begin{array}{c|c}\text{Interval}&\text{Area}\\\hline [0,1]&3 + \frac {\sqrt2}2\\ [1,2]&2+\frac{\sqrt 2}2\\ [2,3] & 2 - \frac{\sqrt 2}2\\ [3,4]&1 - \frac{\sqrt2}2\end{array}$$ while the curve itself has areas $$\begin{array}{c|c}\text{Interval}&\text{Area}\\\hline [0,1]&2 + \frac {4\sqrt2}\pi \\ [1,2]&2 + \frac {8-4\sqrt2}\pi \\ [2,3] & 2 - \frac {8-4\sqrt2}\pi\\ [3,4]&2 - \frac {4\sqrt2}\pi \end{array}$$

This gives an absolute error on $$[0,2]$$ of $$(5 + \sqrt2) -\left(4 + \frac 8\pi\right) \approx -0.1323$$ and on $$[2,4]$$ of $$(3 - \sqrt 2) - \left(4 - \frac 8\pi\right) \approx = 0.1323$$. If you add those, you get an absolute error on $$[0,4]$$ of $$0$$, just as expected.

But you were calculating relative error, which on $$[0,2]$$ is $$\frac{(5 + \sqrt2) -\left(4 + \dfrac 8\pi\right)}{4 + \dfrac 8\pi} \approx -2.0204\%$$ and on $$[2,4]$$ is $$\frac{(3 - \sqrt2) -\left(4 - \dfrac 8\pi\right)}{4 - \dfrac 8\pi} \approx 9.0997\%$$ which indeed do not add up to $$0$$. Why not? Because they are relative errors, but the operation here ia addition!

Remember:

• The absolute error of a sum is the sum of the absolute errors.
• The relative error of a product is approximately the sum of the relative errors.
• thank you! this makes so much more sense now! May 21 '20 at 21:44
• Sorry, I had a question, how would you explain this by taking into account concavities? May 21 '20 at 23:34
• Explain what? I made no assumptions about concave vs convex anywhere. May 21 '20 at 23:39
• Wait, I see where I misunderstood. I was wondering how to explain why the curve is symmetric. May 21 '20 at 23:43
• The curve is symmetric because trigonometric functions possess a high degree of symmetry, which is why they obey all those trig identities. The particular symmetry at play here is that if you reflect any point of the curve through $(2,2)$, you get another point on the curve. Equivalently, if you rotate the graph by 180 degrees about the point $(2,2)$, you get the same curve. Since the trapezoidal curve is built on sub-intervals of equal width, it inherits that same symmetry from the original curve. May 21 '20 at 23:51