Average Error: 28.9 → 0.0
Time: 7.7s
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 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

Details

Time bar (total: 7.3s)Debug log

sample100.0ms

Algorithm
intervals

simplify14.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.3b

localize13.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)))

rewrite6.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

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

series74.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

50.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
16.0ms
(/ 2 (+ 1 (exp (* -2 x))))
8.0ms
(+ 1 (exp (* -2 x)))

simplify521.0ms

Counts
15 → 46
Calls

15 calls. Slowest were:

179.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
104.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
93.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune455.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize20.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))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 50
Calls

4 calls. Slowest were:

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

series376.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

227.0ms
(cbrt (- (/ 2 (+ 1 (exp (* -2 x)))) 1))
55.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
52.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
42.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify953.0ms

Counts
21 → 62
Calls

21 calls. Slowest were:

260.0ms
(cbrt (- (pow (/ 2 (+ 1 (exp (* -2 x)))) 3) (pow 1 3)))
86.0ms
(cbrt (- (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (* 1 1)))
75.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune669.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize20.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))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

5.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))

series90.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

37.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
36.0ms
(* 2/15 (pow x 5))
17.0ms
(* 1/3 (pow x 3))

simplify363.0ms

Counts
17 → 46
Calls

17 calls. Slowest were:

111.0ms
(/ (exp (+ x (* 2/15 (pow x 5)))) (exp (* 1/3 (pow x 3))))
87.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
71.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune421.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes258.0ms

Accuracy

100% (0.0b remaining)

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

bsearch167.0ms

end0.0ms

sample2.7s

Algorithm
intervals