Average Error: 29.2 → 0.2
Time: 14.0s
Precision: 64
Internal Precision: 128
\[e^{a \cdot x} - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot x \le -0.0016894500806073423:\\ \;\;\;\;\sqrt[3]{\log \left(e^{e^{a \cdot x} - 1}\right)} \cdot \left(\sqrt[3]{\log \left(e^{e^{a \cdot x} - 1}\right)} \cdot \sqrt[3]{\log \left(e^{e^{a \cdot x} - 1}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot x + \left(\frac{1}{2} + \left(x \cdot \frac{1}{6}\right) \cdot a\right) \cdot \left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right)\\ \end{array}\]

Error

Bits error versus a

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.2
Target0.1
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;\left|a \cdot x\right| \lt \frac{1}{10}:\\ \;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(\frac{a \cdot x}{2} + \frac{{\left(a \cdot x\right)}^{2}}{6}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{a \cdot x} - 1\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (* a x) < -0.0016894500806073423

    1. Initial program 0.0

      \[e^{a \cdot x} - 1\]
    2. Initial simplification0.0

      \[\leadsto e^{a \cdot x} - 1\]
    3. Using strategy rm
    4. Applied add-log-exp0.0

      \[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.0

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

    if -0.0016894500806073423 < (* a x)

    1. Initial program 44.3

      \[e^{a \cdot x} - 1\]
    2. Initial simplification44.3

      \[\leadsto e^{a \cdot x} - 1\]
    3. Taylor expanded around 0 13.7

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left({a}^{2} \cdot {x}^{2}\right) + \left(a \cdot x + \frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right)\right)}\]
    4. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot x \le -0.0016894500806073423:\\ \;\;\;\;\sqrt[3]{\log \left(e^{e^{a \cdot x} - 1}\right)} \cdot \left(\sqrt[3]{\log \left(e^{e^{a \cdot x} - 1}\right)} \cdot \sqrt[3]{\log \left(e^{e^{a \cdot x} - 1}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot x + \left(\frac{1}{2} + \left(x \cdot \frac{1}{6}\right) \cdot a\right) \cdot \left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2018362 
(FPCore (a x)
  :name "expax (section 3.5)"

  :herbie-target
  (if (< (fabs (* a x)) 1/10) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6)))) (- (exp (* a x)) 1))

  (- (exp (* a x)) 1))

Details

Time bar (total: 10.4s)Debug log

start111.0ms

Algorithm
intervals

setup43.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.6b

localize11.0ms

Local error

Found 2 expressions with local error:

2.8b
(- (exp (* a x)) 1)
0.0b
(exp (* a x))

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
2 → 21
Calls

2 calls. Slowest were:

4.0ms
(- (exp (* a x)) 1)
1.0ms
(exp (* a x))

series47.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

31.0ms
(- (exp (* a x)) 1)
16.0ms
(exp (* a x))

simplify455.0ms

Counts
9 → 27
Calls

9 calls. Slowest were:

350.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (+ (* a x) (* 1/6 (* (pow a 3) (pow x 3)))))
82.0ms
(+ (* a x) (+ (* 1/2 (* (pow a 2) (pow x 2))) 1))
5.0ms
(- (exp (* a x)) 1)

prune247.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize33.0ms

Local error

Found 4 expressions with local error:

0.4b
(* x 1/6)
0.2b
(* (* a x) (* a x))
0.2b
(* a (* x 1/6))
0.0b
(* (* (* a x) (* a x)) (+ (* a (* x 1/6)) 1/2))

rewrite23.0ms

Algorithm
rewrite-expression-head
Counts
4 → 55
Calls

4 calls. Slowest were:

13.0ms
(* (* (* a x) (* a x)) (+ (* a (* x 1/6)) 1/2))
6.0ms
(* (* a x) (* a x))
2.0ms
(* a (* x 1/6))

series96.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

52.0ms
(* (* (* a x) (* a x)) (+ (* a (* x 1/6)) 1/2))
21.0ms
(* (* a x) (* a x))
13.0ms
(* a (* x 1/6))
10.0ms
(* x 1/6)

simplify3.1s

Counts
32 → 67
Calls

32 calls. Slowest were:

632.0ms
(* (* (* (* a x) (* a x)) (* a x)) (* (* (* a x) (* a x)) (* a x)))
321.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (* 1/6 (* (pow a 3) (pow x 3))))
313.0ms
(+ (* 1/6 (* (pow a 3) (pow x 3))) (* 1/2 (* (pow a 2) (pow x 2))))

prune731.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize8.0ms

Local error

Found 3 expressions with local error:

2.8b
(log (exp (- (exp (* a x)) 1)))
2.8b
(- (exp (* a x)) 1)
0.0b
(exp (* a x))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
3 → 40
Calls

3 calls. Slowest were:

8.0ms
(log (exp (- (exp (* a x)) 1)))
4.0ms
(- (exp (* a x)) 1)
1.0ms
(exp (* a x))

series89.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

41.0ms
(- (exp (* a x)) 1)
38.0ms
(log (exp (- (exp (* a x)) 1)))
11.0ms
(exp (* a x))

simplify1.0s

Counts
23 → 49
Calls

23 calls. Slowest were:

436.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (+ (* a x) (* 1/6 (* (pow a 3) (pow x 3)))))
376.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (+ (* a x) (* 1/6 (* (pow a 3) (pow x 3)))))
106.0ms
(+ (* a x) (+ (* 1/2 (* (pow a 2) (pow x 2))) 1))

prune515.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 4 expressions with local error:

2.8b
(log (exp (- (exp (* a x)) 1)))
2.8b
(log (exp (- (exp (* a x)) 1)))
2.8b
(log (exp (- (exp (* a x)) 1)))
2.8b
(- (exp (* a x)) 1)

rewrite45.0ms

Algorithm
rewrite-expression-head
Counts
4 → 69
Calls

4 calls. Slowest were:

19.0ms
(log (exp (- (exp (* a x)) 1)))
8.0ms
(- (exp (* a x)) 1)
8.0ms
(log (exp (- (exp (* a x)) 1)))

series142.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

42.0ms
(log (exp (- (exp (* a x)) 1)))
38.0ms
(- (exp (* a x)) 1)
37.0ms
(log (exp (- (exp (* a x)) 1)))
24.0ms
(log (exp (- (exp (* a x)) 1)))

simplify2.0s

Counts
46 → 81
Calls

46 calls. Slowest were:

418.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (+ (* a x) (* 1/6 (* (pow a 3) (pow x 3)))))
418.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (+ (* a x) (* 1/6 (* (pow a 3) (pow x 3)))))
394.0ms
(+ (* 1/2 (* (pow a 2) (pow x 2))) (+ (* a x) (* 1/6 (* (pow a 3) (pow x 3)))))

prune1.2s

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

regimes445.0ms

Accuracy

99.5% (0.1b remaining)

Error of 0.2b against oracle of 0.1b and baseline of 21.0b

bsearch3.0ms