Algebra Question - finding base val of exponential

Hello, I’m struggling with some algebra. As I understand it, linear:


And exponential / logarithmic:


So the end result I’d like is scaling linear values to an exponential value inside a set range - initially for HZ, but also interaction with LFOs etc. Something like this;

ofMapExponential(value, minimum, maximum, exponent);

My question then is how to solve this;

a = pow(b, c);
c = log(a)/log(b);
b = ?

With an algebraic solution as follows;

From the look of your graph, maybe you want something like:

f(t) = (minimum-maxium)*e^(-t/tau) + maximum (with t>= 0)

And you chose tau based on the linear range you’re considering, knowing that f(tau) will be 63% of the mapped range you want (eg. if minimum = 0, maximum = 100, f(tau) == 63).

And huh… if you’re just asking how to retrieve b knowing a and c; then b = pow(a,1/c) with (c != 0)

I’d found this on this forum some time ago hunting through posts looking for a non-linear mapping function - don’t have the link for it but I did use for a project so here it is from my .cpp file.

float nlMapFunction(float in, float inMin, float inMax, float outMin, float outMax, float shaper){
    // (1) convert to pct (0-1)
    float pct = ofMap(in, inMin, inMax, 0, 1, true);
    // raise this number to a power
    pct = powf(pct, shaper);
    float out = ofMap(pct, 0,1, outMin, outMax, true);
    return out;


From Zach on oF Forum:
 If shaper is 1, you get linear output like ofMap.
 If not, you can shape the output. 
 Shaper > 1 means you'll have non linear steps weighted towards the start.
 If shaper is < 1 and > 0 you can get non linear range weighted towards the end.
 There are plenty of other shaper functions that take a pct (a number between 0 and 1) and output a pct, which might help.

This doesn’t exactly answer your question, but might help!

1 Like

Thank you, it works perfectly and is much cleaner than my solution

Suggestion to add it to OF master as ofMapExp ?