Page 1 of 1

Hyperbolic functions and exponential function

Posted: Mon Nov 12, 2007 10:52 pm
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

Posted: Tue Nov 13, 2007 3:15 pm
by hardfalcon
Give me an Opteron and I'll test that out for you... :lol:

Posted: Fri Nov 16, 2007 1:34 am
by chris319
Any chance of these making it into the core language, along with Exp10()? All of the math has been figured out.

Posted: Fri Nov 16, 2007 3:16 am
by kenmo
Nice, I just noticed last week that PB doesn't have a native Exp() command... Thanks.

Posted: Fri Nov 16, 2007 9:37 am
by srod
That's a nice way of calculating Exp(x). :)

Posted: Fri Nov 16, 2007 10:07 am
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

Re: Hyperbolic functions and exponential function

Posted: Fri Nov 16, 2007 1:34 pm
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:

Re: Hyperbolic functions and exponential function

Posted: Fri Nov 16, 2007 3:25 pm
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: