# Convert section of an equation to a cubic Bezier-curve

I have the equation $$f(x) = \frac{0.25x}{1.25 - x}$$ that I would like to turn into a cubic Bezier-curve in the window $$[0, 1]$$. I have tried to find an answer but I can only find sources on how to turn a quadratic equation into a Bezier-curve.

Is it even possible? And if so how would I start?

• Thank you, I've attempted to improve the question. – ApplePearPerson Apr 8 at 8:12

The definition of a cubic Bezier curve requires 4 points. The starting and ending points and two additional reference points. In general, the curve will not pass through the reference points. So, to answer your question, there is not a unique way of "converting" the graph of $$f$$ into a Bezier curve... You need to specify two additional points $$(x_1,f(x_1)), (x_2, f(x_2))$$ for some $$0 < x_1 < x_2 < 1$$.

Considering $$P_0 ⁼(0,0)$$, $$P_1=(\frac 13 f(\frac 13))$$, $$P_2=(\frac 12, f(\frac 23))$$ and $$P_3=(1,1)$$, the parametric equation of the Bezier curve is

$$(1-t)^3 P_0+ 3 (1-t)^2 t P_1 + 3(1-t) t^2 P_2+t^3P_3, \quad t \in [0,1]$$

or in this specific case, $$\left\{ \begin{array}{l} x(t)=t^3+2 (1-t) t^2+\frac{1}{3} (1-t)^2 t\\ y(t)=t^3+\frac{6}{7} (1-t) t^2+\frac{1}{11} (1-t)^2 t \end{array} \right.$$

This was obtained with the reference points over the curve. You can also run an optimization procedure to get the reference points that minimize the distance between the original curve and the Bezier cubic. In the following images you can see whet you obtain with the reference point over the curve and placed elsewhere.

• Is there a method to choose these reference points so that the resulting curve will approximate the line the equation makes? – ApplePearPerson Apr 8 at 8:21
• The Bezzier curve has severe limitations when approximating a given curve for arbitrary intervals (if you plot the equations above you will see that the Bezier curve is quite far from the graph of $f$. The best strategy is to subdivide the interval into smaller subintervals. – PierreCarre Apr 8 at 8:56

Look at the explicit algebraic expression for the curve

$$B(t) = (1-t)^3{\bf P_0} + (1-t)^2t^1{\bf P_1} + (1-t)^1t^2{\bf P_2} + t^3{\bf P_3}$$

And then sample $$x,y$$ along your curve $$t \in [0,1]$$ and simply set up linear least squares system and solve!

This will work since $$\bf P_0,P_1,P_2,P_3$$ are unknown, and $$(1-t)^{e_1}t^{e_2}$$ is constant for each sample point $$t$$.

As sanity check you can check that $$\bf P_0, P_3$$ should be close to end-points, or you can add this as a regularization cost, even.