6 Estimating Derivatives from Data
If we want to use these ideas in real world problems, we need to be able to estimate partial derivatives using data.
Here is some pretend data – for concreteness’ sake let’s say that the y-axis is pressure (perhaps from from sea-surface height measured by a satellite altimeter). For example, it might be the pressure as a function of distance to the east (x) holding depth (the z-coordinate) and latitude (the y-coordinate) fixed.
p(x) at z = -50 m and y = 24°N
We want to use our measurements of pressure at discrete values of longitude (xi) to estimate the first- and second- partial derivatives of pressure with x. For example, we could use the first partial derivative to estimate the pressure gradient at, say, x2. As another example, when we work problems involving diffusion, we might need to estimate the second partial derivatives.
Estimating the first partial derivative
In the example above, the first partial derivative at x2 is approximated by the change in p divided by the change in x (i.e., the “rise” over the “run” to get the approximate slope of the tangent line at x2.
Key Takeaways
We can estimate the first partial derivative using a finite difference approximation to the partial derivative of pressure with respect to x:
Why did we use points 1 and 3? If we used either points 1 and 2, then the resulting tangent line would have a slope that is more appropriate to a point that lies between points 1 and 2. Since we want the tangent line slope at x2, we choose to take a difference using points that are centered on point 2. Not surprisingly, this is called using a centered difference approximation. Had we used points 1 and 2 to calculate our values, then we would have used a backward difference approximation (because we used information for values lower than, or behind, x2). Had we used points 2 and 3, we would have used a forward difference approximation.
Estimating the second partial derivative
The second derivative (or the derivative of the first derivative) gives you the rate of change of the slope of the tangent line with x. As an example, if the second derivative is zero, then the slope does not change with x, and the curve must be a straight line. For this reason, the second derivative is also associated with the curvature of a function. Positive second derivatives indicate a tangent line slope that increases with x. Negative second derivatives indicate a tangent line slope that decreases with x.
Key Takeaways
Below is a centered finite difference approximation for the second derivative at point x2 where we assume that
Add some algebra to turn it into the previous expression!
Media Attributions
- PressureVsX © Susan Hautala is licensed under a CC BY-SA (Attribution ShareAlike) license