What's a simple periodic function with a smooth curve?

429 Views Asked by At

Is there a simple way to produce a smooth repetitive oscillation, using just basic arithmetic expressions, without trig functions, powers, square roots, etc.?

The numbers don't have to mean anything or approximate anything, it should just plot to something wavy.

I've spent lots of time searching but can only find things like the Taylor series, Bézier curves, etc. which are fairly complex because they're trying to calculate something in particular rather than just produce something curvy.

Thanks for your help.

3

There are 3 best solutions below

10
On BEST ANSWER

$$(x\bmod 1)(1-(x\bmod 1))(-1)^{\lfloor x\rfloor}.$$ You cannot spare the modulo.

enter image description here

Note that this is a quadratic Bezier curve.

0
On

Chebyshev polynomials of the first kind wiggle up and down nicely. There are some pictures on the Wikipedia page.

They only require multiplication and addition.

If you want more wiggles, you can either increase the degree or string together several functions of lower degree.

If you want infinite wiggles that go on forever, you can construct periodic versions of the Chebyshev polynomials by using the mod function.

See also this question.

1
On

If the floor function bothers you, you can use $$ (x\%2)*(x\%2\, - \,1)*(x\%2\, - \,2) $$ Here $x\%2$ denotes $x$ mod 2. This is a string of cubic (Bezier) curves.

enter image description here