Average Error: 28.7 → 0.0
Time: 6.7s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007313920889238615 \lor \neg \left(x \le 0.007445023279981877\right):\\ \;\;\;\;\frac{2}{1 + 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.007313920889238615 or 0.007445023279981877 < x

    1. Initial program 0.0

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

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

    if -0.007313920889238615 < x < 0.007445023279981877

    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.007313920889238615 \lor \neg \left(x \le 0.007445023279981877\right):\\ \;\;\;\;\frac{2}{1 + 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 2019004 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

Details

Time bar (total: 6.4s)Debug log

sample105.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: 26.1b

localize27.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

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

series89.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

55.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
22.0ms
(/ 2 (+ 1 (exp (* -2 x))))
13.0ms
(+ 1 (exp (* -2 x)))

simplify485.0ms

Counts
15 → 46
Calls

15 calls. Slowest were:

195.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
79.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
54.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune380.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize16.0ms

Local error

Found 3 expressions with local error:

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

rewrite24.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

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

series76.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

45.0ms
(- (/ 2 (+ (exp (* -2 x)) 1)) 1)
19.0ms
(/ 2 (+ (exp (* -2 x)) 1))
12.0ms
(+ (exp (* -2 x)) 1)

simplify454.0ms

Counts
15 → 46
Calls

15 calls. Slowest were:

171.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
98.0ms
(+ (* (exp (* -2 x)) (exp (* -2 x))) (- (* 1 1) (* (exp (* -2 x)) 1)))
53.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune437.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize32.0ms

Local error

Found 3 expressions with local error:

21.7b
(- (+ 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))

rewrite15.0ms

Algorithm
rewrite-expression-head
Counts
3 → 37
Calls

3 calls. Slowest were:

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

series101.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

41.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
34.0ms
(* 2/15 (pow x 5))
26.0ms
(* 1/3 (pow x 3))

simplify401.0ms

Counts
17 → 46
Calls

17 calls. Slowest were:

134.0ms
(/ (exp (+ x (* 2/15 (pow x 5)))) (exp (* 1/3 (pow x 3))))
88.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
79.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune427.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes171.0ms

Accuracy

100% (0.0b remaining)

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

bsearch171.0ms

end0.0ms

sample2.9s

Algorithm
intervals