I wish to solve a cubic equation on a computer as fast as possible. Yes, I could stick it into some gradient descent based solver but it is too slow. I am curious if the following equation can be solved with linear systems. What I have below is unwrapped form of a cubic bezier curve equation in 2D
$t^3(p_3 - 3p_2 + 3p_1 - p_0) + t^23(p_2 - 2p_1 + p_0) + t3(p_1 - p_0) + p_0 - p = 0$
Which I will simplify as two constraints with some new notation
$t^3(p_{0x}) + t^2(3*p_{1x}) + t^3(3*p_{2x}) + p_{3x} = px$ $t^3(p_{0y}) + t^2(3*p_{1y}) + t^3(3*p_{2y}) + p_{3y} = py$
I rewrite it as follows:
$\left[\begin{array}{ccc} p_{0x} & p_{1x} & p_{2x}\\ p_{0y} & p_{1y} & p_{2y}\\ ? & ? & ? \end{array}\right]*\left[\begin{array}{c} t^{3}\\ t^{2}\\ t \end{array}\right]=\left[\begin{array}{c} p_{3x}-p_{x}\\ p_{3y}-p_{y}\\ ? \end{array}\right]$
But I am not sure what to fill for the last column, or if i have to add any more columns. In my case when solving this Ax=b system, x is constraint by the fact that it is just square or cube of the same value. So i need to represent that in another set of numbers i can provide.
As said in the linked page, using the analytical formulae for the solutions of a cubic equation is extremely expansive in terms of CPU time.
Having spent (wasted ?) more then fifty years with cubic equations (in the are of applies thermodynamics), I shall try to summarize the method we used in my former research group.
Considering the equation $$\alpha x^3+\beta x^2+\gamma x+\delta=0$$ first divide everything by $\alpha$ and consider that you look for the zero'(s) of function $$f(x)= x^3+a x^2+b x+c$$ $$f'(x)=3 x^2+2a x+b$$
For the case where $f'(x)$ shows two real roots $x_-$ and $x_+$ : if $f(x_-)>0$ and $ f(x_+) <0$, there are three real roots. To estimate the starting point of Newton method, starting of the left, select $$x_0=x_- -\sqrt{-2\frac{f(x_-)}{f''(x_-)}}$$ If you prefer to start on the right, use $$x_0=x_+ +\sqrt{-2\frac{f(x_+)}{f''(x_+)}}$$ Use Newton method to get the first root $x_1$ and, using deflation, what remains is to find $x_2$ and $x_3$ which are the solutions of $$x^2+ (a+x_1)x-\frac{c}{x_1}=0$$