Expression 1, p15

Percentage Accurate: 99.4% → 99.6%
Time: 5.4s
Alternatives: 6
Speedup: TODO×

Specification

?
\[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]

Your Program's Arguments

Results

Enter valid numbers for all inputs

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Target

Original99.4%
Target99.6%
Herbie99.6%
\[\left(d + \left(c + \left(a + b\right)\right)\right) + e \]

Alternative 1?

\[d + \left(e + \left(c + \left(b + a\right)\right)\right) \]
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + c\right) + \left(b + a\right)} \]
    2. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
    3. +-commutative99.5%

      \[\leadsto \color{blue}{\left(d + e\right)} + \left(c + \left(b + a\right)\right) \]
    4. associate-+l+99.6%

      \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  4. Final simplification99.6%

    \[\leadsto d + \left(e + \left(c + \left(b + a\right)\right)\right) \]

Alternative 2?

\[b + \left(e + \left(d + \left(c + a\right)\right)\right) \]
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + c\right) + \left(b + a\right)} \]
    2. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
  3. Simplified99.5%

    \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
  4. Taylor expanded in c around 0 99.5%

    \[\leadsto \left(e + d\right) + \color{blue}{\left(c + \left(a + b\right)\right)} \]
  5. Step-by-step derivation
    1. associate-+r+99.5%

      \[\leadsto \left(e + d\right) + \color{blue}{\left(\left(c + a\right) + b\right)} \]
  6. Simplified99.5%

    \[\leadsto \left(e + d\right) + \color{blue}{\left(\left(c + a\right) + b\right)} \]
  7. Taylor expanded in e around 0 99.5%

    \[\leadsto \color{blue}{c + \left(a + \left(d + \left(b + e\right)\right)\right)} \]
  8. Step-by-step derivation
    1. associate-+r+99.5%

      \[\leadsto \color{blue}{\left(c + a\right) + \left(d + \left(b + e\right)\right)} \]
    2. +-commutative99.5%

      \[\leadsto \left(c + a\right) + \left(d + \color{blue}{\left(e + b\right)}\right) \]
    3. associate-+r+99.4%

      \[\leadsto \left(c + a\right) + \color{blue}{\left(\left(d + e\right) + b\right)} \]
    4. +-commutative99.4%

      \[\leadsto \left(c + a\right) + \left(\color{blue}{\left(e + d\right)} + b\right) \]
    5. associate-+r+99.5%

      \[\leadsto \color{blue}{\left(\left(c + a\right) + \left(e + d\right)\right) + b} \]
    6. +-commutative99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + \left(c + a\right)\right)} + b \]
    7. +-commutative99.5%

      \[\leadsto \color{blue}{b + \left(\left(e + d\right) + \left(c + a\right)\right)} \]
    8. associate-+l+99.6%

      \[\leadsto b + \color{blue}{\left(e + \left(d + \left(c + a\right)\right)\right)} \]
  9. Simplified99.6%

    \[\leadsto \color{blue}{b + \left(e + \left(d + \left(c + a\right)\right)\right)} \]
  10. Final simplification99.6%

    \[\leadsto b + \left(e + \left(d + \left(c + a\right)\right)\right) \]

Alternative 3?

\[b + \left(c + \left(d + e\right)\right) \]
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + c\right) + \left(b + a\right)} \]
    2. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
  3. Simplified99.5%

    \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
  4. Taylor expanded in c around 0 99.5%

    \[\leadsto \left(e + d\right) + \color{blue}{\left(c + \left(a + b\right)\right)} \]
  5. Step-by-step derivation
    1. associate-+r+99.5%

      \[\leadsto \left(e + d\right) + \color{blue}{\left(\left(c + a\right) + b\right)} \]
  6. Simplified99.5%

    \[\leadsto \left(e + d\right) + \color{blue}{\left(\left(c + a\right) + b\right)} \]
  7. Taylor expanded in e around 0 99.5%

    \[\leadsto \color{blue}{c + \left(a + \left(d + \left(b + e\right)\right)\right)} \]
  8. Step-by-step derivation
    1. associate-+r+99.5%

      \[\leadsto \color{blue}{\left(c + a\right) + \left(d + \left(b + e\right)\right)} \]
    2. +-commutative99.5%

      \[\leadsto \left(c + a\right) + \left(d + \color{blue}{\left(e + b\right)}\right) \]
    3. associate-+r+99.4%

      \[\leadsto \left(c + a\right) + \color{blue}{\left(\left(d + e\right) + b\right)} \]
    4. +-commutative99.4%

      \[\leadsto \left(c + a\right) + \left(\color{blue}{\left(e + d\right)} + b\right) \]
    5. associate-+r+99.5%

      \[\leadsto \color{blue}{\left(\left(c + a\right) + \left(e + d\right)\right) + b} \]
    6. +-commutative99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + \left(c + a\right)\right)} + b \]
    7. +-commutative99.5%

      \[\leadsto \color{blue}{b + \left(\left(e + d\right) + \left(c + a\right)\right)} \]
    8. associate-+l+99.6%

      \[\leadsto b + \color{blue}{\left(e + \left(d + \left(c + a\right)\right)\right)} \]
  9. Simplified99.6%

    \[\leadsto \color{blue}{b + \left(e + \left(d + \left(c + a\right)\right)\right)} \]
  10. Taylor expanded in a around 0 25.7%

    \[\leadsto b + \color{blue}{\left(c + \left(d + e\right)\right)} \]
  11. Final simplification25.7%

    \[\leadsto b + \left(c + \left(d + e\right)\right) \]

Alternative 4?

\[c + \left(d + e\right) \]
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + c\right) + \left(b + a\right)} \]
    2. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
    3. +-commutative99.5%

      \[\leadsto \color{blue}{\left(d + e\right)} + \left(c + \left(b + a\right)\right) \]
    4. associate-+l+99.6%

      \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  4. Taylor expanded in a around 0 25.7%

    \[\leadsto \color{blue}{c + \left(d + \left(b + e\right)\right)} \]
  5. Step-by-step derivation
    1. associate-+r+25.7%

      \[\leadsto c + \color{blue}{\left(\left(d + b\right) + e\right)} \]
    2. +-commutative25.7%

      \[\leadsto c + \left(\color{blue}{\left(b + d\right)} + e\right) \]
    3. associate-+l+25.7%

      \[\leadsto c + \color{blue}{\left(b + \left(d + e\right)\right)} \]
    4. +-commutative25.7%

      \[\leadsto c + \left(b + \color{blue}{\left(e + d\right)}\right) \]
  6. Simplified25.7%

    \[\leadsto \color{blue}{c + \left(b + \left(e + d\right)\right)} \]
  7. Taylor expanded in b around 0 23.2%

    \[\leadsto c + \color{blue}{\left(d + e\right)} \]
  8. Final simplification23.2%

    \[\leadsto c + \left(d + e\right) \]

Alternative 5?

\[d + e \]
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + c\right) + \left(b + a\right)} \]
    2. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
    3. +-commutative99.5%

      \[\leadsto \color{blue}{\left(d + e\right)} + \left(c + \left(b + a\right)\right) \]
    4. associate-+l+99.6%

      \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  4. Taylor expanded in a around 0 25.7%

    \[\leadsto \color{blue}{c + \left(d + \left(b + e\right)\right)} \]
  5. Step-by-step derivation
    1. associate-+r+25.7%

      \[\leadsto c + \color{blue}{\left(\left(d + b\right) + e\right)} \]
    2. +-commutative25.7%

      \[\leadsto c + \left(\color{blue}{\left(b + d\right)} + e\right) \]
    3. associate-+l+25.7%

      \[\leadsto c + \color{blue}{\left(b + \left(d + e\right)\right)} \]
    4. +-commutative25.7%

      \[\leadsto c + \left(b + \color{blue}{\left(e + d\right)}\right) \]
  6. Simplified25.7%

    \[\leadsto \color{blue}{c + \left(b + \left(e + d\right)\right)} \]
  7. Taylor expanded in b around 0 23.2%

    \[\leadsto c + \color{blue}{\left(d + e\right)} \]
  8. Taylor expanded in c around 0 21.1%

    \[\leadsto \color{blue}{d + e} \]
  9. Final simplification21.1%

    \[\leadsto d + e \]

Alternative 6?

\[e \]
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(\left(e + d\right) + c\right) + \left(b + a\right)} \]
    2. associate-+l+99.5%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
    3. +-commutative99.5%

      \[\leadsto \color{blue}{\left(d + e\right)} + \left(c + \left(b + a\right)\right) \]
    4. associate-+l+99.6%

      \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  3. Simplified99.6%

    \[\leadsto \color{blue}{d + \left(e + \left(c + \left(b + a\right)\right)\right)} \]
  4. Taylor expanded in e around inf 18.9%

    \[\leadsto \color{blue}{e} \]
  5. Final simplification18.9%

    \[\leadsto e \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (a b c d e)
  :name "Expression 1, p15"
  :precision binary64
  :pre (and (and (and (and (and (and (and (and (and (<= 1.0 a) (<= a 2.0)) (<= 2.0 b)) (<= b 4.0)) (<= 4.0 c)) (<= c 8.0)) (<= 8.0 d)) (<= d 16.0)) (<= 16.0 e)) (<= e 32.0))

  :herbie-target
  (+ (+ d (+ c (+ a b))) e)

  (+ (+ (+ (+ e d) c) b) a))