View Full Version : exponent math
Stump
- 1st November 2005, 22:55
Greetings all
Is it at all possible to calculate the following...
answer= ((a+b)^1.15) using pbp?
(sum of a+b to the power of 1.15)
chip used is 18F6720
Thank you
Ron
kenif
- 30th December 2020, 02:20
Me too.
Bit late (15 years), but the same problem. I need to generate an exponential decay and PBP has no ^/exp function.
There are several ways to do this, but none of them are particularly quick, which is also a complaint of most built-in exp functions. I think, when we get this right, the fastest answer is a lookup table/array approach.
https://nic.schraudolph.org/bib2html/b2hd-Schraudolph99.html
https://codingforspeed.com/using-faster-exponential-approximation/
This doesn't seem too difficult so will try implementing this.
double exp1(double x) {
x = 1.0 + x / 256.0;
x *= x; x *= x; x *= x; x *= x;
x *= x; x *= x; x *= x; x *= x;
return x;
}
mpgmike
- 30th December 2020, 21:28
The line:
x = 1.0 + x / 256.0;
casts it as floating point. If you haven't used floating point math, you have your research cut out for you.
pedja089
- 30th December 2020, 21:56
Just create lookup table, with linear interpolation.
I found it to be simplest and fastest way.
I successfully created this function https://en.wikipedia.org/wiki/Mean_kinetic_temperature (second function)
Using only 2 lookup tables, and linear approximation.
Mel posted years ago example to create sin function with 2 decimal places, using only integer numbers.
richard
- 31st December 2020, 04:50
The line:
casts it as floating point. If you haven't used floating point math, you have your research cut out for you.
its a double precision 64 bit float too boot
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.