Average Error: 28.9 → 0.0
Time: 10.1s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.0065237733413900795 \lor \neg \left(x \le 0.007565603992860171\right):\\ \;\;\;\;\sqrt[3]{\frac{2}{e^{-2 \cdot x} + 1} - 1} \cdot \left(\sqrt[3]{\frac{2}{e^{-2 \cdot x} + 1} - 1} \cdot \sqrt[3]{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{2}{15} \cdot {x}^{5}\right) - {x}^{3} \cdot \frac{1}{3}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -0.0065237733413900795 or 0.007565603992860171 < x

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied add-cube-cbrt0.0

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1} \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}\right) \cdot \sqrt[3]{\frac{2}{1 + e^{-2 \cdot x}} - 1}}\]

    if -0.0065237733413900795 < x < 0.007565603992860171

    1. Initial program 59.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Taylor expanded around 0 0.0

      \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.0065237733413900795 \lor \neg \left(x \le 0.007565603992860171\right):\\ \;\;\;\;\sqrt[3]{\frac{2}{e^{-2 \cdot x} + 1} - 1} \cdot \left(\sqrt[3]{\frac{2}{e^{-2 \cdot x} + 1} - 1} \cdot \sqrt[3]{\frac{2}{e^{-2 \cdot x} + 1} - 1}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{2}{15} \cdot {x}^{5}\right) - {x}^{3} \cdot \frac{1}{3}\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 +o rules:numerics
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

Details

Time bar (total: 9.7s)Debug log

sample59.0ms

Algorithm
intervals

simplify18.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.3b

localize19.0ms

Local error

Found 3 expressions with local error:

3.2b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
0.0b
(/ 2 (+ 1 (exp (* -2 x))))
0.0b
(+ 1 (exp (* -2 x)))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
3 → 50
Calls

3 calls. Slowest were:

5.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
1.0ms
(+ 1 (exp (* -2 x)))
1.0ms
(/ 2 (+ 1 (exp (* -2 x))))

series91.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

49.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
30.0ms
(/ 2 (+ 1 (exp (* -2 x))))
12.0ms
(+ 1 (exp (* -2 x)))

simplify742.0ms

Counts
20 → 59
Calls

20 calls. Slowest were:

261.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
116.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
113.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune580.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize9.0ms

Local error

Found 4 expressions with local error:

3.2b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.2b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
3.2b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
0.0b
(cbrt (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 79
Calls

4 calls. Slowest were:

9.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
9.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
8.0ms
(cbrt (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

series365.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

209.0ms
(cbrt (- (/ 2 (+ 1 (exp (* -2 x)))) 1))
62.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
47.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
46.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify1.5s

Counts
36 → 91
Calls

36 calls. Slowest were:

247.0ms
(cbrt (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3)))
143.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
124.0ms
(cbrt (- (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (* 1 1)))

prune1.1s

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize26.0ms

Local error

Found 3 expressions with local error:

20.4b
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
0.1b
(* 1/3 (pow x 3))
0.0b
(* 2/15 (pow x 5))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 49
Calls

3 calls. Slowest were:

9.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
2.0ms
(* 1/3 (pow x 3))
2.0ms
(* 2/15 (pow x 5))

series87.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

32.0ms
(* 2/15 (pow x 5))
28.0ms
(* 1/3 (pow x 3))
27.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

simplify1.0s

Counts
25 → 58
Calls

25 calls. Slowest were:

166.0ms
(fma 1 (+ x (* 2/15 (pow x 5))) (- (* (pow x 3) 1/3)))
131.0ms
(/ (exp (+ x (* 2/15 (pow x 5)))) (exp (* 1/3 (pow x 3))))
123.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune631.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes245.0ms

Accuracy

100% (0.0b remaining)

Error of 0.0b against oracle of 0.0b and baseline of 28.9b

bsearch202.0ms

end0.0ms

sample2.9s

Algorithm
intervals