2

I want to create a function that have multiple (infinite) steps like this one:

$x+\sin x$

enter image description here

But i want to have control of two things: how quickly it increases and when the (soft) steps occur.

For example: for the function $\frac{1}{(1+e^{-x})}$ which has the following graph: enter image description here

We can make the step rise faster by multiplying x by a big number.

One possible way to write such a function is writing it as a sum of previous function: $\sum_{i=0}^4 \frac{1}{1+e^{-(x-i)*5}}$

enter image description here

Unfortunately I can't use this kind of series to solve my problem. How can I obtain such function?

MasterID
  • 145

2 Answers2

2

I would glue together many stair steps like this one, $\dfrac1{1+e^{-x}}$:

enter image description here

to give:

enter image description here

I used the function

$$f(x) = h\left(\left\lfloor\left(p x-k\right)-\frac12\right\rfloor+\frac{1}{2m}\left(\frac{1}{1+e^{-2\alpha r(x)}}-\frac12\right)+1\right)$$ where $$r(x)=\left(\left(p x-k\right)-\frac12\right)-\left\lfloor\left(p x-k\right)-\frac12\right\rfloor-\frac12$$ and $$ m=\frac{1}{1+e^{-\alpha}}-\frac12. $$

It looks a bit complicated, but it is really just gluing together pieces of stair steps. It passes through the point $(k,0)$, and you can adjust the parameters:

$h$: height of step
$p$: horizontal scaling
$k$: horizontal offset
$\alpha$: sharpness of step

In the above picture, $(h,p,k,\alpha) = (\frac25,2,0,10)$.

Théophile
  • 24,627
  • Any chance of making the function differentiable? I forgot to say it =( – MasterID Nov 20 '17 at 20:26
  • @MasterID Hmm. Perhaps there's a way to smooth it out. What do you need this for? – Théophile Nov 20 '17 at 21:37
  • Sorry, I couldn't answer yesterday. I'm trying to solve discrete logarithm by converting to an continuous problem. If i represent any number B by a function B(x) = exp(10sin^2(xPi/2 * 1/b)) i will have a periodic function that will be near 0 all the time, except when near 'b' which will go to 1. If C(x) = exp(10sin^2(xPi/2 * 1/c)). MOD(x) = C(x)+B(x) then we will have an function which the distances (lets call it a A) of gaussians can represent A = B (mod C) or -A == B (mod C). I need this step function to somehow represent powers B and then try to find A=B^k (mod C) – MasterID Nov 21 '17 at 09:15
0

Step one is to first use modulo.

$a = mod(x, 1)$

Then we can use this sigmoid function with the value we got from the modulo operation to have the sigmoid loop over and over.

$b = \frac{1}{1+\frac{a}{1-a}^{-2}}$

And finally we need to step each loop up by doing

$floor(x) + b$

but if we want to control the width height and curve we can do

$w = 1, h = 1, c = 3$

$a = mod(\frac{x}{w}, 1)$

$b = \frac{1}{1+\frac{a}{1-a}^{-c}}h$

$floor(\frac{x}{w})h + b$