I have a set of points $\left\{ \left(−\frac{6}{4}, 0\right), \left(−\frac{4}{4}, −\frac{\sqrt{6}}{3}\right), \left(−\frac{3}{4}, −1\right), \left(−\frac{2}{4}, −\frac{\sqrt{6}}{3}\right), \left(\frac{0}{4}, 0\right), \left(\frac{2}{4}, \frac{\sqrt{6}}{3}\right), \left(\frac{3}{4}, 1\right), \left(\frac{4}{4}, \frac{\sqrt{6}}{3}\right), \left(\frac{6}{4}, 0\right) \right\}$. I want to find a sinusoidal-esque wave that fits these points.

The function $f(x) = \sin\left(\frac{2 π}{3} x\right)$ has the correct period/wavelength and amplitude, but is too wide at the wave peaks/troughs. Is there a simple way to modify the sine function to be a little less steep at the midpoints between extrema and a little narrower at the extrema?

Graph of points in red, with a basic sine wave plotted in blue.

As an additional constraint, I'd like the derivative of $f(x)$ to not have extra twists/peaks/troughs in it. I believe a more mathematical way of stating that goal is that the second derivative should have no more zeros than the function itself.

  • $\begingroup$ For the first arch of the curve, you can use $$\left(\sin\left(\frac23\pi x\right)\right)^a \qquad a := \frac{\log(\sqrt6/3)}{\log(\sqrt3/2)}=\frac{\log(2/3)}{\log(3/4)}=1.409420\ldots$$ Any (non-negative) $a$ would work to reach $0$ and $1$ at the correct spots; the particular $a$ stretches the sine function's value of $\sqrt{3}/2$ to the desired $\sqrt{6}/3$. To get other arches, because negative numbers raised to irrational powers are problematic, sprinkle-in some absolute values and sign changes. $\endgroup$
    – Blue
    Feb 21 at 23:19
  • 1
    $\begingroup$ @Blue Something like $\sin\left(\frac23\pi x\right)\left|\sin\left(\frac23\pi x\right)\right|^{a-1}$ ? $\endgroup$
    – Neil
    Feb 22 at 0:30
  • 1
    $\begingroup$ @Neil: That should do it! :) ... And one can write $a-1$ as $\dfrac{\log(8/9)}{\log(3/4)}$ $\endgroup$
    – Blue
    Feb 22 at 0:58

3 Answers 3


With so few points, there will be many ways to do this.

However you will have to decide if the results "look sinusoidal enough" for you.

One way is to include higher odd harmonics one by one. Here's just the third harmonic:

$$f(x) = (1 + a) \sin\left(\frac{2 \pi}{3} x\right) - a \sin\left(3\frac{2 \pi}{3} x\right)$$

For that you just solve for $a$ for one of your "shoulder points".

Other ways might include an infinite series of odd powers of $f$,

$$g(x) = \sum_{i=0, 1, 2...} a_i f^{2i+1}(x) $$

But for this one I think unless you are very lucky, you'll need many aterms to get close enough.


Python script for plot

import numpy as np
import matplotlib.pyplot as plt

points = ((-6/4, 0), (-4/4, -6**0.5/3), (-3/4, -1), (-2/4, -6**0.5/3),
          (0/4, 0),
          (2/4, 6**0.5/3), (3/4, 1), (4/4, 6**0.5/3), (6/4, 0))

xp, yp = np.array(points).T

a = -0.055  # approximately

x = np.linspace(-2, 2, 1001)

f1 = np.sin((2 * np.pi / 3) * x)

f2 = (1 + a) * np.sin((2 * np.pi / 3) * x) + a * np.sin(3 * (2 * np.pi / 3) * x)

fig, ax = plt.subplots(1, 1)

ax.plot(xp, yp , 'or')
ax.plot(x, f1)
ax.plot(x, f2)
  • $\begingroup$ I added an additional constraint on the shape that I want. Hopefully it narrows the field of possibilities without eliminating it completely? $\endgroup$
    – Lawton
    Feb 21 at 16:23
  • $\begingroup$ @Lawton I've added a plot. $\endgroup$
    – uhoh
    Feb 21 at 22:54

What about piecewise-defined functions? If those work for you, you can use the periodic version of interpolation by cubic splines. That would most likely satisfy the condition you want on the second derivative, as the second derivative of cubic splines is continuous and is piecewise linear.

Remark: One could in principle consider the convolution between the sine functions and some other function to hope for some averaging effect... But that would just give a rescaled version of the sine wave, so it would not work just like that :)


You could input the points into a calculator and find a sinusoidal regression similar to a linear regression. Then check to see if the graph actually includes your desired points. This may be a good starting point to see if such a curve exists.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .