Normalise exponential numbers between 0 and 1

278 Views Asked by At

I'm creating a fractal visualisation.

I want the colour per point to be based off the iteration final value, $f(z_{n})$, instead of the traditional: number of iterations before reaching a cut-off (usually when any component, real or imaginary, of $z$ is $ > 2$).

How could I from from something like:

0, 1, 4, 9 to:

0, 0.1, 0.2, 0.25

I don't expect the number 1 to ever be reached, in the output set.

1

There are 1 best solutions below

4
On

I don't understand exactly what your sequence is, but if $v$ is your final value you can apply

$$h(v) = 1 - e^{-\alpha v}, \alpha \gt 0$$

to $v$ and get roughly what you've described, i.e. it takes $0$ to $0$, increases as $v$ increases, and goes to $1$ as $v$ gets infinitely large. $\alpha$ is a tunable parameter that controls how quickly $h$ increases. Since you're creating a visualization I'd say just start with $\alpha = 1$ and play with it to get the result you like best.

BTW you could also use any of $$h(v) = 1 - e^{-\alpha v^2}$$ $$h(v) = 1 - e^{-\alpha v^3}$$ $$h(v) = 1 - e^{-\alpha v^{1/2}}$$

which will have the same properties but give better discrimination of either larger or smaller values. You can see that generically these look like

$$h(v) = 1 - e^{-\alpha v^\beta}, \alpha \gt 0, \beta \gt 0$$

so you've now got two parameter to tune your images.


I got curious to see how these looked and created a Desmos graph. You can go here to see it. If you look on the left hand side, towards the bottom, there are two sliders there labelled $a$ and $b$ (corresponding to $\alpha$ and $\beta$ here). You can see how different values of them affect your mapping.