Average Error: 29.1 → 0.0
Time: 15.4s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007531935859306163 \lor \neg \left(x \le 0.006834872945865455\right):\\ \;\;\;\;\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\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.007531935859306163 or 0.006834872945865455 < x

    1. Initial program 0.0

      \[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
    2. Using strategy rm
    3. Applied flip--0.0

      \[\leadsto \color{blue}{\frac{\frac{2}{1 + e^{-2 \cdot x}} \cdot \frac{2}{1 + e^{-2 \cdot x}} - 1 \cdot 1}{\frac{2}{1 + e^{-2 \cdot x}} + 1}}\]

    if -0.007531935859306163 < x < 0.006834872945865455

    1. Initial program 58.9

      \[\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.007531935859306163 \lor \neg \left(x \le 0.006834872945865455\right):\\ \;\;\;\;\frac{\frac{2}{e^{-2 \cdot x} + 1} \cdot \frac{2}{e^{-2 \cdot x} + 1} - 1}{1 + \frac{2}{e^{-2 \cdot x} + 1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - {x}^{3} \cdot \frac{1}{3}\\ \end{array}\]

Reproduce

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

Details

Time bar (total: 15.0s)Debug log

sample77.0ms

Algorithm
intervals

simplify8.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.8b

localize23.0ms

Local error

Found 3 expressions with local error:

3.8b
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
0.0b
(+ 1 (exp (* -2 x)))
0.0b
(/ 2 (+ 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))))

series58.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

36.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
15.0ms
(/ 2 (+ 1 (exp (* -2 x))))
7.0ms
(+ 1 (exp (* -2 x)))

simplify430.0ms

Counts
15 → 46
Calls

15 calls. Slowest were:

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

prune291.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize14.0ms

Local error

Found 4 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
4 → 62
Calls

4 calls. Slowest were:

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

series65.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify1.9s

Counts
35 → 74
Calls

35 calls. Slowest were:

720.0ms
(* (* (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (/ 2 (+ 1 (exp (* -2 x))))) (* (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (/ 2 (+ 1 (exp (* -2 x))))))
160.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
146.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))

prune487.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 3 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

4.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
1.0ms
(* 1/3 (pow x 3))
1.0ms
(* 2/15 (pow x 5))

series60.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

25.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
20.0ms
(* 2/15 (pow x 5))
15.0ms
(* 1/3 (pow x 3))

simplify282.0ms

Counts
17 → 46
Calls

17 calls. Slowest were:

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

prune281.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

localize26.0ms

Local error

Found 4 expressions with local error:

4.0b
(- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))
3.8b
(- (/ 2 (/ (+ (pow 1 3) (pow (exp (* -2 x)) 3)) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))) 1)
0.2b
(/ (+ (pow 1 3) (pow (exp (* -2 x)) 3)) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))
0.0b
(pow (exp (* -2 x)) 3)

rewrite43.0ms

Algorithm
rewrite-expression-head
Counts
4 → 95
Calls

4 calls. Slowest were:

28.0ms
(/ (+ (pow 1 3) (pow (exp (* -2 x)) 3)) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))
7.0ms
(- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))
4.0ms
(pow (exp (* -2 x)) 3)

series289.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

178.0ms
(- (/ 2 (/ (+ (pow 1 3) (pow (exp (* -2 x)) 3)) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))) 1)
64.0ms
(/ (+ (pow 1 3) (pow (exp (* -2 x)) 3)) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))
23.0ms
(- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))
23.0ms
(pow (exp (* -2 x)) 3)

simplify6.0s

Counts
87 → 107
Calls

87 calls. Slowest were:

280.0ms
(/ (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))) (* (cbrt (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))) (cbrt (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))))
235.0ms
(+ (sqrt (/ 2 (/ (+ (pow 1 3) (pow (exp (* -2 x)) 3)) (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))))) 1)
203.0ms
(- (* (pow 1 3) (pow 1 3)) (* (pow (exp (* -2 x)) 3) (pow (exp (* -2 x)) 3)))

prune1.3s

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0.0b

regimes315.0ms

Accuracy

100% (0.0b remaining)

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

bsearch125.0ms

end0.0ms

sample2.9s

Algorithm
intervals