Connecting a function, its first derivative, and its second derivative