# Reconstructing a function from its critical points and inflection points

For my class I have sketched the following graph which depicts certain critical points and curvatures including one local maximum, minimum, two inflection points and a saddle point (which is an inflection point as well):

I would like to draw this graph (and the graphs of the first and second derivate as well) in LaTeX but I need a possible corresponding function. At first I was considering to obtain such a function with the properties of the derivatives based on the critical points but that would be way too complicated with so many equations. Hence I was thinking about using a piecewise function (seems like two functions from $\mathcal{O}(x^2)$ and one from $\mathcal{O}(x^3)$ to mimick the behaviour from the graph) and glueing those pieces together such that the entire function is continuous.

What would you do to reconstruct such a function for plotting purposes?

EDIT

There are no specific values $x$ and $f(x)$ so we're free to take values which make the reconstruction of the function as simple as possible as long as $f$ remains two times differentiable.

• Do you know the values of $f(x)$ and $x$ for all the critical points and inflection points? – HDE 226868 Nov 21 '15 at 15:41
• Because it is just a sketch to show how derivatives behave in the neighbourhood of critical points I left out specific values of $x$ and $f(x)$ hence you can pick whatever values that make this easier. – Christian Ivicevic Nov 21 '15 at 15:47
• What's the difference between "inflection point" and "saddle point"? – Paracosmiste Nov 21 '15 at 15:51
• @whatever Every saddle point is an inflection point but not the other way round if I am not mistaken. The slope at a saddle is always zero while it does not have to be zero for inflection points. – Christian Ivicevic Nov 21 '15 at 15:57
• Ah ok I usually just call them inflection points but maybe saddle point is better. – Paracosmiste Nov 21 '15 at 16:00

The derivative has to be zero at 3 points, and at one of them, it has to have a double zero to get that saddle point. This is a total of 4 zeros for the derivative, meaning it has to be a fourth order polynomial where the zeros are at known locations, meaning I can write it as:

$$f'(x) = (x-x_1)(x-x_2)(x-x_3)^2,$$ where $x_1$ is the max point, $x_2$ is the min point, and $x_3$ is the saddle point. You can plug in some some concrete values and get a form for $f'$, then integrate. So the most general formula for your curve is

$$f(x) = \int(x-x_1)(x-x_2)(x-x_3)^2\;dx$$

I used some concrete values ($x_1=1/8,\;x_2=1/2,\;x_3=1$) and got

$$f(x) = 1/16 x - 3/8 x^2 + 37/48 x^3 - 21/32 x^4 + x^5/5$$

Take a look here so you can put in your own values if you want and get the polynomial coefficients for LaTeX use.

EDIT If you really want that the function must be zero and have zero derivative at $x_2$, then you can begin as mentioned in the comments, and add in an offset:

$$g(x) = f(x) - f(1/2)$$

So clearly $g(1/2)=0$, but now $g(0)\neq 0$. However, we can just move the curve to the right by the correct amount now to get the curve to go through the origin. This requires finding where $g(x_4)=0$ (a small shift in this problem of about $x_4=-0.01346503$, this has a closed form in terms of radicals), but once we have that, we form a shifted function

$$h(x) = g(x+x_4).$$

The function $h$ satisfies all the requirements, as you can see through the links below. If you want the final, exact coefficients, they are really messy (here). You can also get approximate coefficients using the decimal approximation above. With the approximation, $h(0)\approx 10^{-10}$ which isn't exactly zero, but it is graphically indistinguishable from zero for your plot.

• This does not have the double root (of f) at approximately x=1/2 that would be required to match the sketch. (Your function dips below the x-axis, while the sketch does not.) – kccu Nov 21 '15 at 16:29
• Good point, but I wasn't sure if this was important to the OP or not. OP describes only inflection points and maxima and minima and saddle points. Zeros of the function itself are not mentioned explicitly, so I interpreted the request as one that addresses the derivative of $f$, not any explicit values of $f$ itself. – rajb245 Nov 21 '15 at 16:47
• @kccu Well you can just add a constant to $f$ s.t. $f(x_2)=0$ and it should be $7/7680$ if you work with rajb245's points $x_1,x_2,x_3$ - I am currently experimenting with other numbers for a better scaling but the general idea of this approach is definitely good. – Christian Ivicevic Nov 21 '15 at 16:52
• @Christian Ivicevic Yes, but then the function doesn't pass through the origin as depicted. Perhaps this is unimportant to the OP though. – kccu Nov 21 '15 at 17:11
• @ChristianIvicevic please see above for some edits that basically shift my original proposal upwards to get $f(x_2)=0$, then rightwards to get $f(0)$=0. This is basically just moving the origin around in your plots, which is why I didn't include these steps previously. I didn't think the exact location of the origin mattered in a sketch. – rajb245 Nov 22 '15 at 16:16