Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 29th, 2003, 02:46 PM
jack37a jack37a is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 2 jack37a User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
fast exponential function algorithm

Hi !

I am trying to write a program which calculates an exponential function as fast as possible on a PC
I tried a polynom approximation. It is the fastest algorithm i have
got and it has an accurracy of 10 digits.
take a look!

---------------------------------------------------------------------

const float umrechnungf=0.434294481903251f;

const float z00=1.00000000000000f;
const float z11=1.258925411794167f;
const float z22=1.584893192461113f;
const float z33=1.995262314968879f;
const float z44=2.511886431509580f;
const float z55=3.162277660168379f;
const float z66=3.981071705534972f;
const float z77=5.011872336272723f;
const float z88=6.309573444801932f;
const float z99=7.943282347242815f;
const float Kette24Lf=10.423067565678043f;
const float Kette12Lf=5.211533782839021f;
const float Kette50LLf=9.430584850580696f;
const float Kette10LLf=1.886116970116139f;

float Jacks_Exp(float Wert)


{

W=fabs(Wert*umrechnungf);

g=int(W);
z=int((W-g)*10);
h=W-(float(g)+float(z)/10);


switch (z)
{
case 0 : binaer=z00;break;
case 1 : binaer=z11;break;
case 2 : binaer=z22;break;
case 3 : binaer=z33;break;
case 4 : binaer=z44;break;
case 5 : binaer=z55;break;
case 6 : binaer=z66;break;
case 7 : binaer=z77;break;
case 8 : binaer=z88;break;
case 9 : binaer=z99;break;
}


ergebnis = pow(10,g)*binaer*((Kette24Lf/(Kette12Lf-h-(Kette50LLf/(Kette10LLf/h+h))))-1);

if (Wert < 0)
return (1/ergebnis);
else
{
return ergebnis;
}

}


I know that floats are very slow - especially divisions.
I would be very thankfuf if some could help me. Maybe some has a solution to my problem or some hints how I could improve the performance of my algorithm.
Is there a faster way of dividing floating numbers ?
Does anybody know a better algorithm ?
Could someone also recommend me some good books which deal with this kind of the problem.
Thanks in advance

Jack

Reply With Quote
  #2  
Old April 30th, 2003, 09:02 AM
mathew mathew is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Slovak republic
Posts: 15 mathew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 27 m 4 sec
Reputation Power: 0
Send a message via ICQ to mathew
"unlimited" accuracy

hi.

the fastest way to work with numbers is to use some optimized library. I should sugest you GMP lib. (www.swox.com/gmp).
It could be used to work with huge numbers (even millions digits each number or more) and also with huge accuracy (limited only by your memory).
It has all mathematical functions (mul, div, pow, log, binary operations, and much more....) and it is one of the fastest (if not the fastest one) functions cose it is speed optimized.

i hope i helped you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > fast exponential function algorithm

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap