Fitting a polynomial with arbitrary derivative values Given two points $(x_1, y_1)$ and $(x_2, y_2)$ with $x_2 > x_1$ and $y_2 < y_1$, I can obviously fit a line (order $1$ polynomial) to them. But if I want to fit a quadratic function by specifying real, finite values of the derivatives at the two points, are there any constraints on the values of the derivatives?
 A: If you want to fit a quadratic $y=ax^2+bx+c$ to the two points $(x_1,y_1)$ and $(x_2,y_2)$ then you have to satisfy the pair of equations
$$y_1=ax_1^2+bx_1+c$$
and
$$y_2=ax_2^2+bx_2+c$$
If, moreover, you want to force the derivative at $(x_1,y_1)$ to be $m_1$ and the derivative at $(x_2,y_2)$ to be $m_2$, you need to also satisfy the equations
$$m_1 = 2ax_1 + b$$
and
$$m_2 = 2ax_2 + b$$
Now the goal would be to find values of $a, b, c$ such that all four of those equations is satisfied.  In general, if you have four equations in three variables there may be no solution, or a unique solution, or infinitely many solutions, depending on the specific values of the parameters (in this case $x_1, y_1, x_2, y_2, m_1, m_2$).
In this case, probably the easiest way to proceed is to start by solving the last two equations, which contain only the variables $a$ and $b$.  If they have a unique solution, then back-substitute those values into the first pair of equations; it should be clear right away whether they are consistent, in which case you can solve for $c$.
Edited to add: Ooh, this is kind of fun!  If you do this for the general case, you end up with the following condition:  The system has a unique solution if and only if
$$\frac{y_1 - y_2}{x_1 - x_2}= \frac12 (m_1+m_2)$$
which has a simple geometric interpretation:  The slope of the straight line joining your two points has to be equal to the average of the slopes at the two points.
A: You have four variables: $y_1$ and $y_2$, and the slopes $m_1$ and $m_2$. This means that you would need a cubic, which has four coefficients: $a_3x^3+a_2x^2+a_1x+a_0$.
Alternatively, if you really must have a quadratic, you could reduce the degrees of freedom by specifying only one of $m_1$, $m_2$, or by requiring that $m_1 = m_2$, or by specifying both slopes but only one of $y_1, y_2$, etc. This would give you three degrees of freedom corresponding to the three coefficients in $a_2x^2+a_1x+a_0$.
