Hello,I'm working with an exponential function, and I need a bit of help with manipulating its behavior. Basically, I have two points that I would like to maintain whilst "dragging" the curve of the function outwards in order to exaggerate the exponential behavior of the function. Here is the application: I have an input value (x) which I would like to scale from 1080 and 1750 to an output value (y) within 1500 and 2000. I do not want to use a linear equation, because I would like to create the effect where lower x values output y values incrementing at a much slower rate than output y values increment from higher x input values.

Unfortunately, the effect of the exponential behavior is very minor and unnoticeable in the application I am using it for in my program. How can I exaggerate the exponential behavior of the function whilst maintaining the two points (1080, 1500) and (1750, 2000)?

So, other thread didn't help much? http://arduino.cc/forum/index.php/topic,115296.0/topicseen.htmlI'd suggest, before you try to program equation in C, you need clear representation of this equation in math with all coefficients defined, only after that you would be able to make a decision what "library" function is the best for task ( pow, exp, base 2, base 10, float vs integer etc).The simple solution is Excell, or LibreOffice, where you play around with math, and see how it affects a chart. Only when you like what you see, you ready to transfer it in C.

The simple solution is Excell, or LibreOffice, where you play around with math, and see how it affects a chart. Only when you like what you see, you ready to transfer it in C.

I've been doing that, and I disagree with you. I have been doing research online and playing with graphs, and it would seem in this case the simple solution is to ask a forum with over 120,000 people who actually have an idea of what I'm talking about.

Unfortunately, the effect of the exponential behavior is very minor and unnoticeable in the application I am using it for in my program. How can I exaggerate the exponential behavior of the function whilst maintaining the two points (1080, 1500) and (1750, 2000)?

Where is the x in the function?

How would you implement the "basic" function if it was between the points (0,0) and (1,1) ? If you can define that the rest is scaling.

Easiest option is to use - http://arduino.cc/playground/Main/MultiMap - which can mimic all non linear functions

Easiest option is to use - http://arduino.cc/playground/Main/MultiMap - which can mimic all non linear functions

Yes, but he uses map() which uses long value types and I need a high-speed function, so I'm trying to stay away from 32 and 64 bit numbers. (although I have to use 32 bit because Arduino doesn't support 16 bit float values?)

Yes, but he uses map() which uses long value types and I need a high-speed function, so I'm trying to stay away from 32 and 64 bit numbers. (although I have to use 32 bit because Arduino doesn't support 16 bit float values?)

Just remember, the ATmega chips are 8 bit chips, with no floating point. This means every floating point calculation probably involves hundreds to thousands of operations (for add/subtract), and thousands to millions (for multiplies/division). While 32-bit integer arithmetic also involves multiple instructions, it is likely 1-2 orders of magnitude faster than using floating point. If you can recode your algorithm to not use floating point, it probably will execute faster.

If your code is floating point intensive, and you have time constraints on its execution, you probably should be thinking about using something else, like an ARM with hardware floating point.

Quote from: JavaMan on July 22, 2012, 09:07:15 PMSee if this has a noticeable effect:

y = 1500 + .004455(x-1080)*(x-1080)

Thank you, I'll give it a shot. How did you calculate it?

The only number I calculated was .004455, and that was to make y = 2000 when x = 1750. But I forgot about the 1500 and gave you the wrong number! Should have been .001114. Looks like you figured it out anyway. Good job!

I'm using unsigned 16 bit integers (uint16_t) so I'd assume that will work?

No it will not.

your input values are in the range "1080 and 1750" squaring it gives values between 1 and 4 million, will not fit in an 16 bit.OK the subtraction of 1080 makes it max 700^2 == 490.000 which still will not fit in a 16 bit int by a factor 7.

However if you persist to do only 16 bit math and you accept a (~1%) error you could apply the division in steps to keep the result under max unint16. The prices is less accuracy and some "staircasing" in the graph due to less distinct values. I used a spreadsheet to model the results below.

Other 8978 is ~8982 = 2.3.3.499 ===> using 2 and 3 will result in an overflow (700^2 /6 >> 65535)===> using 3 and 6 will give less distinct values than 2 and 5===> using 1 and 9 is interesting as you need one division less! and it will map 1750 on 2000