Expression 1, p15

Percentage Accurate: 99.4% → 99.6%
Time: 9.1s
Alternatives: 8
Speedup: 1.0×

Specification

?
\[\left(\left(\left(\left(\left(\left(\left(\left(1 \leq a \land a \leq 2\right) \land 2 \leq b\right) \land b \leq 4\right) \land 4 \leq c\right) \land c \leq 8\right) \land 8 \leq d\right) \land d \leq 16\right) \land 16 \leq e\right) \land e \leq 32\]
\[\begin{array}{l} \\ \left(\left(\left(e + d\right) + c\right) + b\right) + a \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ (+ (+ (+ e d) c) b) a))
double code(double a, double b, double c, double d, double e) {
	return (((e + d) + c) + b) + a;
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = (((e + d) + c) + b) + a
end function
public static double code(double a, double b, double c, double d, double e) {
	return (((e + d) + c) + b) + a;
}
def code(a, b, c, d, e):
	return (((e + d) + c) + b) + a
function code(a, b, c, d, e)
	return Float64(Float64(Float64(Float64(e + d) + c) + b) + a)
end
function tmp = code(a, b, c, d, e)
	tmp = (((e + d) + c) + b) + a;
end
code[a_, b_, c_, d_, e_] := N[(N[(N[(N[(e + d), $MachinePrecision] + c), $MachinePrecision] + b), $MachinePrecision] + a), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(\left(e + d\right) + c\right) + b\right) + a
\end{array}

Sampling outcomes in binary64 precision:

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 8 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.

Initial Program: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(\left(e + d\right) + c\right) + b\right) + a \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ (+ (+ (+ e d) c) b) a))
double code(double a, double b, double c, double d, double e) {
	return (((e + d) + c) + b) + a;
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = (((e + d) + c) + b) + a
end function
public static double code(double a, double b, double c, double d, double e) {
	return (((e + d) + c) + b) + a;
}
def code(a, b, c, d, e):
	return (((e + d) + c) + b) + a
function code(a, b, c, d, e)
	return Float64(Float64(Float64(Float64(e + d) + c) + b) + a)
end
function tmp = code(a, b, c, d, e)
	tmp = (((e + d) + c) + b) + a;
end
code[a_, b_, c_, d_, e_] := N[(N[(N[(N[(e + d), $MachinePrecision] + c), $MachinePrecision] + b), $MachinePrecision] + a), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(\left(e + d\right) + c\right) + b\right) + a
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(c + \left(b + a\right)\right) + e\right) + d \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ (+ (+ c (+ b a)) e) d))
double code(double a, double b, double c, double d, double e) {
	return ((c + (b + a)) + e) + d;
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = ((c + (b + a)) + e) + d
end function
public static double code(double a, double b, double c, double d, double e) {
	return ((c + (b + a)) + e) + d;
}
def code(a, b, c, d, e):
	return ((c + (b + a)) + e) + d
function code(a, b, c, d, e)
	return Float64(Float64(Float64(c + Float64(b + a)) + e) + d)
end
function tmp = code(a, b, c, d, e)
	tmp = ((c + (b + a)) + e) + d;
end
code[a_, b_, c_, d_, e_] := N[(N[(N[(c + N[(b + a), $MachinePrecision]), $MachinePrecision] + e), $MachinePrecision] + d), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(c + \left(b + a\right)\right) + e\right) + d
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
    2. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
    4. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
    8. +-lowering-+.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(c + \left(\left(e + d\right) + b\right)\right) + a} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-+r+N/A

      \[\leadsto \left(\left(c + \left(e + d\right)\right) + b\right) + a \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(\left(e + d\right) + c\right) + b\right) + a \]
    3. associate-+l+N/A

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

      \[\leadsto \left(e + d\right) + \color{blue}{\left(c + \left(b + a\right)\right)} \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(e + d\right), \color{blue}{\left(c + \left(b + a\right)\right)}\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \left(\color{blue}{c} + \left(b + a\right)\right)\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \color{blue}{\left(b + a\right)}\right)\right) \]
    8. +-lowering-+.f6499.6%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
  6. Applied egg-rr99.6%

    \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
  7. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \left(c + \left(b + a\right)\right) + \color{blue}{\left(e + d\right)} \]
    2. associate-+r+N/A

      \[\leadsto \left(\left(c + \left(b + a\right)\right) + e\right) + \color{blue}{d} \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(c + \left(b + a\right)\right) + e\right), \color{blue}{d}\right) \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\left(c + \left(b + a\right)\right), e\right), d\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + a\right)\right), e\right), d\right) \]
    6. +-lowering-+.f6499.7%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(b, a\right)\right), e\right), d\right) \]
  8. Applied egg-rr99.7%

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

Alternative 2: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(c + \left(b + a\right)\right) + \left(e + d\right) \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ (+ c (+ b a)) (+ e d)))
double code(double a, double b, double c, double d, double e) {
	return (c + (b + a)) + (e + d);
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = (c + (b + a)) + (e + d)
end function
public static double code(double a, double b, double c, double d, double e) {
	return (c + (b + a)) + (e + d);
}
def code(a, b, c, d, e):
	return (c + (b + a)) + (e + d)
function code(a, b, c, d, e)
	return Float64(Float64(c + Float64(b + a)) + Float64(e + d))
end
function tmp = code(a, b, c, d, e)
	tmp = (c + (b + a)) + (e + d);
end
code[a_, b_, c_, d_, e_] := N[(N[(c + N[(b + a), $MachinePrecision]), $MachinePrecision] + N[(e + d), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(c + \left(b + a\right)\right) + \left(e + d\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
    2. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
    4. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
    8. +-lowering-+.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(c + \left(\left(e + d\right) + b\right)\right) + a} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-+r+N/A

      \[\leadsto \left(\left(c + \left(e + d\right)\right) + b\right) + a \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(\left(e + d\right) + c\right) + b\right) + a \]
    3. associate-+l+N/A

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

      \[\leadsto \left(e + d\right) + \color{blue}{\left(c + \left(b + a\right)\right)} \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(e + d\right), \color{blue}{\left(c + \left(b + a\right)\right)}\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \left(\color{blue}{c} + \left(b + a\right)\right)\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \color{blue}{\left(b + a\right)}\right)\right) \]
    8. +-lowering-+.f6499.6%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
  6. Applied egg-rr99.6%

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

    \[\leadsto \left(c + \left(b + a\right)\right) + \left(e + d\right) \]
  8. Add Preprocessing

Alternative 3: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(b + a\right) + \left(c + \left(e + d\right)\right) \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ (+ b a) (+ c (+ e d))))
double code(double a, double b, double c, double d, double e) {
	return (b + a) + (c + (e + d));
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = (b + a) + (c + (e + d))
end function
public static double code(double a, double b, double c, double d, double e) {
	return (b + a) + (c + (e + d));
}
def code(a, b, c, d, e):
	return (b + a) + (c + (e + d))
function code(a, b, c, d, e)
	return Float64(Float64(b + a) + Float64(c + Float64(e + d)))
end
function tmp = code(a, b, c, d, e)
	tmp = (b + a) + (c + (e + d));
end
code[a_, b_, c_, d_, e_] := N[(N[(b + a), $MachinePrecision] + N[(c + N[(e + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(b + a\right) + \left(c + \left(e + d\right)\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
    2. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
    4. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
    8. +-lowering-+.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(c + \left(\left(e + d\right) + b\right)\right) + a} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-+r+N/A

      \[\leadsto \left(\left(c + \left(e + d\right)\right) + b\right) + a \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(\left(e + d\right) + c\right) + b\right) + a \]
    3. associate-+l+N/A

      \[\leadsto \left(\left(e + d\right) + c\right) + \color{blue}{\left(b + a\right)} \]
    4. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + c\right), \color{blue}{\left(b + a\right)}\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(c + \left(e + d\right)\right), \left(\color{blue}{b} + a\right)\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(e + d\right)\right), \left(\color{blue}{b} + a\right)\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(e, d\right)\right), \left(b + a\right)\right) \]
    8. +-lowering-+.f6499.6%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(e, d\right)\right), \mathsf{+.f64}\left(b, \color{blue}{a}\right)\right) \]
  6. Applied egg-rr99.6%

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

    \[\leadsto \left(b + a\right) + \left(c + \left(e + d\right)\right) \]
  8. Add Preprocessing

Alternative 4: 25.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ d + \left(b + \left(c + e\right)\right) \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ d (+ b (+ c e))))
double code(double a, double b, double c, double d, double e) {
	return d + (b + (c + e));
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = d + (b + (c + e))
end function
public static double code(double a, double b, double c, double d, double e) {
	return d + (b + (c + e));
}
def code(a, b, c, d, e):
	return d + (b + (c + e))
function code(a, b, c, d, e)
	return Float64(d + Float64(b + Float64(c + e)))
end
function tmp = code(a, b, c, d, e)
	tmp = d + (b + (c + e));
end
code[a_, b_, c_, d_, e_] := N[(d + N[(b + N[(c + e), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
d + \left(b + \left(c + e\right)\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
    2. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
    4. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
    8. +-lowering-+.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
  3. Simplified99.4%

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

    \[\leadsto \color{blue}{b + \left(c + \left(d + e\right)\right)} \]
  6. Step-by-step derivation
    1. associate-+r+N/A

      \[\leadsto \left(b + c\right) + \color{blue}{\left(d + e\right)} \]
    2. +-commutativeN/A

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

      \[\leadsto d + \color{blue}{\left(e + \left(b + c\right)\right)} \]
    4. +-commutativeN/A

      \[\leadsto d + \left(\left(b + c\right) + \color{blue}{e}\right) \]
    5. associate-+r+N/A

      \[\leadsto d + \left(b + \color{blue}{\left(c + e\right)}\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(d, \color{blue}{\left(b + \left(c + e\right)\right)}\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(d, \mathsf{+.f64}\left(b, \color{blue}{\left(c + e\right)}\right)\right) \]
    8. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(d, \mathsf{+.f64}\left(b, \left(e + \color{blue}{c}\right)\right)\right) \]
    9. +-lowering-+.f6425.7%

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

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

    \[\leadsto d + \left(b + \left(c + e\right)\right) \]
  9. Add Preprocessing

Alternative 5: 23.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ e + \left(c + d\right) \end{array} \]
(FPCore (a b c d e) :precision binary64 (+ e (+ c d)))
double code(double a, double b, double c, double d, double e) {
	return e + (c + d);
}
real(8) function code(a, b, c, d, e)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8), intent (in) :: e
    code = e + (c + d)
end function
public static double code(double a, double b, double c, double d, double e) {
	return e + (c + d);
}
def code(a, b, c, d, e):
	return e + (c + d)
function code(a, b, c, d, e)
	return Float64(e + Float64(c + d))
end
function tmp = code(a, b, c, d, e)
	tmp = e + (c + d);
end
code[a_, b_, c_, d_, e_] := N[(e + N[(c + d), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e + \left(c + d\right)
\end{array}
Derivation
  1. Initial program 99.4%

    \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
  2. Step-by-step derivation
    1. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
    2. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
    4. associate-+l+N/A

      \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
    8. +-lowering-+.f6499.4%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\left(c + \left(\left(e + d\right) + b\right)\right) + a} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. associate-+r+N/A

      \[\leadsto \left(\left(c + \left(e + d\right)\right) + b\right) + a \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(\left(e + d\right) + c\right) + b\right) + a \]
    3. associate-+l+N/A

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

      \[\leadsto \left(e + d\right) + \color{blue}{\left(c + \left(b + a\right)\right)} \]
    5. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(e + d\right), \color{blue}{\left(c + \left(b + a\right)\right)}\right) \]
    6. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \left(\color{blue}{c} + \left(b + a\right)\right)\right) \]
    7. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \color{blue}{\left(b + a\right)}\right)\right) \]
    8. +-lowering-+.f6499.6%

      \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
  6. Applied egg-rr99.6%

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

    \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \color{blue}{c}\right) \]
  8. Step-by-step derivation
    1. Simplified23.2%

      \[\leadsto \left(e + d\right) + \color{blue}{c} \]
    2. Step-by-step derivation
      1. associate-+l+N/A

        \[\leadsto e + \color{blue}{\left(d + c\right)} \]
      2. +-commutativeN/A

        \[\leadsto \left(d + c\right) + \color{blue}{e} \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\left(d + c\right), \color{blue}{e}\right) \]
      4. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(c + d\right), e\right) \]
      5. +-lowering-+.f6423.2%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, d\right), e\right) \]
    3. Applied egg-rr23.2%

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

      \[\leadsto e + \left(c + d\right) \]
    5. Add Preprocessing

    Alternative 6: 21.2% accurate, 3.0× speedup?

    \[\begin{array}{l} \\ e + d \end{array} \]
    (FPCore (a b c d e) :precision binary64 (+ e d))
    double code(double a, double b, double c, double d, double e) {
    	return e + d;
    }
    
    real(8) function code(a, b, c, d, e)
        real(8), intent (in) :: a
        real(8), intent (in) :: b
        real(8), intent (in) :: c
        real(8), intent (in) :: d
        real(8), intent (in) :: e
        code = e + d
    end function
    
    public static double code(double a, double b, double c, double d, double e) {
    	return e + d;
    }
    
    def code(a, b, c, d, e):
    	return e + d
    
    function code(a, b, c, d, e)
    	return Float64(e + d)
    end
    
    function tmp = code(a, b, c, d, e)
    	tmp = e + d;
    end
    
    code[a_, b_, c_, d_, e_] := N[(e + d), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    e + d
    \end{array}
    
    Derivation
    1. Initial program 99.4%

      \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
    2. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
      2. associate-+l+N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
      4. associate-+l+N/A

        \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
      8. +-lowering-+.f6499.4%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{\left(c + \left(\left(e + d\right) + b\right)\right) + a} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \left(\left(c + \left(e + d\right)\right) + b\right) + a \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\left(e + d\right) + c\right) + b\right) + a \]
      3. associate-+l+N/A

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

        \[\leadsto \left(e + d\right) + \color{blue}{\left(c + \left(b + a\right)\right)} \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\left(e + d\right), \color{blue}{\left(c + \left(b + a\right)\right)}\right) \]
      6. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \left(\color{blue}{c} + \left(b + a\right)\right)\right) \]
      7. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \color{blue}{\left(b + a\right)}\right)\right) \]
      8. +-lowering-+.f6499.6%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), \mathsf{+.f64}\left(c, \mathsf{+.f64}\left(b, \color{blue}{a}\right)\right)\right) \]
    6. Applied egg-rr99.6%

      \[\leadsto \color{blue}{\left(e + d\right) + \left(c + \left(b + a\right)\right)} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(c + \left(b + a\right)\right) + \color{blue}{\left(e + d\right)} \]
      2. associate-+r+N/A

        \[\leadsto \left(\left(c + \left(b + a\right)\right) + e\right) + \color{blue}{d} \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\left(\left(c + \left(b + a\right)\right) + e\right), \color{blue}{d}\right) \]
      4. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\left(c + \left(b + a\right)\right), e\right), d\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + a\right)\right), e\right), d\right) \]
      6. +-lowering-+.f6499.7%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(b, a\right)\right), e\right), d\right) \]
    8. Applied egg-rr99.7%

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

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{e}, d\right) \]
    10. Step-by-step derivation
      1. Simplified21.1%

        \[\leadsto \color{blue}{e} + d \]
      2. Add Preprocessing

      Alternative 7: 19.9% accurate, 3.0× speedup?

      \[\begin{array}{l} \\ c + e \end{array} \]
      (FPCore (a b c d e) :precision binary64 (+ c e))
      double code(double a, double b, double c, double d, double e) {
      	return c + e;
      }
      
      real(8) function code(a, b, c, d, e)
          real(8), intent (in) :: a
          real(8), intent (in) :: b
          real(8), intent (in) :: c
          real(8), intent (in) :: d
          real(8), intent (in) :: e
          code = c + e
      end function
      
      public static double code(double a, double b, double c, double d, double e) {
      	return c + e;
      }
      
      def code(a, b, c, d, e):
      	return c + e
      
      function code(a, b, c, d, e)
      	return Float64(c + e)
      end
      
      function tmp = code(a, b, c, d, e)
      	tmp = c + e;
      end
      
      code[a_, b_, c_, d_, e_] := N[(c + e), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      c + e
      \end{array}
      
      Derivation
      1. Initial program 99.4%

        \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
      2. Step-by-step derivation
        1. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
        2. associate-+l+N/A

          \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
        3. +-commutativeN/A

          \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
        4. associate-+l+N/A

          \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
        6. +-commutativeN/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
        7. +-lowering-+.f64N/A

          \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
        8. +-lowering-+.f6499.4%

          \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
      3. Simplified99.4%

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

        \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \color{blue}{e}\right), a\right) \]
      6. Step-by-step derivation
        1. Simplified20.2%

          \[\leadsto \left(c + \color{blue}{e}\right) + a \]
        2. Taylor expanded in a around 0

          \[\leadsto \color{blue}{c + e} \]
        3. Step-by-step derivation
          1. +-lowering-+.f6419.9%

            \[\leadsto \mathsf{+.f64}\left(c, \color{blue}{e}\right) \]
        4. Simplified19.9%

          \[\leadsto \color{blue}{c + e} \]
        5. Add Preprocessing

        Alternative 8: 18.9% accurate, 9.0× speedup?

        \[\begin{array}{l} \\ e \end{array} \]
        (FPCore (a b c d e) :precision binary64 e)
        double code(double a, double b, double c, double d, double e) {
        	return e;
        }
        
        real(8) function code(a, b, c, d, e)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            real(8), intent (in) :: d
            real(8), intent (in) :: e
            code = e
        end function
        
        public static double code(double a, double b, double c, double d, double e) {
        	return e;
        }
        
        def code(a, b, c, d, e):
        	return e
        
        function code(a, b, c, d, e)
        	return e
        end
        
        function tmp = code(a, b, c, d, e)
        	tmp = e;
        end
        
        code[a_, b_, c_, d_, e_] := e
        
        \begin{array}{l}
        
        \\
        e
        \end{array}
        
        Derivation
        1. Initial program 99.4%

          \[\left(\left(\left(e + d\right) + c\right) + b\right) + a \]
        2. Step-by-step derivation
          1. +-lowering-+.f64N/A

            \[\leadsto \mathsf{+.f64}\left(\left(\left(\left(e + d\right) + c\right) + b\right), \color{blue}{a}\right) \]
          2. associate-+l+N/A

            \[\leadsto \mathsf{+.f64}\left(\left(\left(e + d\right) + \left(c + b\right)\right), a\right) \]
          3. +-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(\left(\left(c + b\right) + \left(e + d\right)\right), a\right) \]
          4. associate-+l+N/A

            \[\leadsto \mathsf{+.f64}\left(\left(c + \left(b + \left(e + d\right)\right)\right), a\right) \]
          5. +-lowering-+.f64N/A

            \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(b + \left(e + d\right)\right)\right), a\right) \]
          6. +-commutativeN/A

            \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \left(\left(e + d\right) + b\right)\right), a\right) \]
          7. +-lowering-+.f64N/A

            \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\left(e + d\right), b\right)\right), a\right) \]
          8. +-lowering-+.f6499.4%

            \[\leadsto \mathsf{+.f64}\left(\mathsf{+.f64}\left(c, \mathsf{+.f64}\left(\mathsf{+.f64}\left(e, d\right), b\right)\right), a\right) \]
        3. Simplified99.4%

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

          \[\leadsto \color{blue}{e} \]
        6. Step-by-step derivation
          1. Simplified18.9%

            \[\leadsto \color{blue}{e} \]
          2. Add Preprocessing

          Developer Target 1: 99.6% accurate, 1.0× speedup?

          \[\begin{array}{l} \\ \left(d + \left(c + \left(a + b\right)\right)\right) + e \end{array} \]
          (FPCore (a b c d e) :precision binary64 (+ (+ d (+ c (+ a b))) e))
          double code(double a, double b, double c, double d, double e) {
          	return (d + (c + (a + b))) + e;
          }
          
          real(8) function code(a, b, c, d, e)
              real(8), intent (in) :: a
              real(8), intent (in) :: b
              real(8), intent (in) :: c
              real(8), intent (in) :: d
              real(8), intent (in) :: e
              code = (d + (c + (a + b))) + e
          end function
          
          public static double code(double a, double b, double c, double d, double e) {
          	return (d + (c + (a + b))) + e;
          }
          
          def code(a, b, c, d, e):
          	return (d + (c + (a + b))) + e
          
          function code(a, b, c, d, e)
          	return Float64(Float64(d + Float64(c + Float64(a + b))) + e)
          end
          
          function tmp = code(a, b, c, d, e)
          	tmp = (d + (c + (a + b))) + e;
          end
          
          code[a_, b_, c_, d_, e_] := N[(N[(d + N[(c + N[(a + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + e), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \left(d + \left(c + \left(a + b\right)\right)\right) + e
          \end{array}
          

          Reproduce

          ?
          herbie shell --seed 2024161 
          (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))
          
            :alt
            (! :herbie-platform default (+ (+ d (+ c (+ a b))) e))
          
            (+ (+ (+ (+ e d) c) b) a))