News for hackers. Stuff that matters.
Re:A Quirky Function by johnp_ on Saturday June 25, 2016 @03:42PM (#11977673)
Not a math student, but I tried it anyway:

  0 for x<=0
  1 for x>=1
  e^(1 - 1/(1 - (x - 1)^2)) else
Does this work? Does the last condition mean smoothness (C∞)?

(Not a native english or math speaker, so please forgive my ignorance)

edit: HN ate the link :/ wolframalpha code:

  Piecewise[{{0, x <= 0}, {1, x >=1}}, {e^(1 - 1/(1 - (x - 1)^2))}]
Re:A Quirky Function by S4M on Sunday June 26, 2016 @04:26AM (#11979891)
That one will not work because the function is not C∞ [I didn't know how to make that symbol] in 1. it's first derivative is 0 in 1, but that's only because the derivative for 1-1/(1-(x-1)^2) is 0 in 1, that will not be the case for the second derivative.

If you look at what's going on in 0, the derivative of any order is something like phi(x) e^(1 - 1/(1 - (x - 1)^2)) where phi is a rational function, and thus it will always be 0 in 0 (the exponential always beats a rational function).

so the answer is, similarly to what kmill posted:

0 for x <=0 1 for x >= 1 1/(1+exp(K(x))) else

With K(x) = (x-1/2)/(x(x-1))

(x-1/2 is added to create a change of sign between 0 and 1)

in 0, K(x) -> ∞, so 1/(1+exp(K(x)) -> 0, and in 1, K(x) -> -∞, so 1/(1+exp(K(x)) -> 1.

To see that the function is C∞, you can check that the n-th derivative 1/(1+exp(K(x))) is of the form phi(x) exp(K(x)) 1/(1+exp(K(x)))^(n+1) where phi is a rational function, and then verify that the n-th derivative is 0 in 1 and 0.