# Creating a graph given condition of local minima and maxima

I had a question that goes like this:

Let $$m$$ be the number of local minima and $$M$$ be the number of local maxima. Can you create a function where $$M > m + 2$$ ? Graph.

I tried graphing it using piecewise function and I improvised it by doing 3 parabolas opening downward and 1 parabola opening upward with each horizontal line separating them.

I was just wondering if there is an easier way in creating a graph given such condition?

Such a function is not possible if you want a continuous function, because between 2 local minumums has to be a local maximum, and vice versa. So local minumums and maximums always alternate (if you exclude cases where $$f(x)$$ is constant on an interval).

If you allow discontinuous functions, you can use

$$f(x) = \lfloor x\rfloor -x$$

It has a local maximum at each integer ($$f(x) = 0, \forall x \in \mathbb Z$$), but no local minimum at all: for a given $$x_0 \in \mathbb R$$ with $$\lfloor x_0\rfloor = k$$, choose any $$x \in (x_0, k+1): f(x_0) = k - x_0 > k - x = f(x)$$, so $$x_0$$ can't be a local minimum.

• it makes perfect sense because a function does not need to be continuous to have local minima and maxima – Codex Oct 19 '18 at 14:56

Because we need a local maxima and minima, we can choose a third degree polynomial because its derivative has two roots So can't we create a function that has two roots then take its antiderivative? Let y and z be roots of the function. $$z < M-2$$. So lets get $$z=M-3. f(x)=(x-M)*(x-(M-3)). f(x)=x²+3x-xM-xM-3M+M² =x²+3x-2xM-3M+M².$$ antiderivative$$(x²+3x-2xM-3M+M²)=(x³/3)+(3x²/2)-Mx²-3Mx+M²x + C$$. I need help! First time using this, don't know how to set up equations.

• it cant be only a third degree polynomial since you need larger maxima than minima so the least amount that you can do is 3 maxima and no minima. – Codex Oct 19 '18 at 4:42
• I think you misunderstand the question. $m$ and $M$ are the number of maxima/minima, not the $x$-values on which they are taken. – Ingix Oct 19 '18 at 7:21
• Oh, I completely misunderstood the question. M is the number of maximas, not the maxima. Sorry – Matheus Andrade Barreto Oct 19 '18 at 14:35