Expression, p6

Percentage Accurate: 94.3% → 100.0%
Time: 6.7s
Alternatives: 6
Speedup: 1.0×

Specification

?
\[\left(\left(\left(-14 \leq a \land a \leq -13\right) \land \left(-3 \leq b \land b \leq -2\right)\right) \land \left(3 \leq c \land c \leq 3.5\right)\right) \land \left(12.5 \leq d \land d \leq 13.5\right)\]
\[\begin{array}{l} \\ \left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \end{array} \]
(FPCore (a b c d) :precision binary64 (* (+ a (+ b (+ c d))) 2.0))
double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    code = (a + (b + (c + d))) * 2.0d0
end function
public static double code(double a, double b, double c, double d) {
	return (a + (b + (c + d))) * 2.0;
}
def code(a, b, c, d):
	return (a + (b + (c + d))) * 2.0
function code(a, b, c, d)
	return Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0)
end
function tmp = code(a, b, c, d)
	tmp = (a + (b + (c + d))) * 2.0;
end
code[a_, b_, c_, d_] := N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]
\begin{array}{l}

\\
\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2
\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 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.

Initial Program: 94.3% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\left(b + c\right) + \left(d + a\right)\right)} \cdot 2 \]
    7. lower-+.f64N/A

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

      \[\leadsto \left(\color{blue}{\left(c + b\right)} + \left(d + a\right)\right) \cdot 2 \]
    9. lower-+.f64N/A

      \[\leadsto \left(\color{blue}{\left(c + b\right)} + \left(d + a\right)\right) \cdot 2 \]
    10. lower-+.f64100.0

      \[\leadsto \left(\left(c + b\right) + \color{blue}{\left(d + a\right)}\right) \cdot 2 \]
  4. Applied rewrites100.0%

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

Alternative 2: 17.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \leq -0.005:\\ \;\;\;\;\left(d + a\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(\left(c + a\right) + d\right) \cdot 2\\ \end{array} \end{array} \]
(FPCore (a b c d)
 :precision binary64
 (if (<= (* (+ a (+ b (+ c d))) 2.0) -0.005)
   (* (+ d a) 2.0)
   (* (+ (+ c a) d) 2.0)))
double code(double a, double b, double c, double d) {
	double tmp;
	if (((a + (b + (c + d))) * 2.0) <= -0.005) {
		tmp = (d + a) * 2.0;
	} else {
		tmp = ((c + a) + d) * 2.0;
	}
	return tmp;
}
real(8) function code(a, b, c, d)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: d
    real(8) :: tmp
    if (((a + (b + (c + d))) * 2.0d0) <= (-0.005d0)) then
        tmp = (d + a) * 2.0d0
    else
        tmp = ((c + a) + d) * 2.0d0
    end if
    code = tmp
end function
public static double code(double a, double b, double c, double d) {
	double tmp;
	if (((a + (b + (c + d))) * 2.0) <= -0.005) {
		tmp = (d + a) * 2.0;
	} else {
		tmp = ((c + a) + d) * 2.0;
	}
	return tmp;
}
def code(a, b, c, d):
	tmp = 0
	if ((a + (b + (c + d))) * 2.0) <= -0.005:
		tmp = (d + a) * 2.0
	else:
		tmp = ((c + a) + d) * 2.0
	return tmp
function code(a, b, c, d)
	tmp = 0.0
	if (Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0) <= -0.005)
		tmp = Float64(Float64(d + a) * 2.0);
	else
		tmp = Float64(Float64(Float64(c + a) + d) * 2.0);
	end
	return tmp
end
function tmp_2 = code(a, b, c, d)
	tmp = 0.0;
	if (((a + (b + (c + d))) * 2.0) <= -0.005)
		tmp = (d + a) * 2.0;
	else
		tmp = ((c + a) + d) * 2.0;
	end
	tmp_2 = tmp;
end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], -0.005], N[(N[(d + a), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(N[(c + a), $MachinePrecision] + d), $MachinePrecision] * 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \leq -0.005:\\
\;\;\;\;\left(d + a\right) \cdot 2\\

\mathbf{else}:\\
\;\;\;\;\left(\left(c + a\right) + d\right) \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (+.f64 a (+.f64 b (+.f64 c d))) #s(literal 2 binary64)) < -0.0050000000000000001

    1. Initial program 93.5%

      \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
    2. Add Preprocessing
    3. Taylor expanded in b around 0

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

        \[\leadsto \left(a + \color{blue}{\left(d + c\right)}\right) \cdot 2 \]
      2. lower-+.f641.6

        \[\leadsto \left(a + \color{blue}{\left(d + c\right)}\right) \cdot 2 \]
    5. Applied rewrites1.6%

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

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

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

        \[\leadsto \color{blue}{\left(\left(a + d\right) + c\right)} \cdot 2 \]
      3. lower-+.f64N/A

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

        \[\leadsto \left(\color{blue}{\left(d + a\right)} + c\right) \cdot 2 \]
      5. lower-+.f641.6

        \[\leadsto \left(\color{blue}{\left(d + a\right)} + c\right) \cdot 2 \]
    8. Applied rewrites1.6%

      \[\leadsto \color{blue}{\left(\left(d + a\right) + c\right)} \cdot 2 \]
    9. Step-by-step derivation
      1. Applied rewrites1.6%

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

        \[\leadsto \left(a + \color{blue}{d}\right) \cdot 2 \]
      3. Step-by-step derivation
        1. Applied rewrites18.0%

          \[\leadsto \left(d + \color{blue}{a}\right) \cdot 2 \]

        if -0.0050000000000000001 < (*.f64 (+.f64 a (+.f64 b (+.f64 c d))) #s(literal 2 binary64))

        1. Initial program 94.5%

          \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
        2. Add Preprocessing
        3. Taylor expanded in b around 0

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

            \[\leadsto \left(a + \color{blue}{\left(d + c\right)}\right) \cdot 2 \]
          2. lower-+.f6416.5

            \[\leadsto \left(a + \color{blue}{\left(d + c\right)}\right) \cdot 2 \]
        5. Applied rewrites16.5%

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

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

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

            \[\leadsto \color{blue}{\left(\left(a + d\right) + c\right)} \cdot 2 \]
          3. lower-+.f64N/A

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

            \[\leadsto \left(\color{blue}{\left(d + a\right)} + c\right) \cdot 2 \]
          5. lower-+.f6416.5

            \[\leadsto \left(\color{blue}{\left(d + a\right)} + c\right) \cdot 2 \]
        8. Applied rewrites16.5%

          \[\leadsto \color{blue}{\left(\left(d + a\right) + c\right)} \cdot 2 \]
        9. Step-by-step derivation
          1. Applied rewrites16.5%

            \[\leadsto \left(\left(c + a\right) + \color{blue}{d}\right) \cdot 2 \]
        10. Recombined 2 regimes into one program.
        11. Add Preprocessing

        Alternative 3: 16.9% accurate, 0.5× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \leq -0.005:\\ \;\;\;\;\left(d + a\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;c + c\\ \end{array} \end{array} \]
        (FPCore (a b c d)
         :precision binary64
         (if (<= (* (+ a (+ b (+ c d))) 2.0) -0.005) (* (+ d a) 2.0) (+ c c)))
        double code(double a, double b, double c, double d) {
        	double tmp;
        	if (((a + (b + (c + d))) * 2.0) <= -0.005) {
        		tmp = (d + a) * 2.0;
        	} else {
        		tmp = c + c;
        	}
        	return tmp;
        }
        
        real(8) function code(a, b, c, d)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            real(8), intent (in) :: d
            real(8) :: tmp
            if (((a + (b + (c + d))) * 2.0d0) <= (-0.005d0)) then
                tmp = (d + a) * 2.0d0
            else
                tmp = c + c
            end if
            code = tmp
        end function
        
        public static double code(double a, double b, double c, double d) {
        	double tmp;
        	if (((a + (b + (c + d))) * 2.0) <= -0.005) {
        		tmp = (d + a) * 2.0;
        	} else {
        		tmp = c + c;
        	}
        	return tmp;
        }
        
        def code(a, b, c, d):
        	tmp = 0
        	if ((a + (b + (c + d))) * 2.0) <= -0.005:
        		tmp = (d + a) * 2.0
        	else:
        		tmp = c + c
        	return tmp
        
        function code(a, b, c, d)
        	tmp = 0.0
        	if (Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0) <= -0.005)
        		tmp = Float64(Float64(d + a) * 2.0);
        	else
        		tmp = Float64(c + c);
        	end
        	return tmp
        end
        
        function tmp_2 = code(a, b, c, d)
        	tmp = 0.0;
        	if (((a + (b + (c + d))) * 2.0) <= -0.005)
        		tmp = (d + a) * 2.0;
        	else
        		tmp = c + c;
        	end
        	tmp_2 = tmp;
        end
        
        code[a_, b_, c_, d_] := If[LessEqual[N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], -0.005], N[(N[(d + a), $MachinePrecision] * 2.0), $MachinePrecision], N[(c + c), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \leq -0.005:\\
        \;\;\;\;\left(d + a\right) \cdot 2\\
        
        \mathbf{else}:\\
        \;\;\;\;c + c\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (*.f64 (+.f64 a (+.f64 b (+.f64 c d))) #s(literal 2 binary64)) < -0.0050000000000000001

          1. Initial program 93.5%

            \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
          2. Add Preprocessing
          3. Taylor expanded in b around 0

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

              \[\leadsto \left(a + \color{blue}{\left(d + c\right)}\right) \cdot 2 \]
            2. lower-+.f641.6

              \[\leadsto \left(a + \color{blue}{\left(d + c\right)}\right) \cdot 2 \]
          5. Applied rewrites1.6%

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

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

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

              \[\leadsto \color{blue}{\left(\left(a + d\right) + c\right)} \cdot 2 \]
            3. lower-+.f64N/A

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

              \[\leadsto \left(\color{blue}{\left(d + a\right)} + c\right) \cdot 2 \]
            5. lower-+.f641.6

              \[\leadsto \left(\color{blue}{\left(d + a\right)} + c\right) \cdot 2 \]
          8. Applied rewrites1.6%

            \[\leadsto \color{blue}{\left(\left(d + a\right) + c\right)} \cdot 2 \]
          9. Step-by-step derivation
            1. Applied rewrites1.6%

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

              \[\leadsto \left(a + \color{blue}{d}\right) \cdot 2 \]
            3. Step-by-step derivation
              1. Applied rewrites18.0%

                \[\leadsto \left(d + \color{blue}{a}\right) \cdot 2 \]

              if -0.0050000000000000001 < (*.f64 (+.f64 a (+.f64 b (+.f64 c d))) #s(literal 2 binary64))

              1. Initial program 94.5%

                \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
              2. Add Preprocessing
              3. Taylor expanded in c around inf

                \[\leadsto \color{blue}{2 \cdot c} \]
              4. Step-by-step derivation
                1. lower-*.f6416.4

                  \[\leadsto \color{blue}{2 \cdot c} \]
              5. Applied rewrites16.4%

                \[\leadsto \color{blue}{2 \cdot c} \]
              6. Step-by-step derivation
                1. Applied rewrites16.4%

                  \[\leadsto c + \color{blue}{c} \]
              7. Recombined 2 regimes into one program.
              8. Add Preprocessing

              Alternative 4: 16.3% accurate, 0.6× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \leq -0.005:\\ \;\;\;\;b + b\\ \mathbf{else}:\\ \;\;\;\;c + c\\ \end{array} \end{array} \]
              (FPCore (a b c d)
               :precision binary64
               (if (<= (* (+ a (+ b (+ c d))) 2.0) -0.005) (+ b b) (+ c c)))
              double code(double a, double b, double c, double d) {
              	double tmp;
              	if (((a + (b + (c + d))) * 2.0) <= -0.005) {
              		tmp = b + b;
              	} else {
              		tmp = c + c;
              	}
              	return tmp;
              }
              
              real(8) function code(a, b, c, d)
                  real(8), intent (in) :: a
                  real(8), intent (in) :: b
                  real(8), intent (in) :: c
                  real(8), intent (in) :: d
                  real(8) :: tmp
                  if (((a + (b + (c + d))) * 2.0d0) <= (-0.005d0)) then
                      tmp = b + b
                  else
                      tmp = c + c
                  end if
                  code = tmp
              end function
              
              public static double code(double a, double b, double c, double d) {
              	double tmp;
              	if (((a + (b + (c + d))) * 2.0) <= -0.005) {
              		tmp = b + b;
              	} else {
              		tmp = c + c;
              	}
              	return tmp;
              }
              
              def code(a, b, c, d):
              	tmp = 0
              	if ((a + (b + (c + d))) * 2.0) <= -0.005:
              		tmp = b + b
              	else:
              		tmp = c + c
              	return tmp
              
              function code(a, b, c, d)
              	tmp = 0.0
              	if (Float64(Float64(a + Float64(b + Float64(c + d))) * 2.0) <= -0.005)
              		tmp = Float64(b + b);
              	else
              		tmp = Float64(c + c);
              	end
              	return tmp
              end
              
              function tmp_2 = code(a, b, c, d)
              	tmp = 0.0;
              	if (((a + (b + (c + d))) * 2.0) <= -0.005)
              		tmp = b + b;
              	else
              		tmp = c + c;
              	end
              	tmp_2 = tmp;
              end
              
              code[a_, b_, c_, d_] := If[LessEqual[N[(N[(a + N[(b + N[(c + d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], -0.005], N[(b + b), $MachinePrecision], N[(c + c), $MachinePrecision]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \leq -0.005:\\
              \;\;\;\;b + b\\
              
              \mathbf{else}:\\
              \;\;\;\;c + c\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if (*.f64 (+.f64 a (+.f64 b (+.f64 c d))) #s(literal 2 binary64)) < -0.0050000000000000001

                1. Initial program 93.5%

                  \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
                2. Add Preprocessing
                3. Taylor expanded in b around inf

                  \[\leadsto \color{blue}{2 \cdot b} \]
                4. Step-by-step derivation
                  1. lower-*.f6416.0

                    \[\leadsto \color{blue}{2 \cdot b} \]
                5. Applied rewrites16.0%

                  \[\leadsto \color{blue}{2 \cdot b} \]
                6. Step-by-step derivation
                  1. Applied rewrites16.0%

                    \[\leadsto b + \color{blue}{b} \]

                  if -0.0050000000000000001 < (*.f64 (+.f64 a (+.f64 b (+.f64 c d))) #s(literal 2 binary64))

                  1. Initial program 94.5%

                    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
                  2. Add Preprocessing
                  3. Taylor expanded in c around inf

                    \[\leadsto \color{blue}{2 \cdot c} \]
                  4. Step-by-step derivation
                    1. lower-*.f6416.4

                      \[\leadsto \color{blue}{2 \cdot c} \]
                  5. Applied rewrites16.4%

                    \[\leadsto \color{blue}{2 \cdot c} \]
                  6. Step-by-step derivation
                    1. Applied rewrites16.4%

                      \[\leadsto c + \color{blue}{c} \]
                  7. Recombined 2 regimes into one program.
                  8. Add Preprocessing

                  Alternative 5: 94.3% accurate, 1.0× speedup?

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

                    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
                  2. Add Preprocessing
                  3. Add Preprocessing

                  Alternative 6: 6.2% accurate, 3.8× speedup?

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

                    \[\left(a + \left(b + \left(c + d\right)\right)\right) \cdot 2 \]
                  2. Add Preprocessing
                  3. Taylor expanded in b around inf

                    \[\leadsto \color{blue}{2 \cdot b} \]
                  4. Step-by-step derivation
                    1. lower-*.f646.0

                      \[\leadsto \color{blue}{2 \cdot b} \]
                  5. Applied rewrites6.0%

                    \[\leadsto \color{blue}{2 \cdot b} \]
                  6. Step-by-step derivation
                    1. Applied rewrites6.0%

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

                    Developer Target 1: 94.0% accurate, 0.8× speedup?

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

                    Reproduce

                    ?
                    herbie shell --seed 2024337 
                    (FPCore (a b c d)
                      :name "Expression, p6"
                      :precision binary64
                      :pre (and (and (and (and (<= -14.0 a) (<= a -13.0)) (and (<= -3.0 b) (<= b -2.0))) (and (<= 3.0 c) (<= c 3.5))) (and (<= 12.5 d) (<= d 13.5)))
                    
                      :alt
                      (! :herbie-platform default (let ((e 2)) (+ (* (+ a b) e) (* (+ c d) e))))
                    
                      (* (+ a (+ b (+ c d))) 2.0))