Slope of an fcurve - how to determine? Is there any function or method to obtain the slope (first derivative) of an fcurve at a particular point/frame? (Corresponding to velocity or angular velocity or "velocity of scale" or any other rate of change of a property with an fcurve).

At the basic level I'd like to have a driver depend on whether a scene object is travelling upwards or downwards, not just on it's instantaneous location. The velocity would have even more uses than just a simple sign.

At the moment I can approximate it by sampling the fcurve a little before and a little after the frame in question, and calculating a slope from there, but it feels a bit like a hack, particularly if a better way to calculate it exists.

The maths for calculating the slope of linear and Bezier interpolated fcurves isn't that difficult, but so far I've been unable to find an elegant method of doing so. The upcoming easing equations would also have an simple mathematical solution, but again it's a matter of whether it's implemented as a python function or whether it would have to be calculated from the control points. (If it does have to be calculated that way, I'd love some advice on how to calculate it best).

Further, is it possible to obtain the second derivative (acceleration) for use in a driver?
No, blender doesn't have the ability to do this.

For Bezier splines you could probably calculate this yourself, but once you have F-Curve modifiers and use 2.71's new easing options, this becomes very complicated.

So the best you can do is check values to either side of the keyframe with some offset (called nabla)