# Use a set of data points from a graph to find a derivative

I have a data logger that is recording the temperature readings from thermocouples at a specific interval. This gives me data points that I can graph where the x-coordinate is time and the y-coordinate is temperature. For each set of data points that I graph, I can connect the points and make a line - usually curved. I need to find the derivative of each line and graph those as well. There is no known function that creates these curves, so I can't simply find the derivative of a function. All I have is a huge list of (x,y) coordinates. How do I take a derivative and graph it in this case?

-

There are several ways to get estimates of the derivative at the $i$-th point.

The simplest estimate is probably $(y_{i+1} - y_{i-1})/(x_{i+1} - x_{i-1})$. This is just the slope of the line between the $(i-1)$-th point and the the $(i+1)$-th point. You'll have to do something special at the first and last points, of course. For example, at the first point, use $(y_2 - y_1)/(x_2 - x_1)$, instead.

A slightly more sophisticated approach is to estimate the derivative at the $i$-th point by using the slope of the parabola passing through points $i-1$, $i$, and $i+1$. If this approach sounds attractive, and you need help figuring out the formula for this slope, feel free to ask again.

Edit: I just realized that the slope of the parabola is actually given by the formula above if the $x$-values are equally spaced. So, in this case, my two suggested solutions are actually one and the same.

Here are some graphs made using the first technique. The red curve shows function values, and the blue curve shows (estimated) derivative values:

-
Let me ask this question to clarify. If I have x values of 12, 13, and 14 and y values of 2, 4, 6, to find the derivative at the second point (13, 4), I would use 6-14/2-12? –  Trillian522 Feb 18 '13 at 14:40
No. In this case $(x_{i-1}, x_i, x_{i+1}) = (12,13,14)$ and $(y_{i-1}, y_i, y_{i+1}) = (2,4,6)$. So the derivative estimate at the middle point $(x=3, y=4)$ is $(6-2)/(14-12)$. –  bubba Feb 19 '13 at 2:06

You can connect consecutive points with lines and assume that the derivative is the slope of these lines between these points. Of course, this makes the derivative noncontinuous (and not defined at the sample points).

A more elaborate idea would be to go for a spline interpolation, which would give a smoothe derivative

-
I came across the idea of a spline interpolation when I started looking into this project, but I have never done it before. It seemed like it would provide a great solution, but I haven't been able to figure out how to actually do it. –  Trillian522 Feb 14 '13 at 16:53