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

    1. Initial program 0.0

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

      \[\leadsto \frac{2}{\color{blue}{\sqrt{1 + e^{-2 \cdot x}} \cdot \sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    4. Applied associate-/r*0.0

      \[\leadsto \color{blue}{\frac{\frac{2}{\sqrt{1 + e^{-2 \cdot x}}}}{\sqrt{1 + e^{-2 \cdot x}}}} - 1\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.0

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

    if -0.007330709220870434 < x < 0.006326539173242781

    1. Initial program 59.2

      \[\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. Using strategy rm
    4. Applied associate--l+0.0

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

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

Reproduce

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

Details

Time bar (total: 10.3s)Debug log

sample88.0ms

Algorithm
intervals

simplify15.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
15.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.0b

localize27.0ms

Local error

Found 3 expressions with local error:

2.9b
(- (/ 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
Rules
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
add-exp-log
add-cbrt-cube
associate-/r*
pow1
flip-+
associate-/r/
flip3-+
flip--
div-inv
difference-of-sqr-1
flip3--
frac-2neg
sub-neg
clear-num
+-commutative
Counts
3 → 37
Calls
3 calls:
Slowest
8.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
2.0ms
(+ 1 (exp (* -2 x)))
1.0ms
(/ 2 (+ 1 (exp (* -2 x))))

series112.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
76.0ms
(- (/ 2 (+ 1 (exp (* -2 x)))) 1)
28.0ms
(/ 2 (+ 1 (exp (* -2 x))))
8.0ms
(+ 1 (exp (* -2 x)))

simplify512.0ms

Counts
15 → 46
Calls
15 calls:
Slowest
187.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
91.0ms
(+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))
76.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
53.0ms
(- (+ x 1) (* 1/3 (pow x 3)))
30.0ms
(- (* 2 (/ 1 (+ (exp (* -2 x)) 1))) 1)

prune403.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize28.0ms

Local error

Found 3 expressions with local error:

20.3b
(- (+ 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
Rules
associate-*r*
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
*-commutative
flip--
associate--l+
unpow3
diff-log
flip3--
sub-neg
cube-mult
Counts
3 → 37
Calls
3 calls:
Slowest
5.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))

series91.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
35.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
33.0ms
(* 1/3 (pow x 3))
23.0ms
(* 2/15 (pow x 5))

simplify355.0ms

Counts
17 → 46
Calls
17 calls:
Slowest
138.0ms
(/ (exp (+ x (* 2/15 (pow x 5)))) (exp (* 1/3 (pow x 3))))
70.0ms
(- (+ x (* 2/15 (pow x 5))) (* 1/3 (pow x 3)))
63.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)))
7.0ms
(* 1/3 (pow x 3))

prune488.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 3 expressions with local error:

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

rewrite6.0ms

Algorithm
rewrite-expression-head
Rules
associate-*r*
add-log-exp
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
add-exp-log
add-cbrt-cube
pow1
*-commutative
flip--
unpow3
diff-log
flip3--
sub-neg
cube-mult
Counts
3 → 36
Calls
3 calls:
Slowest
3.0ms
(- (* 2/15 (pow x 5)) (* 1/3 (pow x 3)))
1.0ms
(* 1/3 (pow x 3))
1.0ms
(* 2/15 (pow x 5))

series144.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
84.0ms
(- (* 2/15 (pow x 5)) (* 1/3 (pow x 3)))
33.0ms
(* 2/15 (pow x 5))
27.0ms
(* 1/3 (pow x 3))

simplify254.0ms

Counts
17 → 45
Calls
17 calls:
Slowest
72.0ms
(/ (exp (* 2/15 (pow x 5))) (exp (* 1/3 (pow x 3))))
50.0ms
(- (* 2/15 (pow x 5)) (* 1/3 (pow x 3)))
48.0ms
(- (* 2/15 (pow x 5)) (* 1/3 (pow x 3)))
26.0ms
(- (* 2/15 (pow x 5)) (* 1/3 (pow x 3)))
10.0ms
(* 1/3 (pow x 3))

prune463.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.0b

localize18.0ms

Local error

Found 4 expressions with local error:

2.9b
(- (/ (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x))))) 1)
0.5b
(/ 2 (sqrt (+ 1 (exp (* -2 x)))))
0.0b
(/ (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x)))))
0.0b
(+ 1 (exp (* -2 x)))

rewrite34.0ms

Algorithm
rewrite-expression-head
Rules
38×times-frac
32×add-sqr-sqrt
27×add-cube-cbrt
27×*-un-lft-identity
25×sqrt-prod
18×associate-/r/
18×sqrt-div
12×associate-/r*
10×flip-+
10×flip3-+
div-inv
associate-/l*
add-exp-log
add-cbrt-cube
add-log-exp
pow1
difference-of-sqr-1
frac-2neg
clear-num
associate-/l/
flip--
div-exp
flip3--
sub-neg
+-commutative
cbrt-undiv
Counts
4 → 105
Calls
4 calls:
Slowest
25.0ms
(- (/ (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x))))) 1)
5.0ms
(/ (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x)))))
2.0ms
(/ 2 (sqrt (+ 1 (exp (* -2 x)))))
1.0ms
(+ 1 (exp (* -2 x)))

series140.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
52.0ms
(/ 2 (sqrt (+ 1 (exp (* -2 x)))))
50.0ms
(- (/ (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x))))) 1)
26.0ms
(/ (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x)))))
12.0ms
(+ 1 (exp (* -2 x)))

simplify2.9s

Counts
109 → 117
Calls
109 calls:
Slowest
314.0ms
(- (+ (* 1/2 (/ x (sqrt 1/2))) (* 2 (sqrt 1/2))) (* 1/16 (/ (pow x 2) (pow (sqrt 1/2) 3))))
219.0ms
(- (+ (* 2 (pow x 2)) 2) (* 2 x))
215.0ms
(/ (* (* (/ 2 (sqrt (+ 1 (exp (* -2 x))))) (/ 2 (sqrt (+ 1 (exp (* -2 x)))))) (/ 2 (sqrt (+ 1 (exp (* -2 x)))))) (* (* (sqrt (+ 1 (exp (* -2 x)))) (sqrt (+ 1 (exp (* -2 x))))) (sqrt (+ 1 (exp (* -2 x))))))
118.0ms
(sqrt (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x))))))
97.0ms
(/ (sqrt (+ (* 1 1) (- (* (exp (* -2 x)) (exp (* -2 x))) (* 1 (exp (* -2 x)))))) (sqrt (sqrt (+ 1 (exp (* -2 x))))))

prune1.1s

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.0b

regimes242.0ms

Accuracy

100% (0.0b remaining)

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

bsearch176.0ms

end0.0ms

sample2.6s

Algorithm
intervals