I have the function $f(x) = \frac{x^3 − x^2 \sqrt{2 x^2 + 2} + 4 x} {x^2 + 2}$. I want to find the optimal control points $\{P_0, P_1, P_2, P_3\}$ for a cubic Bézier curve $B(t) = (1 − t)³ P_0 + 3(1 − t)² t P_1 + 3 (1 − t) t² P_2 + t³ P_3$ that most closely matches the function over the interval $0 ≤ x ≤ 1$.
I know that $f(0) = 0$ and $f(1) = 1$, so $P_0 = (0, 0)$ and $P_3 = (1, 1)$. I also know that $f′(0) = 2$, so $P_1$ lies on the line $y = 2 x$ and can be represented as $P_1 = (a, 2 a)$, and $f′(1) = 0$, so $P_2$ lies on the line $y = 1$ and can be represented as $P_2 = (b, 1)$. Thus I only need to find two values, $a$ and $b$, to get the full set of four points completely determined.
However, I don't know how to calculate the optimal values of $a$ and $b$ to make the Bézier curve most closely match the function, and I haven't been able to find the answer online.