[Math] Finding $n$ value for trapezoid and midpoint rule errors

approximate integrationcalculusintegration

I have this math question as follows:

(a) Find the approximations $T_{10}$ and $M_{10}$ for $\int_1^2 9e^{1/x}\,dx$, . (This means use the trapezoid rule with $n=10$ and the midpoint rule with $n=10$.)

I did this and got correct answers of $18.197781$ and $18.171917$, respectively.

(b) Estimate the errors in the approximations of part (a). (Round your answers to six decimal places.)

Correct answers: $.061161$ and $.030581$, respectively.

But it is this part I cannot seem to get:

(c) How large do we have to choose $n$ so that the approximations $T_n$ and $M_n$ to the integral in part (a) are accurate to within $0.0001$?

I took the second derivative and found the max to be $27e$. I set that to:

$\frac{27e}{24n^2} < .0001$ for the midpoint and $\frac{27e}{12n^2} < .0001$ for the trapezoid rule.

My answers were $247.308191$ for the trapezoid and $174.873299$ for the midpoint. But it's not right. I don't know what I'm doing wrong, so if someone could steer me in the right direction that would be very helpful.

Best Answer

What are the given correct answers?

Your work seems correct. But of course $n$ is a positive integer, so you need to round your values up to the ceiling of your calculated answers. So $n=248$ guarantees the desired precision for the trapezoidal rule and $n=175$ does so for the midpoint rule.

However, those values were gotten by using the formulas that guarantee the desired precision, given a bound on the absolute value of the second derivative. You may get much better precision than the guaranteed value. Using $n=175$ I get the error $0.000028237574$ using the midpoint rule, much better than the desired $0.001$. You can get the desired error with much smaller values of $n$.

You should repeat the calculations of the approximate integrals to find just which value of $n$ actually gives you the desired error. For the midpoint rule in your situation, I get $n=93$ as the smallest $n$, which give the error $0.000099982028$. ($n=92$ gives $0.000102167251$.) For the trapezoidal rule I get $n=132$, giving the error $0.000099262595$.

Is the given correct answer for the midpoint rule $n=175$, my theoretical answer, or $n=93$, my calculated answer, or something else?