# What is the smallest degree of polynomial so that its graph includes four extreme points

Let there be four points (-2,-5), (5,-6), (6,1), (-1,2) that are extrema (maxima / minima). I am trying to find a polynomial that includes these extreme points. I tried

p[x_] = Sum[c[i] x^i, {i, 0, 7}];
p[x] /. Solve[{p[-2] == -5, p[5] == -6, p[6] == 1, p[-1] == 2,
p'[-2] == 0, p'[5] == 0, p'[6] == 0, p'[-1] == 0}, {c[0], c[1],
c[2], c[3], c[4], c[5], c[6], c[7]}]

{-(112909/16464) - (1227475 x)/98784 + (1360085 x^2)/592704 +
(6599065 x^3)/1185408 - (292265 x^4)/296352 - (310447 x^5)/592704 +
(13175 x^6)/84672 - (13175 x^7)/1185408}


What is the smallest degree of a polynomial so that its graph includes the four points as extrema?

• You have 8 conditions, therefore you need a polynomial with 8 parameters, that is a 7 degree polynomial. Commented Aug 12, 2023 at 10:06
• @DanielHuber Well, that's the general case which holds "almost always" (in the mathematical sense). It could have a lower degree for some constraints (quite obviously). One could use Exists and such to figure out constraints on these constraints to succeed with a lower degree. Commented Aug 12, 2023 at 10:52

• Use the form InterpolatingPolynomial[{{x1,f[x1],f'[x1]},{x2,f[x2],f'[x2]},...}]

• We use f[x]==y,f'[x]==0,f''[x]!=0 to verify the extreme points.

Clear[pts, data, f];
pts = {{-2, -5}, {5, -6}, {6, 1}, {-1, 2}};
data = PadRight[#, 3] & /@ pts;
f[x_] = InterpolatingPolynomial[data, x] // Expand
f /@ pts[[;; , 1]] == pts[[;; , 2]]
f' /@ pts[[;; , 1]]
f'' /@ pts[[;; , 1]] != 0 // Thread


## Reply to comment

Plot[f[x], {x, -3, 7}, Mesh -> {pts[[;; , 1]]},
MeshStyle -> Directive[Red, AbsolutePointSize[6]],
AspectRatio -> Automatic,
Epilog -> {EdgeForm[Red], FaceForm[LightGreen], Opacity[.8],
Polygon@pts}]


• {{-2, -5}, {5, -6}, {6, 1}, {-1, 2}} is a square. How can I draw it and show it. Commented Aug 13, 2023 at 2:07
• @JohnPaulPeter pts = {{-2, -5}, {5, -6}, {6, 1}, {-1, 2}}; poly = Polygon[pts]; Graphics[{EdgeForm[Red], FaceForm[LightGreen], poly}] Commented Aug 13, 2023 at 2:10
• Draw in the same graph of f[x]? Commented Aug 13, 2023 at 2:12
• Thanks. Let's me try. Commented Aug 13, 2023 at 2:19
• @JohnPaulPeter I see it now. See my updated. Commented Aug 13, 2023 at 2:22
pts = {{-2, -5}, {5, -6}, {6, 1}, {-1, 2}};
derivs = {0, 0, 0, 0};
specs = MapThread[{{First@ #1}, Last@ #1, #2}&, {pts, derivs}];
InterpolatingPolynomial[specs, x] // Expand


• f'[5]==-769/42, not equal to 0. Similar to f'[-2], f'[6], f'[-1] Commented Aug 12, 2023 at 14:32
• @Laurenso Good point, fixed. Commented Aug 12, 2023 at 23:34
val = {{-2, -5}, {5, -6}, {6, 1}, {-1, 2}};

f = Interpolation[val]

Series[f[x], {x, 0, 7}]


$$\frac{51}{14}-\frac{37 x}{84}-\frac{25 x^2}{14}+\frac{25x^3}{84}+O\left(x^8\right)$$

  (f[#1] == #2 &) @@@ val
{True, True, True, True}