# Functional equations of (S-shape?) curves

I am looking for the way to "quite easily" express particular curves using functional equations.

What's important (supposing the chart's size is 1x1 - actually it doesn't matter in the final result):

• obviously the shape - as shown in the picture;
• there should be exactly three solutions to f(x) = x:
x=0, x close to or equal 0.5 and x=1;
• (0.5,0.5) should be the point of intersection with y = x;
• it would be really nice, if both of the arcs are scalable - as shown in the left example (the lower arc is more significant than the upper one).

I've done some research, but nothing seemed to match my needs; I tried trigonometric and sigmoid functions too, they turned out to be quite close to what I want. I'd be grateful for any hints or even solutions.

P.S. The question was originally asked at stackoverflow and I was suggested to look for help here. Some answers involved splines, cumulative distribution functions or the logistic equation. Is that the way to go?

-
Presumably you also want the function to never go outside the range $[0,1]$, right? – Rahul Jul 15 '12 at 14:31
That's right. It shouldn't go outside the range [0,1] for any x from [0,1]. – Michal B Jul 15 '12 at 14:34
The graph on the left suggests that you don't insist in having a tangent line at 0.5 (the curve appears to have a corner there). If so, then you essentially want two functions: one of [0,0.5] and.another in [0.5,1]. The boundary values are given, and apparently the first function should be convex while the other concave. Looks like a job for two parabolas. – user31373 Jul 15 '12 at 14:39
It would be best if you could elaborate on how the things you've looked up so far didn't match your needs. Your problem as given is underspecified (there are lots of functions that will do the job), and it would help to get an idea of what "soft" or "aesthetic" features you're looking for to pick the best one. – Rahul Jul 15 '12 at 14:41
@Leonid the curves should be used for image processing so I guess it would be better to avoid corners? Anyway, thanks for suggestion, that's pretty simple idea. – Michal B Jul 15 '12 at 14:48

## 2 Answers

For what it's worth, the interpolating polynomial through the points $(0,0), \big(\!\frac14,a\big)$, $\big(\!\frac12,\frac12\!\big)$, $\big(\!\frac34,b\big)$, and $(1,1)$ is $$p(x) = \left(-7+16 a+\frac{16 b}{3}\right) x+\left(\frac{136}{3}-\frac{208 a}{3}-\frac{112 b}{3}\right) x^2+\left(-80+96 a+\frac{224 b}{3}\right) x^3+\left(\frac{128}{3}-\frac{128 a}{3}-\frac{128 b}{3}\right) x^4.$$ However, it overshoots the range $[0,1]$ on similar input to the first image. Below I picked $a = \frac18$ and $b = \frac{13}{16}$.

-
You might also consider the Hermite interpolant $$p(x)=(2 b-2 a) x^4+(5 a-3 b-2) x^3+(b-4 a+3) x^2+a x$$ The polynomial passes through those three points and has the property that $p^\prime(0)=a$ and $p^\prime(1)=b$. – J. M. Jul 15 '12 at 15:28
Thanks, the idea seems to be nice, although the so called "overshooting" is a major problem. I want the curve to behave as it behaves in Curves tool in image processing software (Gimp, Photoshop etc.) - generally speaking it behaves in a far softer way. Here is another example (with x and y in [0,255]), on a verge of acceptance: ubuntuone.com/2GtSMuciatWC99P1EhsMWS - note that the curve leans gently to the edges. – Michal B Jul 15 '12 at 15:41
And thanks for the Hermite suggestions. – Michal B Jul 15 '12 at 15:42

Have you tried polynomial interpolation? It seems that for 'well-behaved' graphs like the ones you are looking for (curves for image processing?), it could work just fine.

At the bottom of this page you can find an applet demonstrating it. There is a potential problem with the interpolated degree 4 curve possibly becoming negative though. I'll let you know once I have worked out a better way to do this.

EDIT: The problem associated with those unwanted 'spikes' or oscillations is called Runge's phenomenon . I would guess that image manipulation programs like Photoshop actually use Spline interpolation to find the curves.

-
Yes, I'm looking for curves for image processing. Thanks for the suggestion, I will take a closer look at it! – Michal B Jul 15 '12 at 14:35
Just edited my answer with some extra info and another possible method. Hope this helps! – us2012 Jul 15 '12 at 14:40