How to find the vertex form of a cubic? In a calculus textbook, i am asked the following question: 
Find a cubic polynomial whose graph has horizontal tangents at (−2, 5) and (2, 3)
A vertex on a function $f(x)$ is defined as a point where $f(x)' = 0$. So the slope needs to be 0, which fits the description given here. So i am being told to find the vertex form of a cubic. Further i'd like to generalize and call the two vertex points (M, S), (L, G).
I understand how i'd get the proper x-coordinates for the vertices in the final function:
I need to find the two places where the slope is $0$. So i need to control the 
x-intercepts of a cubic's derivative. I start by:
$(x + M) * (x + L)$ which becomes:  $x^2 + x*(M+L)+M*L$ 
I now compare with the derivative of a cubic in the form: $ax^3 + bx^2 + cx + d$:
$3a*x^2 + 2b*x + c = x^2 + (M+L)*x+M*L$ . From this i conclude:
$3a = 1$,   $2b=(M+L)$, $c=M*L$, so, solving these: $a=1/3$, $b=\frac{L+M}{2}$, $c=M*L$.
So, putting these values back in the standard form of a cubic gives us:
$\frac{1}{3} * x^3 + \frac{L+M}{2} * x^2 + L*M*x + d$
And that's where i get stumped. This works but not really. If both $L$ and $M$ are positive, or both negative, the function starts giving wrong results. 
But the biggest problem is the fact that i have absoloutely no idea how i'd make this fit certain requirements for the $y$-values. Only thing i know is that substituting $x$ for $L$ should give me $G$. And substituting $x$ for $M$ should give me $S$.
Any help is appreciated, have a good day!

Let $f(x)=a x^3+b x^2+c x+d$ be the cubic we are looking for
We know that it passes through points $(−2, 5)$ and $(2, 3)$ thus
$f(-2)=-8 a+4 b-2 c+d=5;\;f(2)=8 a+4 b+2 c+d=3$
Furthermore we know that those points are vertices so $f'(x)=0$
$f'(x)=3 a x^2+2 b x+c$ so we get other two conditions
$f'(-2)=12 a-4 b+c=0;\;f'(2)=12 a+4 b+c=0$
subtracting these last two equations we get $8b=0\to b=0$ so the other equations become
$$-8 a-2 c+d=5;\;8 a+2 c+d=3;\;12 a+c=0$$
from the 3rd we get $c=-12a$ substitute in the first two and in the end we get
$a= \dfrac{1}{16},b= 0,c=-\dfrac{3}{4},d= 4$
and the equation of the cubic is
$f(x)=\dfrac{x^3}{16}-\dfrac{3 x}{4}+4$
