0

I was playing with tanh and what would be very close but not as expensive as tanh, computation wise. I came up with:

      2/(1+exp(-2*x))-1

It is VERY close. The biggest delta I saw was like in the 10 to the -15 range. It's still not as cheap as polynomial approximations.

Can somebody differentiate that for me? :)

Bing Bang
  • 524
  • 7
  • 16
  • 2
    [Use wolfram alpha](http://www.wolframalpha.com/input/?i=2%2F%281%2Bexp%28-2*x%29%29-1) – halex Mar 24 '15 at 17:42
  • What a nifty site! Thanks a lot. – Bing Bang Mar 24 '15 at 18:01
  • OOOPsss!!! I think this IS the tanh formula rewritten. replace the 1 with (1+exp(2*x))/(1+exp(2*x)). You end up with (1-exp(2*x))/(1+exp(2x)). I started with the sigmoid formula and modified it to make it look like tanh. The sigmoid, 1/(1+exp(x)), looks a lot like tanh but its range is [0,1]. So I multiplied the sigmoid by 2 and subtracted 1 making the range [-1,1]. but the modified sigmoid had a much lower slope near 0 so I replaced the exp(x) with exp(2x) and voila! It matched tanh so close... Now I know why! – Bing Bang Mar 28 '15 at 00:03

1 Answers1

2

1-(2*(1/(1+exp(x*2)))) works well on limited hardware

SpagnumMoss
  • 104
  • 6