# Determining an n for Numerical Integration

• I
Gold Member

## Main Question or Discussion Point

When estimating an integral using trapezoidal approximation, we can find the error or uncertainty in the estimation by:
$Error~in~T_n \leq \frac{M(b-a)^3}{12n^2}$ where $M$ is the maximum value of the absolute value of f''(x) over [a,b], $n$ is the number of intervals, and $T_n$ is the trapezoidal approximation with n intervals.

If we want an estimation within a certain degree of accuracy, we find M, set in less than or equal to our desired maximum value of uncertainty, then solve for n. This will give us an n amount of intervals to use for the approximation to stay withing a specified range of error or uncertainty.

My question is two fold:
First, why is $M$ the absolute value of f''(x)? What is the role that the second derivative plays here and why absolute value?

Second, please see the attached image which is part of an example problem in my text. I don't know what they're doing when solving for the absolute value of f''(x). Clearly, the maximum would be 6e, as when we plug in 1 into the second derivative, this is what we get. But I don't know what they're doing to get this value. I am referring to the very bottom line of the attached image.

#### Attachments

• 63.6 KB Views: 162

So I hope I understood your problem correctly.

The error T in the result of a numerical calculation R should always be interpreted as this:

The result for the analytical solution S is with certainty 100% in the interval [R-T,R+T].

What you do is make a worst case analysis. In trapezoidal numerical integration, the errors come primarily from the local second derivative. So you look up in your function where the second derivative is largest, and then find that the final error will be smaller than the case where every trapezoid yields the worst case error. Is this helpful?

jedishrfu
Mentor
I think they choose $x = 1$ because that will give the largest value for $f''$ by inspection.

Ray Vickson
Homework Helper
Dearly Missed
When estimating an integral using trapezoidal approximation, we can find the error or uncertainty in the estimation by:
$Error~in~T_n \leq \frac{M(b-a)^3}{12n^2}$ where $M$ is the maximum value of the absolute value of f''(x) over [a,b], $n$ is the number of intervals, and $T_n$ is the trapezoidal approximation with n intervals.

If we want an estimation within a certain degree of accuracy, we find M, set in less than or equal to our desired maximum value of uncertainty, then solve for n. This will give us an n amount of intervals to use for the approximation to stay withing a specified range of error or uncertainty.

My question is two fold:
First, why is $M$ the absolute value of f''(x)? What is the role that the second derivative plays here and why absolute value?

Second, please see the attached image which is part of an example problem in my text. I don't know what they're doing when solving for the absolute value of f''(x). Clearly, the maximum would be 6e, as when we plug in 1 into the second derivative, this is what we get. But I don't know what they're doing to get this value. I am referring to the very bottom line of the attached image.
Google is your friend. Do a search using keywords "trapezoidal rule error", and you will find articles that tell you all you want to know, and more.

Anyway, I do not agree with their calculation leading to $|f''(x)| \leq 6$; I would say that $|f''(x)| \leq 18,$ because $2 \times 3 \times e \leq 18.$ So, I think you need to take $M = 18$ (or $M = 6 e,$ which is a bit less but harder to use and probably will not affect $n$ very much).

Gold Member
So I hope I understood your problem correctly.

The error T in the result of a numerical calculation R should always be interpreted as this:

The result for the analytical solution S is with certainty 100% in the interval [R-T,R+T].

What you do is make a worst case analysis. In trapezoidal numerical integration, the errors come primarily from the local second derivative. So you look up in your function where the second derivative is largest, and then find that the final error will be smaller than the case where every trapezoid yields the worst case error. Is this helpful?
So to find the error of approximation with a problem like this, we need to graph it and see where in the interval that the second derivative is the largest (most concavity)? And this is where I have been confused in my research- we are using the trapezoids to "fill up" the area under neath the graph of $f$ Now depending on concavity of the graph of $f$, that will determine if the approximation is an over estimate or under estimate in that interval. So why don't we just look at the graph of $f$ rather than the graph of $f''$? Or do we look at the graph of $f$, we are just concerned about $f''$ which is the concavity of $f$?

Gold Member
I think they choose $x = 1$ because that will give the largest value for $f''$ by inspection.
So then our errors are naturally going to be different for the intervals that we choose and depending on the interval, we can have either an under approximation or an over approximation?

Gold Member
Google is your friend. Do a search using keywords "trapezoidal rule error", and you will find articles that tell you all you want to know, and more.

Anyway, I do not agree with their calculation leading to $|f''(x)| \leq 6$; I would say that $|f''(x)| \leq 18,$ because $2 \times 3 \times e \leq 18.$ So, I think you need to take $M = 18$ (or $M = 6 e,$ which is a bit less but harder to use and probably will not affect $n$ very much).
I've done the research but can't find an answer as to why we have an absolute value here.

Ray Vickson
Homework Helper
Dearly Missed
I've done the research but can't find an answer as to why we have an absolute value here.
The Wikipedia entry proves the formula
$$\text{error} = f''(\xi) \frac{(b-a)^3}{12 N^2},$$
where $f''(\xi) = \max_{x \in [a,b]} |f''(x)|.$

The article suppose the error measure to be $> 0$ because it measures an upper bound on the distance between the computed result and the true result. If you look more carefully into the proof you will realize that if
$$m_1 = \min_{x \in [a,b]} f''(x) < 0$$ and $$m_2 = \max_{x \in [a,b]} f''(x) > 0$$ then the actual numerical error (positive or negative) satisfies
$$m_1 (b-a)^3/(12 N^2 ) \leq \text{numerical error} \leq m_2 (b-a)^3/(12 N^2)$$ Therefore,
$$\text{error} \equiv |\text{numerical error}| \leq \max(|m_1|,|m_2|) (b-a)^3/(12N^2)\\ = \max_{x \in[a,b]} |f''(x)| (b-a)^3/(12 N^2)$$

Gold Member
Ok thanks so much Ray, the key word distance there makes sense to me intuitively, but i went through that proof and its over my head currently. I just started Calculus 2 so the notation and techniques there were foreign and I didnt know what to even Google to clear up my confusion in the proof.