2
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ How about a rotated sine or cosine? $\endgroup$ – user247327 Nov 20 '17 at 17:59
  • $\begingroup$ What do you mean? $\endgroup$ – MasterID Nov 20 '17 at 18:00
  • $\begingroup$ He means reflected across $y=x$. $\endgroup$ – Aqua Nov 20 '17 at 18:06
  • $\begingroup$ But then it won't be a function anymore because for a single x it will have multiple values. I will try to rotate 45 degrees and check its properties. $\endgroup$ – MasterID Nov 20 '17 at 18:08
2
$\begingroup$

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)$.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Any chance of making the function differentiable? I forgot to say it =( $\endgroup$ – MasterID Nov 20 '17 at 20:26
  • $\begingroup$ @MasterID Hmm. Perhaps there's a way to smooth it out. What do you need this for? $\endgroup$ – Théophile Nov 20 '17 at 21:37
  • $\begingroup$ 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(10*sin^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(10*sin^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) $\endgroup$ – MasterID Nov 21 '17 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.