This semester in first-semester Calculus I've been trying to focus on how to do Calculus calculations when given a table of data since this seems to be of importance to science majors. There are pretty standard methods for computing tabular derivatives and tabular antiderivatives (integrals). It appears, though, that doing one operation and then doing the other does not give back the data you started with.

Before I get into my long example below, the main question is:

Most Important Question: Is there a way, using tables of data, to demonstrate the Fundamental Theorem of Calculus?

A Long Example

Suppose we have the data

$x$ 1 5 9 13 17
$f(x)$ 1 3 7 15 31

For data in the middle of the table, we use the average of the slopes to the right and left to approximate the derivative at that point, e.g. $$f'(5) = \text{Average}\left(\frac{3-1}{5-1},\frac{7-3}{9-5}\right) = \frac{3}{4}.$$ For endpoints, you just use the only slope you can compute, e.g. $f'(1) = \frac{3-1}{5-1} = \frac{1}{2}$.

Doing so gives you the table

$x$ 1 5 9 13 17
$f(x)$ 1 3 7 15 31
$f'(x)$ 1/2 3/4 3/2 3 4

Going in reverse, suppose we know $f(1)=1$ and, given the derivatives we just computed, now compute $f$ at the other points. The standard way to do this is using the average of a left-hand and right-hand sum (aka trapezoid rule) to approximate the integral, e.g. $$f(9) = f(1) + \int_1^9 f'(x)dx = 1 + \frac{4}{2}\left(\frac{1}{2}+2\cdot\frac{3}{4}+\frac{3}{2}\right) = 8 \neq 7$$ The full table looks like

$x$      1 5 9 13 17
$f(x)$ 1 3 7 15 31
$f'(x)$ 1/2 3/4 3/2 3 4
$f(1)+\int_1^x f'(t)dt$ 1 3.5 8 17 31

First Question: How do we "fix" the inner data points so that $f(x) = f(1)+\int_1^x f'(t)dt$?

Going the other direction is worse. Suppose now we had just the last two rows of the previous table and then compute a derivative from the last row. Then it looks like

$x$           1 5 9 13 17
$f'(x)$ 1/2 3/4 3/2 3 4
$F(x) = 1+\int_1^x f'(t)dt$ 1 3.5 8 17 31
$F'(x)$ 5/8 7/8 27/16 23/8 3.5

Second Question: How do we "correct" the process so that $f'(x)=F'(x)$?

Third Question: Why doesn't this work? (I'm guessing it has to do with the essence of an approximation and the weird edge effects.)

Bonus Question: Do those who actually do applied mathematics with data in a research setting have to worry about this?

  • $\begingroup$ That second table looks fine in the preview/edit page, but for some reason isn't formatting when I post. If someone knows how to fix it, please do so. Thanks! $\endgroup$ – Aeryk Mar 22 at 20:57
  • $\begingroup$ The problem with the table was not having a line break before the table. Not sure why the table rendered in preview but not the post. $\endgroup$ – Steven Gubkin Mar 23 at 12:29


$x$ 1 5 9 13 17
$f(x)$ 1 3 7 15 31

Then we can approximate the slopes at the midpoint of each subinterval:

$x$ 3 7 11 15
$f'(x)$ 0.5 1 2 4

Going in reverse, if given that $f(1)=1$ and the above table of values, we can approximate

$f(5) = f(1)+ \displaystyle \int_1^5 f'(t) \textrm{d}t \approx 1+0.5(4) = 3$

$f(9) = f(1) + \displaystyle \int_1^9 f'(t) \textrm{d}t \approx 1+0.5(4)+1(4) = 7$


  • $\begingroup$ I get that this works. Thank you. But we/textbooks don't usually give data points at 3, 7, 11,... And then ask for F(9) given F(1). Is this a systematic pedagogical error? $\endgroup$ – Aeryk Mar 23 at 12:44
  • $\begingroup$ You can give data points whereever you want, and then just keep your wits about you as you approximate. If you know $f(1) = 3$, $f'(2) = 2$, $f'(6) = 1$, and you want to approximate $f(7)$, then you have options for how you will model $f$. One way is to treat is as piecewise linear on $[1,3]$ and $[3,7]$. Then we would have $f(7) \approx 3+2*3+1*4 = 13$. However, changing the intervals you use will impact your estimate. This is natural, since you do not have complete information. Whichever piecewise linear function you model with will enjoy the FTOC. $\endgroup$ – Steven Gubkin Mar 23 at 13:56
  • 1
    $\begingroup$ You could also fit a polynomial or whatever. Linear models are just convenient, and illustrate the idea. $\endgroup$ – Steven Gubkin Mar 23 at 14:00

The key term to search for this is "calculus of finite differences". (https://en.wikipedia.org/wiki/Finite_difference)

It looks like a common practice to solve this is to look at "forward differences", essentially letting "f'(x)" = f(x+1)-f(x). This solves the "fencepost error" by associating the "fence segment" between x and x+1 to the "fencepost" at x. This gives one a really nice fundamental theorem as in https://people.math.sc.edu/howard/Classes/555c/finiteDiff.pdf :

If $f(x) = F(x+1)-F(x)$, then: $$\sum\limits_{k=a}^b f(k) = F(b+1)-F(a)$$ Which holds by a basic telescoping sum.

If you want to use your notion of derivative, we can see what's happening if we make a table for a general function f: (I'm using sampling point spacing of 1 to make the calculations easier and show the general idea)

x 1 2 3 4 5
"f'(x)" $f(2)-f(1)$ $\frac{f(2)-f(1)}2+\frac{f(3)-f(2)}2$ $\frac{f(4)-f(3)}2+\frac{f(3)-f(2)}2$ $\frac{f(5)-f(4)}2+\frac{f(4)-f(3)}2$ $f(5)-f(4)$

If we add up all of these, we get: $$\frac32 [f(2)-f(1)] + [f(3)-f(2)] + [f(4)-f(3)] + \frac32 [f(5)-f(4)]$$

Which is very close to what we want: $$[f(2)-f(1)] + [f(3)-f(2)] + [f(4)-f(3)] + [f(5)-f(4)] = f(5)-f(1),$$ but the end differences are being counted an extra .5 times. This is why your trapezoid rule method gives the correct answers: each middle difference counts fully since it shows up in both the left-hand and right-hand sums, but each end difference is only counted half since it is only counted in one of the two sums.

If we take the trapezoid rule from 1 to 4 (instead of 1 to 5), however, we get: $$[f(2)-f(1)]+[f(3)-f(2)]+.75[f(4)-f(3)]+.25[f(5)-f(4)]$$ Which is nearly what we want: $$[f(2)-f(1)]+[f(4)-f(2)]+[f(4)-f(3)] = f(4)-f(1)$$ To correct this we need to add in a term of $$-.25f(3) + .5f(4) - .25f(5)$$ In general we need an analogous error correction term for any integral with internal upper bound, and if we want our "integral" to start at an internal point, we need a correction term for that too. Note that these error terms vanish as the distance between sampling points approaches 0 for nice functions, and only depend on what's happening at the endpoints of the "integral".

My advice is to use forward differences and left-hand sums to make things cleaner for a demonstration for students. Note that this pairing works even with different spacings for sample points.

  • $\begingroup$ Actually this answers the question I had earlier in the semester: "Why does my book only use the right-side to make the derivative?" Seemed sort of asymmetrical and unjustified at the time (I thought maybe it was just making it easier on students), but now I see how it helps dovetail in with the integration side. Thanks! $\endgroup$ – Aeryk Mar 23 at 18:06
  • $\begingroup$ @Aeryk: Note that the traditional "definition of the derivative" lim h->0 (f(x+h)-f(x))/h is not a "right-sided" derivative. The limit also incorporates the "left-sided" derivative when h < 0. But it is a "sided" derivative, and disagrees with the "central" derivative lim h->0 (f(x+h)-f(x-h))/(2h). (For instance, the "central" derivative thinks the derivative of abs(x) at x = 0 is 0) $\endgroup$ – TomKern Mar 23 at 18:36
  • $\begingroup$ Sorry, should have clarified: The book only uses the interval to the right when doing tabular derivatives. My thought was "what's wrong with the interval to the left? Shouldn't that info be considered too?" But using only the right-side/forward difference makes more sense now. $\endgroup$ – Aeryk Mar 23 at 19:49
  • 1
    $\begingroup$ I think there's some symbol mix-up in "If $f(x) = F(x + 1) - F(x)$, then $\sum_{k = a}^b f'(k) = F(b + 1) - F(a)$." $\endgroup$ – LSpice Mar 23 at 23:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.