2

I am looking for a mathematical function with growth controlled by a parameter. It would have two inputs:

  1. A growth scale, further called $w$
  2. An input ranging from $0$ to $1$, further called $x$

The function $f(x, w)$ should behave according to the following pattern.

If $w$ equals $2$, it would be a linear function (I think):

  • if $x = \frac{1}{2}$, then $f(x,w)$ should be $\frac{1}{2}$
  • if $x = 1$, then $f(x, w)$ should be $\frac{2}{2}$

If $w$ equals $3$, the growth increases:

  • If $x = \frac{1}{2}$, $f(x, w)$ should be $\frac{1}{3}$
  • If $x = \frac{3}{4}$ (or $\frac{1}{2} + \frac{1}{2} * \frac{1}{2}$), $f(x, w)$ should be $\frac{2}{3}$
  • If $x = 1$, $f(x, w)$ should be $\frac{3}{3}$

If $w$ equals $4$, the growth increases further:

  • If $x = \frac{1}{2}$, $f(x, w)$ should be $\frac{1}{4}$
  • If $x = \frac{3}{4}$, $f(x, w)$ should be $\frac{2}{4}$
  • If $x = \frac{7}{8}$, $f(x, w)$ should be $\frac{3}{4}$
  • If $x = 1$, $f(x, w)$ should be $\frac{4}{4}$

This behaviour should continue infinitely as $w$ increases. How would the function for this behaviour look like?

DMcMor
  • 10,059
  • 2
    I don't have an actual formula for this family of functions yet, though I may circle back later. That said, I did make this Desmos Plot to illustrate your function. Move the $w$ slider to change the function to show the points as you've outlined them. – DMcMor Jul 20 '20 at 19:29

1 Answers1

2

For $\;\displaystyle x=1-\frac 1{2^n},\ \ 1\le n<w\;$ you want the result $\displaystyle \frac nw\,$ while $x=1$ should have the image $1$.

$\displaystyle f(x,w)=-\frac{\log_2(1-x)}w\;$ for $x<1$ may be a starting point but probably not what you really wished...

The logarithm will indeed produce a singularity for $x=1$ instead of the $1$ value.
To illustrate the problem let's complete DMcMor's clear illustration in the case $w=5$ :

w=5 picture

The way your points are produced becomes pretty clear :

  • the middle of $\;(0,0)-(1,2/w)\;$ for the first point $\;(1-1/2,1/w)\;$
  • the middle of the previous point and $\,(1,3/w)\;$ for the second one
  • and so on until getting to $(1,w/w)$ and producing $(1-1/2^{w-1},(w-1)/w)$

Clearly we could continue the process as illustrated and produce the next $\displaystyle (1-1/2^n,n/w)$ points up to infinity.

Since you want the value $1\,$ for $\,x=1\,$ I would suggest the function :

$$f(x,w)=\begin{cases} -\dfrac{\log_2(1-x)}w&x\le 1-\dfrac 1{2^{w-1}}\\ 1-\dfrac {2^{w-1}(1-x)}w&\text x>1-\dfrac 1{2^{w-1}}\\ \end{cases}$$ with a linear interpolation for the last segment as in the illustration.

You could too repeat the previous segment vertically shifted by $\dfrac 1w\,$ to get the last one (your suggestion I think) : $$f\left(x-\frac 1{2^{w-1}}\right)+\frac 1w$$ or for a smoother derivative at $\,1-1/2^{w-1}\,$ prefer the symmetric : $$2-\frac 2w-f\left(2-\frac 1{2^{w-2}}-x,\,w\right)$$

  • 1
    (perhaps that a linear interpolation for $,1-\dfrac 1{2^{w-1}}<x<1,$ would satisfy you... You may have to modify too the behavior for $x<\dfrac 12$) – Raymond Manzoni Jul 20 '20 at 19:53
  • 1
    This solves my problem indeed! As soon as $1-\frac{1}{2^{w-1}} < x < 1$ is true, I'm remapping $x$ to the range $1-\frac{1}{2^{w-2}} < x < 1-\frac{1}{2^{w-1}}$ to repeat the last step until $x$ reaches $1$. I think for this final range, a custom condition is required anyways, so I'll accept the answer. However, if anybody comes up with an answer that doesn't involve such a special case, I will accept that one instead. I don't see an answer like that coming though. – narranoid Jul 21 '20 at 08:46
  • 2
    @narranoid: I edited my answer with more details and altenative suggestions but not without special case! :-) You may too try the method exposed here to get one 'smoothed' function up of two. Excellent continuation, – Raymond Manzoni Jul 21 '20 at 13:02
  • 1
    Awesome! That's very helpful! As I said, I don't even think there is a solution without such a special case (I'm no math guru though, so who knows :p), but your answer is now a very good reference to explore the options for bridging that final range to $1$. Thanks! – narranoid Jul 21 '20 at 15:12