1
$\begingroup$

I want to write a mathematic formular that, given any number of monotonic arbitrary point, it will produce a monotonic smooth step function

Such as a figure below, I give it 2 point (the intersect point of red line and black curve). It will plot a graph as a function curve that pass all given points with derivative 0, so between each point will be like S curve

enter image description here

I want a function that was not being step, being a single function that could inverse and differentiate/integrate. So it could be use in forward and reverse calculation

Are there any function that fit this requirement?

$\endgroup$
  • 1
    $\begingroup$ It's not clear what other properties the functions need to have at infinity, but would taking a polynomial of the type $p(x)=(x-x_0)^2\cdots(x-x_n)^2$ and integrating $q(x)=\int p(x)dx$ be sufficient? You may have to introduce some constants in $p$ to achieve the correct heights. $\endgroup$ – Chrystomath Feb 13 at 17:26
  • 1
    $\begingroup$ I don't think there's any way to, in general, create a function with all your requirements. Nonetheless, I believe something like $f(x) = \sum_{i=1}^n a_i e^{b_i x^2 + c_i x}$ might be close. For one $i$, you could have $b_i = c_i = 0$ to get a constant. For all others, have $b_i \lt 0$ so the exponential has a max. at $x = -\frac{c_i}{2b_i}$ & goes to $0$ as $x \to \pm \infty$. This makes it approach a Kronecker delta type function. However, even if this could work, I'm not sure what sort of algorithm to use to find the values, especially for anything other than one or two very simple cases. $\endgroup$ – John Omielan Feb 13 at 20:57
  • $\begingroup$ @Chrystomath The first problem is, it can't control the height of each point more than 2 points. The second problem is, I think we can't inverse polynomial more than 4 degree can't we? Integrate that function will always give you a function with at least 5 degree $\endgroup$ – Thaina Feb 14 at 4:39
  • 1
    $\begingroup$ You can always find a polynomial that passes through given points with given directions. Look up Hermite interpolation for this. Or perhaps cubic splines may be sufficient. $\endgroup$ – Chrystomath Feb 15 at 9:25
  • $\begingroup$ @Chrystomath When it need to passed more than 4 point it then become many function that not continued which would be the last resort I would do. Are there any better solution? $\endgroup$ – Thaina Feb 16 at 11:47
2
$\begingroup$

One way to accomplish this would to begin with a basic transition graph such as

$$ T(x)=\frac{1-\cos(\pi x)}{2}\text{ for }0\le x<1 $$

which transitions between the points $(0,0)$ and $(1,1)$.

Transition Graph

Next, a graph for just the portion between two points $(x_k,y_k)$ and $(x_{k+1},y_{k+1})$ can be written in terms of the transition graph

$$ f_k(x)=\begin{cases}(y_{k+1}-y_k)T\left(\frac{x-x_k}{x_{k+1}-x_k}\right)+y_k&\text{ for }x_k\le x<x_{k+1}\\ 0&\text{ otherwise.}\end{cases} $$

enter image description here

Then the entire graph can be defined as

$$ F(x)=\begin{cases}y_1&\text{ for }x<x_1\\ \sum_{k=1}^{n-1}f_k(x)&\text{ for }x_1\le x<x_n\\ y_n&\text{ for }x\ge x_n\end{cases} $$

enter image description here

You can also experiment with different S-like curves $T(x)$.

ADDENDUM: For example, if we use my suggestion in the comment section to use $T(x)=x^2(3-2x)$ we can define the function $F(x)$ on the interval $[x_1,x_n)$ which satisfies all your requirements.

$$ F(x)=\sum_{k=1}^{n-1}(y_{k+1}-y_k)\left[\left(\frac{x-x_k}{x_{k+1}-x_k}\right)^2\left(3-2\left(\frac{x-x_k}{x_{k+1}-x_k}\right)\right)\right]\cdot\left[U(x_{k})-U(x_{k+1})\right] $$

where $U(x)$ is the unit step function.

$\endgroup$
  • $\begingroup$ This looks interesting, with it being a sort of spline function type approach. However, it doesn't seem to fully meet the OP's requirements that it be "... a single function that could inverse and differentiate/integrate". $\endgroup$ – John Omielan Feb 23 at 1:25
  • $\begingroup$ @JohnOmielan It's all that except for the "single function" part if the domain is restricted to $[x_1,x_n)$, by which I assume OP means something like Vandermond only non-decreasing on any interval. $\endgroup$ – John Wayland Bales Feb 23 at 1:59
  • 1
    $\begingroup$ If I understand your response correctly, I believe cubic splines, plus other similar type functions, could also be made to work as requested. $\endgroup$ – John Omielan Feb 23 at 2:03
  • $\begingroup$ @JohnOmielan $T(x)=3x^2-2x^3$ on the interval $[0,1)$ would work in place of the trigonometric example I used. $\endgroup$ – John Wayland Bales Feb 23 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.