This is actually not a difficult problem to solve, IF you think about what a tangent line means.
For example, consider the polynomial
y(x) = expand((x-1)*(x+1)*(x+2)*(x-2)*(x-2.5)*(x+2.5))
(I don't do homework problems for people. Sorry. So this is my own function. Feel free to look at what I wrote and to use it. But that would force you to think about what I wrote, and how to modify it to solve a different problem.)
The goal is to find lines that are doubly tangent to the curve. How would we define that in terms of mathematics? First, we need the derivative of the function y.
What do points of common tangency have in common? The slope MUST be the same at both points. Can we write that in mathematics? Assume the x xoordinates of the points of common tangency are at the locations u and v.
That just says the slope of the curve at x=u mst be the same as the slope at x=v. But we need more than that. We can define a line by two points along the line. Think of them as (u,y(u)) and (v,y(v)). If the tngent line connects tose two points, then we must have this simple relation (THINK ABOUT WHAT IT MEANS!)
eq(2) = y(u) + (v - u)*dy(u) == y(v)
Now we can just try using solve on the problem.
And that must fail (if you look at it, because we are effectively trying to solve an implicit polynomial of degree 13), so we must convert those results to floating point numbers to resolve them. Actually, we should be happy that solve finds these solutions.
uv = vpa([uvsol.u,uvsol.v]);
Again, 13 solutions were found overall. We want to exclude the cases where we have u==v. We also want to worry only about the cases where v > u, since we seem to have duplicates. That is, if we found the solution (u,v), then the solution (v,u) should be excluded, as it would be the same line. We can resolve both issues by including only those sets where u < v (thus excluding those where u>=v).
uv(uv(:,1) >= uv(:,2),:) = 
That leaves 6 distinct solutions. We can plot them simply enough, as
yfun = matlabFunction(y);
Those are the 6 lines of double tangency for this specific function. (At least for MY choice of function.) Change the function, and the solutions will be different. There may be different numbers of doubly tangent lines.
A nice feature of this solution is these lines are indeed the exact solutions to the problem, and they effectively encompass all possible solutions. (Exact to within floating point trash, that is.)