The function $erf\left(t\right)\:=\:\frac{2}{\sqrt{\pi }}\int _0^t\:e^{-x^2}dx$ is called the error function in statistics. If we use the composite trapezoid rule to compute $erf\left(2\right)$, how many points are needed to ensure that the absolute error is not larger than $10^{-5}$?
I understand that the error with the composite trapezoid rule is given by $-\frac{1}{12}\left(b-a\right)h^2f''\left(z\right)$. Here, $a$ and $b$ would be the two endpoints of the integration and $h$ would be $\frac{a-b}{\:n}$, where $n$ is the number of subintervals. I understand I am supposed to figure out the value of $n$ for which the error formula above is below $10^{-5}$.
However, I am quite confused what the values of $a$, $b$, $h$, and $z$ are supposed to be in this specific case.
Any help would be greatly appreciated!
You have $a=0$, $b=2$, $h=\frac{b-a}n=\frac2n$ and $z$ is an unknown midpoint. You need to take the worst possible case into account, that is, use $M=\max_{z\in[0,2]}|f''(z)|$. $n$ is the number of segments, so $n+1$ is the number of points.
For a first estimate you can also approximate the error as $\frac{|f'(b)-f'(a)|}{12n^2}$. The next term in the error expansion is of order $n^{-4}$.