I want to make a few curves from 0 to 1 with a different growth acceleration. So I tried this:
float y_mlt = 1/exp(-q/interations); // slow grow on the first stage but fast grow in second
float a=0.582;
float y_add=a/interations;
for (int x; x<interations; x++) {
y = y*y_mlt + y_add;
}
y result is 1 - works
float y_mlt = exp(-q/(interations)); // non linear fast grow on the first stage but slow grow in second
float y_add=(q+a)/interations;
for (int x; x<interations; x++) {
y = y*y_mlt + y_add;
}
y result is 1 - works
I find more curves for different values of q and a
- q=1 - - - - - - a=0.582
- q=2 - - - - - - a=0.313
- q=3 - - - - - - a=0.1559
- q=4 - - - - - - a=0.0743
- q=5 - - - - - - a=0.0335
The calculation of a was made by more trying, in a primitive way.
I want to generalize, so what it's the relation between q and a ?
iterations can have any int value, for 722 I get graph of the curves using a=0.582
Denoting $y$ on $k$-th iteration as $y_k$,
y_mltas $u$ andy_addas $v$, number of iterations as $N$, we have recurrent relation $y_{k + 1} = u \cdot y_k + v$, with initial conditions $y_0 = 0$ and require $y_N = 1$.General solution of this relation is $y_n = c u^{n - 1} + v \frac{u^n - 1}{u - 1}$. $y_0 = 0$ gives $c = -uv$, so we have $y_n = v \cdot \frac{-u^{n + 1} + 2u^n - 1}{u - 1}$.
From this, $y_N = 1$ gives $v = \frac{u - 1}{-u^{N + 1} + 2u^N - 1}$.
Substituting $v = \frac{q + a}{N}$ and $u = \exp(-q / N)$, we get expression for $a$: $$a = N \cdot \frac{\exp(-q / N) - 1}{-\exp(-q / N)^{N + 1} + 2\exp(-q/N)^N - 1} - q$$