Implement a (one-dimensional) adaptive recursive integrator which at each iteration subdivides the interval not into two, but into three sub-intervals.
For example, a rule like this (check that the numbers are correct),
xi={1/6,3/6,5/6} reusable points for division by 3;
wi={3/8,2/8,3/8} trapezium (higher order) rule; (check this!)
vi={1/3,1/3,1/3} rectangle (lower order) rule; (check this!)
Implement an adaptive division-by-three integrator with the signature
double adaptive3( Func<double,double> integrand, double a,double b, double acc=1e-3,double eps=1e-3, double f2=NaN )that takes a function 'integrand' and calculates its integral from 'a' to 'b' with the absolute accuracy 'acc' and relative accuracy 'eps' (reusing the points from the previous iteration).
Test your integrator on some interesting integrals (for example, from the homework "recursive adaptive integration") and check that the returned result is within the required accuracy goal, that is, check that
|result-exact| ≤ acc + |exact|*eps .Record the number of integrand evaluations during the integration of these integrals and compare with your integrator from the homework.
Implement the Clenshaw–Curtis variable transformation method. Test. Compare the number of integrand evaluations with your 'adaptive3' integrator and with your integrator from your homework.
Make your integrator estimate and return the error. Test.
Make your integrator accept infinite limits. Test.
Try calculate 'erf(1)' with the maximum precision that your integrator can do.