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:

(1)

Changing k to 1/k gives:

(2)

And this simplifies to:

(3)

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:

(4)

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:

### Like this:

Like Loading...

*Related*

This entry was posted on March 6, 2011 at 4:42 pm and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.

January 2, 2012 at 5:37 pm |

Hi Dino, can you post the Wolfram Alpha text formula that you used to generate the 21st Century plot above? I came up with this:

plot ((k(1/2*(-sgn(k)+1))-1) t)/(k t-1-k*(1/2*(sgn(k)+1))) k = -10 to 10 t = 0 to 1

And it looks equivalent to your formula, but there is a small discontinuity along k=0 which does not show up in your plot. I’m not sure what the ‘x’ character that appears in your formula means. I assume that it’s multiplication, but other instances of multiplication in your formula are implicit.

January 2, 2012 at 5:48 pm |

It looks like the formula is correct, I also see the glitch you mention, but I think that is a bug in Wolfram Alpha. The x you mention was inserted by Wolfram Alpha, I guess because it could not fit the expression in one line (so it is times t and explicit because the t is underneath). Wolfram Alpha does not seem to format it like that now.

You may want to try it in another package such as Maxima.