Hyperbolic functions and exponential function

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Hyperbolic functions and exponential function

Post by Psychophanta »

Code: Select all

Macro Sinh(x)
  ((Pow(2,x#/Log(2))-Pow(2,-x#/Log(2)))/2)
EndMacro
Macro Cosh(x)
  ((Pow(2,x#/Log(2))+Pow(2,-x#/Log(2)))/2)
EndMacro
Macro Tanh(x)
  (Sinh(x#)/Cosh(x#))
EndMacro
Macro Cotanh(x)
  (Cosh(x#)/Sinh(x#))
EndMacro
Macro Sech(x)
  (1/Cosh(x#))
EndMacro
Macro Cosech(x)
  (1/Sinh(x#))
EndMacro
Macro exp(x)
  (Pow(2,x#/Log(2)))
EndMacro
EDIT: BTW, there looks like AMD bets for maths better performaces for their opterons:
http://developer.amd.com/acml.jsp
Last edited by Psychophanta on Fri Nov 16, 2007 3:25 pm, edited 1 time in total.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
hardfalcon
User
User
Posts: 89
Joined: Fri Apr 29, 2005 3:03 pm
Location: Luxembourg
Contact:

Post by hardfalcon »

Give me an Opteron and I'll test that out for you... :lol:
"And God caused a deep sleep to fall upon Adam, and he slept: and he took one of his ribs, and closed up the flesh instead thereof; And the spare rib, which God had taken from man, made he a woman, and brought her unto the man"
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Post by chris319 »

Any chance of these making it into the core language, along with Exp10()? All of the math has been figured out.
User avatar
kenmo
Addict
Addict
Posts: 2047
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Nice, I just noticed last week that PB doesn't have a native Exp() command... Thanks.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

That's a nice way of calculating Exp(x). :)
I may look like a mule, but I'm not a complete ass.
Helle
Enthusiast
Enthusiast
Posts: 178
Joined: Wed Apr 12, 2006 7:59 pm
Location: Germany
Contact:

Post by Helle »

Look at the precision of exp(x):
- Float exp(10) = 22026.466796875
- Double exp(10) = 22026.465189555718
- Really exp(10) = 22026.4657948067165169579...
For more precision see:
http://www.mdcc-fun.de/k.helbing/HBC/
This is a fun project; many things are to do, the code is dirty (strings)...
But: Have fun :D !

Gruss
Helle
lionel_om
User
User
Posts: 31
Joined: Wed Jul 18, 2007 4:14 pm
Location: France

Re: Hyperbolic functions and exponential function

Post by lionel_om »

Psychophanta wrote:Replace .f by .d if wanted. :)
Why don't you have create Macro. By this way, we have not to change the variables types.

Lio :wink:
Webmaster of Basic-univers
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Hyperbolic functions and exponential function

Post by Psychophanta »

lionel_om wrote:
Psychophanta wrote:Replace .f by .d if wanted. :)
Why don't you have create Macro. By this way, we have not to change the variables types.

Lio :wink:
Very right!!
Modified at first post :wink:

EDIT:
Helle wrote:Look at the precision of exp(x):
- Float exp(10) = 22026.466796875
- Double exp(10) = 22026.465189555718
- Really exp(10) = 22026.4657948067165169579...
For more precision see:
http://www.mdcc-fun.de/k.helbing/HBC/
This is a fun project; many things are to do, the code is dirty (strings)...
But: Have fun :D !

Gruss
Helle
wow!! nice calculator. The best i've seen, and in PB is awesome.
However, my functions are faster :wink: , even not with that precision. :roll:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply