I'm developing a script to connect point with curved lines.
The points are in ascendent order in x-axis like this:
I'm studying Bezier Curves, but I don't think it's the best solution (see https://www.geogebra.org/m/qcnExXbn):
But, instead of straight lines, I just would like to connect these points in a smooth way.
Could anyone help me with a formula or algorithm?





Given an arbitrary set of $n$ points, it's possible to find the equation of a unique polynomial of degree at most $n-1$ that passes through all $n$ points.
Let's consider a very simple example; say we we wanted to find the parabola that passes through the points $(-4,2)$, $(-2,-1)$, and $(1,1)$.
The general equation of a parabola is $$y=ax^2+bx+c$$ so we can substitute the $x$- and $y$-coordinates of the three points we have to create a system of three equations with three unknowns, like so: $$\begin{align} 2&=16a-4b+c \\ -1&=4a-2b+c \\ 1&=a+b+c \end{align}$$ Solving this system, we find that $a=\frac{13}{30}$, $b=\frac{11}{10}$, and $c=\frac{-8}{15}$. The parabola $y=\frac{13}{30}x^2+\frac{11}{10}x-\frac{8}{15}$ does indeed pass cleanly through all three points, so we're done.
And of course, you could do this with a system of six equations with six unknowns as well, but that would just take a little longer than this example.
Edit:
Mathematica reveals that the interpolating polynomial for those six points is approximately $$y=1.51771x^5-10.5198x^4+23.6478x^3-17.2688x^2-0.696339x+2.81946$$ The graph of that function looks like this: