Main Archive Specials Wiki | FAQ Links Submit Forum


fast exp() approximations

Type : Taylor series approximation
References : Posted by scoofy[AT]inf[DOT]elte[DOT]hu

Notes :
I needed a fast exp() approximation in the -3.14..3.14 range, so I made some approximations based on the tanh() code posted in the archive by Fuzzpilz. Should be pretty straightforward, but someone may find this useful.

The increasing numbers in the name of the function means increasing precision. Maximum error in the -1..1 range:
fastexp3: 0.05 (1.8%)
fastexp4: 0.01 (0.36%)
fastexp5: 0.0016152 (0.59%)
fastexp6: 0.0002263 (0.0083%)
fastexp7: 0.0000279 (0.001%)
fastexp8: 0.0000031 (0.00011%)
fastexp9: 0.0000003 (0.000011%)

Maximum error in the -3.14..3.14 range:
fastexp3: 8.8742 (38.4%)
fastexp4: 4.8237 (20.8%)
fastexp5: 2.28 (9.8%)
fastexp6: 0.9488 (4.1%)
fastexp7: 0.3516 (1.5%)
fastexp8: 0.1172 (0.5%)
fastexp9: 0.0355 (0.15%)

These were done using the Taylor series, for example I got fastexp4 by using:
exp(x) = 1 + x + x^2/2 + x^3/6 + x^4/24 + ...
= (24 + 24x + x^2*12 + x^3*4 + x^4) / 24
(using Horner-scheme:)
= (24 + x * (24 + x * (12 + x * (4 + x)))) * 0.041666666f



Code :
inline float fastexp3(float x) {
return (6+x*(6+x*(3+x)))*0.16666666f;
}

inline float fastexp4(float x) {
return (24+x*(24+x*(12+x*(4+x))))*0.041666666f;
}

inline float fastexp5(float x) {
return (120+x*(120+x*(60+x*(20+x*(5+x)))))*0.0083333333f;
}

inline float fastexp6(float x) {
return 720+x*(720+x*(360+x*(120+x*(30+x*(6+x))))))*0.0013888888f;
}

inline float fastexp7(float x) {
return (5040+x*(5040+x*(2520+x*(840+x*(210+x*(42+x*(7+x)))))))*0.00019841269f;
}

inline float fastexp8(float x) {
return (40320+x*(40320+x*(20160+x*(6720+x*(1680+x*(336+x*(56+x*(8+x))))))))*2.4801587301e-5;
}

inline float fastexp9(float x) {
return (362880+x*(362880+x*(181440+x*(60480+x*(15120+x*(3024+x*(504+x*(72+x*(9+x)))))))))*2.75573192e-6;
}



Comments


Added on : 02/07/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]hu
Comment :
These series converge fast only near zero. But there is an identity:

exp(x) = exp(a) * exp(x-a)

So, if you want a relatively fast polynomial approximation for exp(x) for 0 to ~7.5, you can use:

// max error in the 0 .. 7.5 range: ~0.45%
inline float fastexp(float const &x)
{
  if (x<2.5)
      return 2.7182818f * fastexp5(x-1.f);
  else if (x<5)
      return 33.115452f * fastexp5(x-3.5f);
  else
      return 403.42879f * fastexp5(x-6.f);
}

where 2.7182.. = exp(1), 33.1154.. = exp(3.5) and 403.428.. = exp(6). I chose these values because fastexp5 has a maximum error of 0.45% between -1 - 1.5 (using fastexp6, the maximum error is 0.09%).

Using the identity

  pow(a,x) = exp(x * log(a))

you can use any base, for example to get 2^x:

// max error in the 0-10.58 range: ~0.45%
inline float fastpow2(float const &x)
{
  float const log_two = 0.6931472f;
  return fastexp(x * log_two);
}

These functions are about 3x faster than exp().

-- Peter Schoffhauzer




Added on : 12/02/17 by ss64[ DOT ]77[ DOT ]36[ DOT ]4[ DOT ][ AT ]gmail[ DOT ]com
Comment :
[url=https://goo.gl/3Ou4Ia][img]http://bolshe.com.ua/uploads/image-1457900037-742_big.jpg[/img][/url]

Äîáðîå óòðî, Äîðîãîé Äðóã.
Ìû èçó÷àåì ÿçûê ìóçûêè è ñ÷èòàåì, ÷òî êàæäûé ÷åëîâåê  ñïîñîáåí îáó÷èòñÿ èãðàòü ìóçûêó è ðàçâèâàòü åñòåñòâåííûå ìóçûêàëüíûé ñëóõ è ðèòì. Ìóçûêàëüíàÿ èìïðîâèçàöèÿ ýòî ëó÷øèé ìåòîä, äëÿ òîãî ÷òîáû ðàññëàáèòü ðàññóäîê è òåëî, ðàñêðûòü èíäèâèäóàëüíûå ýìîöèè è îòêðûòüñÿ ãàðìîíèè. Ìóçûêà ðàçâèâàåò âîîáðàæåíèå. Äëÿ ðåàëèçàöèè ýòîé çàäóìêè, óæå ìíîãî ëåò ìû çàíèìàåìñÿ èçó÷åíèåì è èçãîòîâëåíèåì ñòàëüíûõ ÿçû÷êîâûõ áàðàáàíîâ ãëþêîôîíîâ.
Ãëþêîôîí ýòî òîíàëüíûé ëåïåñòêîâûé áàðàáàí èíäèâèäóàëüíîé ðó÷íîé ðàáîòû â ôîðìå ëåòàþùåé òàðåëêè. Ó íàñ âû ìîæåòå âûáðàòü êàê óæå ãîòîâûé èíñòðóìåíò, òàê è ñäåëàòü çàêàç íà ãëþêîôîí ïî ëè÷íûì òðåáîâàíèÿì, ïîäîáðàâ åãî äèàìåòð, ÷èñëî íîò, íàñòðîéêó ëåïåñòêîâ, öâåò è ôàêòóðó.
Ãëþêîôîí ýòî íå ïðîñòîé ìóçûêàëüíûé èíñòðóìåíò. Ýòî ïàíàöåÿ, êîòîðàÿ ïîçâîëÿåò ñíèìàòü ñòðåññ, èíòóèòèâíî è ñàìîñòîÿòåëüíî ðàçâèâàòü ìóçûêàëüíûé ñëóõ è îùóùåíèå ðèòìà â ëþáîì âîçðàñòå.
Íàøè èíñòðóìåíòû âûïîëíåíû ñ îñîáîé äåëèêàòíîñòüþ. Ôîðìà êîðïóñà è ñòðîåíèå ìåòàëëà ôîðìèðóåò çâóêîâûå êîëåáàíèÿ âîëíîé âíóòðè áàðàáàíà. Îñíîâíàÿ çàäóìêà íàøåé ìàñòåðñêîé ýòî èçãîòîâëåíèå âûñîêîêà÷åñòâåííûõ è ïîëíîñòüþ ôóíêöèîíèðóþùèõ èíñòðóìåíòîâ ïî öåíàì, äîñòóïíûì êàæäîìó. Áëàãîäàðÿ ýòîìó èíñòðóìåíòó ìû õîòèì ïîêàçàòü ëþäÿì, ÷òî êàæäûé ÷åëîâåê ìîæåò íàó÷èòüñÿ èãðàòü ñâîþ ñîáñòâåííóþ ìóçûêó â ëþáîì âîçðàñòå, çà êîðîòîå âðåìÿ.
Ó íàñ â ìàãàçèíå Âû ñìîæåòå ïðèîáðåñòè ãëþêîôîí è  îçíàêîìèòüñÿ  ñ íåîáû÷íûìè ñòîðîíàìè ýòîãî èíñòðóìåíòà.

[url=https://goo.gl/Vy5vgj][img]http://stroymet-shop.ru/upload/medialibrary/653/653733eb264c5c3c49bf2f3ec6853d21.png[/img][/url]

Ïåðåéòè íà Íàø ñàéò --->>>  https://goo.gl/VfpDEc

















































õàíã äðàì ñëóøàòü îíëàéí âèäåî
õàíã óë êàðüåð
õàíã äðàì ïðîãðàììà
õàíã óðîêè
ãëþêîôîí áàðíàóë
õàíã öåíà óêðàèíà
õàíã äðàì âåáèíàð
hapi drum coupon code
õàíã åêàòåðèíáóðã êóïèòü
vadjraghanta drumõàíã

äåøåâûé îðèãèíàëüíûé ïîäàðîê ñâàäüáó
îðèãèíàëüíûé ïîäàðîê ïàðíþ +íà íîâûé ãîä
âðó÷èòü ïîäàðîê íåîáû÷íî
ýëèòíûå ïîäàðêè +äëÿ ìóæ÷èí +íà äåíü ðîæäåíèÿ
îðèãèíàëüíûå ïîäàðêè +íà äåíü ðîæäåíèÿ íîâîñèáèðñê

õàíã íîâîñèáèðñê
hapi drum chile venta
mini hang drum for sale
ãëþêîôîí ñïá êóïèòü
hang drum music ñêà÷àòü áåñïëàòíî
hapi drum logo
ìóçûêà õàíãà îíëàéí
ãëþêîôîí ñïá
hapi drum online
steel tongue drum vs hang drum

îðèãèíàëüíûå ïîäàðêè áåëãîðîä
ìàñòåðñêàÿ ýêñêëþçèâíûõ ïîäàðêîâ ñïá
ìàãàçèí îðèãèíàëüíûõ ïîäàðêîâ âîëãîãðàä
îðèãèíàëüíûå øîó ïîäàðêè
íåîáû÷íûå ïîäàðêè íåâåñòû


hapi drum craigslist
steel tongue drum double sided
ãëþêîôîí evolution 2 êóïèòü
hang drum sale
ãëþêîôîí êóïèòü â ìîñêâå íåäîðîãî
õàíã â ìîñêâå
hang drum ìóçûêà ñëóøàòü
ãëþêîôîí îê
hapi drum kaufen schweiz
èãðà +íà õàíãå ñëóøàòü îíëàéí

îðèãèíàëüíûé ïîäàðîê ëþáèìîìó äð
îðèãèíàëüíûå ïîäàðêè äåíü ðîæäåíèÿ æåíùèíå íà÷àëüíèêó
íåîáû÷íûå ïîäàðêè äåíü âàëåíòèíà
êàêîé îðèãèíàëüíûé ïîäàðîê ìîæíî ïîäàðèòü +íà ñâàäüáó
îðèãèíàëüíûå ïîäàðêè +äëÿ ñîòðóäíèêîâ

hapi drum mini review
hapi drum mini
õàíã äðàì ñëóøàòü îíëàéí âèäåî
ãëþêîôîí ïî÷åìó òàê íàçûâàåòñÿ
ãëþêîôîí þòüþá
õàíã äðàì ñêà÷àòü áåñïëàòíî
hang öåíà
èäèîôîí äàâàé
ãëþêîôîí êóïèòü â ñïá
ýëåêòðîííûé õàíã

îðèãèíàëüíûå ïîäàðêè ìîëîäûì ñâàäüáó
âðó÷åíèå ïîäàðêà ðåáåíêó îðèãèíàëüíî
ýêñêëþçèâíûå äåòñêèå ïîäàðêè
îðèãèíàëüíûé ïîäàðîê îòöó +íà äåíü ðîæäåíèÿ
ìàãàçèí îðèãèíàëüíûõ ïîäàðêîâ íîâîñèáèðñê


ãëþêîôîí á\/ó êóïèòü
ãëþêîôîí ìèíè
hapi drum scales
ãëþêîôîí soundrum
hang ðåêâèåì
ìóçûêàëüíûé èíñòðóìåíò õàíã öåíà
steel tongue drum selber bauen
âàäæðàãõàíòà èíòåãðàë
hapi drum wholesale
õàíã ýçîòåðè÷åñêèé ìóçûêàëüíûé èíñòðóìåíò

îðèãèíàëüíûå ïîäàðêè +íà êîæàíóþ ñâàäüáó
íåîáû÷íûå ïîäàðêè íîâîñèáèðñê
ìàãàçèí íåîáû÷íûõ ïîäàðêîâ òþìåíü
äîñòàâêà îðèãèíàëüíûõ ïîäàðêîâ ìîñêâà
îðèãèíàëüíûå ïîäàðêè ìóðìàíñê

hang drum ñòîèìîñòü
õàíã çâó÷àíèå
èäèîôîí ìóçûêàëüíûé èíñòðóìåíò
ãëþêîôîí ðîñòîâ íà äîíó
õàíã þòüþá
ãëþêîôîí hapi drum tank drum
hang drum çàêàçàòü
õàíã ìï3
steel tongue drum ñëóøàòü
õàíã oberton

îðèãèíàëüíûå äîðîãèå ïîäàðêè +äëÿ ìóæ÷èí
íåîáû÷íûå ïîäàðêè øêîëüíèêàì
îðèãèíàëüíûé ïîäàðîê äåíåã ñâàäüáó +ñâîèìè ðóêàìè
îðèãèíàëüíûé ñâàäåáíûé ïîäàðîê
íåîáû÷íûå ïîäàðêè àâòîìîáèëü


ãëþêîôîí çàêàçàòü
hapi drum mini c major
èäèîôîí áîëüøèå
ãëþêîôîí áîëüøîé
õàíã ÷åëÿáèíñê
hapi drum vs hang
ïîñëóøàòü õàíã
õàíã çèììåð
hapi drum uk for sale
õàíã ýòà ìóçûêà

îðèãèíàëüíûå ïîäàðêè +íà äåíü ðîæäåíèÿ çàêàçàòü
ýëèòíûå ïîäàðêè +íà ñâàäüáó
äîðîãèå îðèãèíàëüíûå ïîäàðêè +äëÿ æåíùèí
îðèãèíàëüíûé ïîäàðîê +íà 14 îêòÿáðÿ
îðèãèíàëüíûé ïîäàðîê ìóæ÷èíå +íà þáèëåé 30 ëåò

http://xyya.net
jqV1sfi57F




Add your own comment
Comments are displayed in fixed width, no HTML code allowed!
Email:

Comment:

Are you human?



Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion