Average Error: 29.8 → 0.0
Time: 18.0s
Precision: 64
Internal Precision: 128
\[\frac{2}{1 + e^{-2 \cdot x}} - 1\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007287118496474421 \lor \neg \left(x \le 0.004923808475551174\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.007287118496474421 or 0.004923808475551174 < 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.007287118496474421 < x < 0.004923808475551174

    1. Initial program 59.1

      \[\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.007287118496474421 \lor \neg \left(x \le 0.004923808475551174\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 2019002 
(FPCore (x y)
  :name "Logistic function from Lakshay Garg"
  (- (/ 2 (+ 1 (exp (* -2 x)))) 1))

Details

Time bar (total: 17.3s)Debug log

sample62.0ms

Algorithm
intervals

simplify7.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.9b

localize14.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
2 → 27
Calls

2 calls. Slowest were:

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

series83.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

57.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
26.0ms
(/ 2 (+ 1 (exp (* -2 x))))

simplify294.0ms

Counts
12 → 33
Calls

12 calls. Slowest were:

67.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
58.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
42.0ms
(- (+ x 1) (* 1/3 (pow x 3)))

prune395.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 4 expressions with local error:

19.2b
(- (+ 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))
0.0b
(+ x (* 2/15 (pow x 5)))

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 47
Calls

4 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))

series168.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

82.0ms
(+ x (* 2/15 (pow x 5)))
33.0ms
(* 2/15 (pow x 5))
27.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
26.0ms
(* 1/3 (pow x 3))

simplify445.0ms

Counts
20 → 59
Calls

20 calls. Slowest were:

150.0ms
(/ (exp (+ x (* 2/15 (pow x 5)))) (exp (* 1/3 (pow x 3))))
76.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
73.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))

prune556.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize29.0ms

Local error

Found 4 expressions with local error:

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

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 67
Calls

4 calls. Slowest were:

8.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)))))
4.0ms
(+ (/ 2 (+ 1 (exp (* -2 x)))) 1)

series123.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

41.0ms
(- (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x))))) (* 1 1))
29.0ms
(* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x)))))
28.0ms
(/ 2 (+ 1 (exp (* -2 x))))
25.0ms
(+ (/ 2 (+ 1 (exp (* -2 x)))) 1)

simplify2.4s

Counts
40 → 79
Calls

40 calls. Slowest were:

1.0s
(* (* (* (/ 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))))))
163.0ms
(/ (exp (* (/ 2 (+ 1 (exp (* -2 x)))) (/ 2 (+ 1 (exp (* -2 x)))))) (exp (* 1 1)))
133.0ms
(- (* 4 (/ 1 (pow (+ (exp (* -2 x)) 1) 2))) 1)

prune846.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize18.0ms

Local error

Found 4 expressions with local error:

41.0b
(/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5))))
19.2b
(- (/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5)))) (* 1/3 (pow x 3)))
16.3b
(- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5))))
0.1b
(* 1/3 (pow x 3))

rewrite57.0ms

Algorithm
rewrite-expression-head
Counts
4 → 75
Calls

4 calls. Slowest were:

33.0ms
(- (/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5)))) (* 1/3 (pow x 3)))
11.0ms
(/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5))))
6.0ms
(- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5))))

series306.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

140.0ms
(/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5))))
99.0ms
(- (/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5)))) (* 1/3 (pow x 3)))
47.0ms
(- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5))))
20.0ms
(* 1/3 (pow x 3))

simplify7.5s

Counts
58 → 87
Calls

58 calls. Slowest were:

716.0ms
(/ (sqrt (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5))))) (sqrt (- x (* 2/15 (pow x 5)))))
623.0ms
(/ (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5)))) (- x (* 2/15 (pow x 5))))
376.0ms
(/ (sqrt (- (* x x) (* (* 2/15 (pow x 5)) (* 2/15 (pow x 5))))) (* (cbrt (- x (* 2/15 (pow x 5)))) (cbrt (- x (* 2/15 (pow x 5))))))

prune1.1s

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes278.0ms

Accuracy

100% (0.0b remaining)

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

bsearch154.0ms

end0.0ms

sample2.4s

Algorithm
intervals