I was playing with my sigmoid function, and Wolfram Alpha, seeing how the formula integrated and differentiated and so on. One thing that’s a bit awkward with it is how the k value is such that you need a large value for a straight line, and a small value for a sharp curve.
So I tried to replace k with 1/k to see what happened. I had never tried to simplify the equation from here, never occurred to me to try. Well it turns out that the extra divisions simplify and yields a potentially superior function.
It behaves fine for k=0, and the larger the value of k, the sharper the curve.
Here is the original function:
Changing k to 1/k gives:
And this simplifies to:
The new formula works for values of k great than 0. One disadvantage over the previous formula is that to work cleanly a variant needs to be used to create curves that other way (if you recall, the original version is invalid for k values between 0 and -1). However accepting this and using different formulae for positive and negative values of k will also allow us to remove the invalid zone between 0-1. Here is the version that works for negative k, valid from 0 to minus infinity:
So we have two cases and two formulae, but as a challenge I wanted to write it as a single formula so I could get Wolfram Alpha to plot it. One way is to use the sign function, that returns -1, 0 or 1 depending on the sign of a number. A bit of playing around gave me:
OK, it seems to be getting complicated, but in code you would use two separate formulae with an if statement. But here I am trying, for fun, to get Wolfram Alpha to plot the thing. The formula itself gives a lot of information. It is also interesting because in this form we have taken a discontinuous function and made it continuous by cutting out a piece. Anyway, never mind that, here’s the final result: