Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23

Percentage Accurate: 99.9% → 99.9%
Time: 8.1s
Alternatives: 7
Speedup: 1.3×

Specification

?
\[\begin{array}{l} \\ \left(x \cdot y + z\right) \cdot y + t \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((x * y) + z) * y) + t
end function
public static double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
def code(x, y, z, t):
	return (((x * y) + z) * y) + t
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * y) + z) * y) + t)
end
function tmp = code(x, y, z, t)
	tmp = (((x * y) + z) * y) + t;
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot y + z\right) \cdot y + t
\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 7 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.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot y + z\right) \cdot y + t \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (* (+ (* x y) z) y) t))
double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (((x * y) + z) * y) + t
end function
public static double code(double x, double y, double z, double t) {
	return (((x * y) + z) * y) + t;
}
def code(x, y, z, t):
	return (((x * y) + z) * y) + t
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * y) + z) * y) + t)
end
function tmp = code(x, y, z, t)
	tmp = (((x * y) + z) * y) + t;
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot y + z\right) \cdot y + t
\end{array}

Alternative 1: 99.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(y, x, z\right), y, t\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (fma (fma y x z) y t))
double code(double x, double y, double z, double t) {
	return fma(fma(y, x, z), y, t);
}
function code(x, y, z, t)
	return fma(fma(y, x, z), y, t)
end
code[x_, y_, z_, t_] := N[(N[(y * x + z), $MachinePrecision] * y + t), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\mathsf{fma}\left(y, x, z\right), y, t\right)
\end{array}
Derivation
  1. Initial program 99.9%

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot y + z\right) \cdot y + t} \]
    2. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(x \cdot y + z\right) \cdot y} + t \]
    3. lower-fma.f6499.9

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot y + z, y, t\right)} \]
    4. lift-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot y + z}, y, t\right) \]
    5. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot y} + z, y, t\right) \]
    6. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot x} + z, y, t\right) \]
    7. lower-fma.f6499.9

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(y, x, z\right)}, y, t\right) \]
  4. Applied rewrites99.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(y, x, z\right), y, t\right)} \]
  5. Add Preprocessing

Alternative 2: 87.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(x \cdot y + z\right) \cdot y\\ t_2 := \mathsf{fma}\left(x, y, z\right) \cdot y\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+164}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-37}:\\ \;\;\;\;\mathsf{fma}\left(z, y, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (+ (* x y) z) y)) (t_2 (* (fma x y z) y)))
   (if (<= t_1 -5e+164) t_2 (if (<= t_1 2e-37) (fma z y t) t_2))))
double code(double x, double y, double z, double t) {
	double t_1 = ((x * y) + z) * y;
	double t_2 = fma(x, y, z) * y;
	double tmp;
	if (t_1 <= -5e+164) {
		tmp = t_2;
	} else if (t_1 <= 2e-37) {
		tmp = fma(z, y, t);
	} else {
		tmp = t_2;
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(Float64(x * y) + z) * y)
	t_2 = Float64(fma(x, y, z) * y)
	tmp = 0.0
	if (t_1 <= -5e+164)
		tmp = t_2;
	elseif (t_1 <= 2e-37)
		tmp = fma(z, y, t);
	else
		tmp = t_2;
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * y + z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+164], t$95$2, If[LessEqual[t$95$1, 2e-37], N[(z * y + t), $MachinePrecision], t$95$2]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(x \cdot y + z\right) \cdot y\\
t_2 := \mathsf{fma}\left(x, y, z\right) \cdot y\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+164}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-37}:\\
\;\;\;\;\mathsf{fma}\left(z, y, t\right)\\

\mathbf{else}:\\
\;\;\;\;t\_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (+.f64 (*.f64 x y) z) y) < -4.9999999999999995e164 or 2.00000000000000013e-37 < (*.f64 (+.f64 (*.f64 x y) z) y)

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in t around 0

      \[\leadsto \color{blue}{y \cdot \left(z + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{\left(z + x \cdot y\right) \cdot y} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(z + x \cdot y\right) \cdot y} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot y + z\right)} \cdot y \]
      4. lower-fma.f6492.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z\right)} \cdot y \]
    5. Applied rewrites92.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z\right) \cdot y} \]

    if -4.9999999999999995e164 < (*.f64 (+.f64 (*.f64 x y) z) y) < 2.00000000000000013e-37

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0

      \[\leadsto \color{blue}{t + y \cdot z} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{y \cdot z + t} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{z \cdot y} + t \]
      3. lower-fma.f6491.6

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
    5. Applied rewrites91.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 52.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(x \cdot y + z\right) \cdot y\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+130}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+37}:\\ \;\;\;\;1 \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (+ (* x y) z) y)))
   (if (<= t_1 -1e+130) (* z y) (if (<= t_1 5e+37) (* 1.0 t) (* z y)))))
double code(double x, double y, double z, double t) {
	double t_1 = ((x * y) + z) * y;
	double tmp;
	if (t_1 <= -1e+130) {
		tmp = z * y;
	} else if (t_1 <= 5e+37) {
		tmp = 1.0 * t;
	} else {
		tmp = z * y;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = ((x * y) + z) * y
    if (t_1 <= (-1d+130)) then
        tmp = z * y
    else if (t_1 <= 5d+37) then
        tmp = 1.0d0 * t
    else
        tmp = z * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = ((x * y) + z) * y;
	double tmp;
	if (t_1 <= -1e+130) {
		tmp = z * y;
	} else if (t_1 <= 5e+37) {
		tmp = 1.0 * t;
	} else {
		tmp = z * y;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = ((x * y) + z) * y
	tmp = 0
	if t_1 <= -1e+130:
		tmp = z * y
	elif t_1 <= 5e+37:
		tmp = 1.0 * t
	else:
		tmp = z * y
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(Float64(x * y) + z) * y)
	tmp = 0.0
	if (t_1 <= -1e+130)
		tmp = Float64(z * y);
	elseif (t_1 <= 5e+37)
		tmp = Float64(1.0 * t);
	else
		tmp = Float64(z * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = ((x * y) + z) * y;
	tmp = 0.0;
	if (t_1 <= -1e+130)
		tmp = z * y;
	elseif (t_1 <= 5e+37)
		tmp = 1.0 * t;
	else
		tmp = z * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x * y), $MachinePrecision] + z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+130], N[(z * y), $MachinePrecision], If[LessEqual[t$95$1, 5e+37], N[(1.0 * t), $MachinePrecision], N[(z * y), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \left(x \cdot y + z\right) \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+130}:\\
\;\;\;\;z \cdot y\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+37}:\\
\;\;\;\;1 \cdot t\\

\mathbf{else}:\\
\;\;\;\;z \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (+.f64 (*.f64 x y) z) y) < -1.0000000000000001e130 or 4.99999999999999989e37 < (*.f64 (+.f64 (*.f64 x y) z) y)

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf

      \[\leadsto \color{blue}{y \cdot z} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{z \cdot y} \]
      2. lower-*.f6439.5

        \[\leadsto \color{blue}{z \cdot y} \]
    5. Applied rewrites39.5%

      \[\leadsto \color{blue}{z \cdot y} \]

    if -1.0000000000000001e130 < (*.f64 (+.f64 (*.f64 x y) z) y) < 4.99999999999999989e37

    1. Initial program 99.9%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0

      \[\leadsto \color{blue}{t + x \cdot {y}^{2}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{x \cdot {y}^{2} + t} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{{y}^{2} \cdot x} + t \]
      3. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left({y}^{2}, x, t\right)} \]
      4. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot y}, x, t\right) \]
      5. lower-*.f6485.8

        \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot y}, x, t\right) \]
    5. Applied rewrites85.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot y, x, t\right)} \]
    6. Taylor expanded in t around inf

      \[\leadsto t \cdot \color{blue}{\left(1 + \frac{x \cdot {y}^{2}}{t}\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites84.9%

        \[\leadsto \mathsf{fma}\left(x, \frac{y \cdot y}{t}, 1\right) \cdot \color{blue}{t} \]
      2. Taylor expanded in t around inf

        \[\leadsto 1 \cdot t \]
      3. Step-by-step derivation
        1. Applied rewrites76.9%

          \[\leadsto 1 \cdot t \]
      4. Recombined 2 regimes into one program.
      5. Add Preprocessing

      Alternative 4: 78.8% accurate, 0.7× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{+38}:\\ \;\;\;\;\left(y \cdot y\right) \cdot x\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+30}:\\ \;\;\;\;\mathsf{fma}\left(z, y, t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot y\right) \cdot y\\ \end{array} \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (if (<= y -1.85e+38)
         (* (* y y) x)
         (if (<= y 8e+30) (fma z y t) (* (* x y) y))))
      double code(double x, double y, double z, double t) {
      	double tmp;
      	if (y <= -1.85e+38) {
      		tmp = (y * y) * x;
      	} else if (y <= 8e+30) {
      		tmp = fma(z, y, t);
      	} else {
      		tmp = (x * y) * y;
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	tmp = 0.0
      	if (y <= -1.85e+38)
      		tmp = Float64(Float64(y * y) * x);
      	elseif (y <= 8e+30)
      		tmp = fma(z, y, t);
      	else
      		tmp = Float64(Float64(x * y) * y);
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := If[LessEqual[y, -1.85e+38], N[(N[(y * y), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[y, 8e+30], N[(z * y + t), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -1.85 \cdot 10^{+38}:\\
      \;\;\;\;\left(y \cdot y\right) \cdot x\\
      
      \mathbf{elif}\;y \leq 8 \cdot 10^{+30}:\\
      \;\;\;\;\mathsf{fma}\left(z, y, t\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(x \cdot y\right) \cdot y\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -1.8500000000000001e38

        1. Initial program 99.9%

          \[\left(x \cdot y + z\right) \cdot y + t \]
        2. Add Preprocessing
        3. Taylor expanded in y around inf

          \[\leadsto \color{blue}{x \cdot {y}^{2}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
          3. unpow2N/A

            \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x \]
          4. lower-*.f6474.0

            \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x \]
        5. Applied rewrites74.0%

          \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot x} \]

        if -1.8500000000000001e38 < y < 8.0000000000000002e30

        1. Initial program 100.0%

          \[\left(x \cdot y + z\right) \cdot y + t \]
        2. Add Preprocessing
        3. Taylor expanded in y around 0

          \[\leadsto \color{blue}{t + y \cdot z} \]
        4. Step-by-step derivation
          1. +-commutativeN/A

            \[\leadsto \color{blue}{y \cdot z + t} \]
          2. *-commutativeN/A

            \[\leadsto \color{blue}{z \cdot y} + t \]
          3. lower-fma.f6487.8

            \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
        5. Applied rewrites87.8%

          \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]

        if 8.0000000000000002e30 < y

        1. Initial program 99.9%

          \[\left(x \cdot y + z\right) \cdot y + t \]
        2. Add Preprocessing
        3. Taylor expanded in y around inf

          \[\leadsto \color{blue}{x \cdot {y}^{2}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
          3. unpow2N/A

            \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x \]
          4. lower-*.f6483.5

            \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x \]
        5. Applied rewrites83.5%

          \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot x} \]
        6. Step-by-step derivation
          1. Applied rewrites85.1%

            \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{y} \]
        7. Recombined 3 regimes into one program.
        8. Add Preprocessing

        Alternative 5: 79.5% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(x \cdot y\right) \cdot y\\ \mathbf{if}\;y \leq -1.85 \cdot 10^{+38}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+30}:\\ \;\;\;\;\mathsf{fma}\left(z, y, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (let* ((t_1 (* (* x y) y)))
           (if (<= y -1.85e+38) t_1 (if (<= y 8e+30) (fma z y t) t_1))))
        double code(double x, double y, double z, double t) {
        	double t_1 = (x * y) * y;
        	double tmp;
        	if (y <= -1.85e+38) {
        		tmp = t_1;
        	} else if (y <= 8e+30) {
        		tmp = fma(z, y, t);
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        function code(x, y, z, t)
        	t_1 = Float64(Float64(x * y) * y)
        	tmp = 0.0
        	if (y <= -1.85e+38)
        		tmp = t_1;
        	elseif (y <= 8e+30)
        		tmp = fma(z, y, t);
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -1.85e+38], t$95$1, If[LessEqual[y, 8e+30], N[(z * y + t), $MachinePrecision], t$95$1]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_1 := \left(x \cdot y\right) \cdot y\\
        \mathbf{if}\;y \leq -1.85 \cdot 10^{+38}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;y \leq 8 \cdot 10^{+30}:\\
        \;\;\;\;\mathsf{fma}\left(z, y, t\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -1.8500000000000001e38 or 8.0000000000000002e30 < y

          1. Initial program 99.9%

            \[\left(x \cdot y + z\right) \cdot y + t \]
          2. Add Preprocessing
          3. Taylor expanded in y around inf

            \[\leadsto \color{blue}{x \cdot {y}^{2}} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
            2. lower-*.f64N/A

              \[\leadsto \color{blue}{{y}^{2} \cdot x} \]
            3. unpow2N/A

              \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x \]
            4. lower-*.f6479.0

              \[\leadsto \color{blue}{\left(y \cdot y\right)} \cdot x \]
          5. Applied rewrites79.0%

            \[\leadsto \color{blue}{\left(y \cdot y\right) \cdot x} \]
          6. Step-by-step derivation
            1. Applied rewrites77.3%

              \[\leadsto \left(x \cdot y\right) \cdot \color{blue}{y} \]

            if -1.8500000000000001e38 < y < 8.0000000000000002e30

            1. Initial program 100.0%

              \[\left(x \cdot y + z\right) \cdot y + t \]
            2. Add Preprocessing
            3. Taylor expanded in y around 0

              \[\leadsto \color{blue}{t + y \cdot z} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \color{blue}{y \cdot z + t} \]
              2. *-commutativeN/A

                \[\leadsto \color{blue}{z \cdot y} + t \]
              3. lower-fma.f6487.8

                \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
            5. Applied rewrites87.8%

              \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
          7. Recombined 2 regimes into one program.
          8. Add Preprocessing

          Alternative 6: 65.8% accurate, 2.4× speedup?

          \[\begin{array}{l} \\ \mathsf{fma}\left(z, y, t\right) \end{array} \]
          (FPCore (x y z t) :precision binary64 (fma z y t))
          double code(double x, double y, double z, double t) {
          	return fma(z, y, t);
          }
          
          function code(x, y, z, t)
          	return fma(z, y, t)
          end
          
          code[x_, y_, z_, t_] := N[(z * y + t), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \mathsf{fma}\left(z, y, t\right)
          \end{array}
          
          Derivation
          1. Initial program 99.9%

            \[\left(x \cdot y + z\right) \cdot y + t \]
          2. Add Preprocessing
          3. Taylor expanded in y around 0

            \[\leadsto \color{blue}{t + y \cdot z} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{y \cdot z + t} \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{z \cdot y} + t \]
            3. lower-fma.f6465.6

              \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
          5. Applied rewrites65.6%

            \[\leadsto \color{blue}{\mathsf{fma}\left(z, y, t\right)} \]
          6. Add Preprocessing

          Alternative 7: 39.0% accurate, 2.8× speedup?

          \[\begin{array}{l} \\ 1 \cdot t \end{array} \]
          (FPCore (x y z t) :precision binary64 (* 1.0 t))
          double code(double x, double y, double z, double t) {
          	return 1.0 * t;
          }
          
          real(8) function code(x, y, z, t)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8), intent (in) :: t
              code = 1.0d0 * t
          end function
          
          public static double code(double x, double y, double z, double t) {
          	return 1.0 * t;
          }
          
          def code(x, y, z, t):
          	return 1.0 * t
          
          function code(x, y, z, t)
          	return Float64(1.0 * t)
          end
          
          function tmp = code(x, y, z, t)
          	tmp = 1.0 * t;
          end
          
          code[x_, y_, z_, t_] := N[(1.0 * t), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          1 \cdot t
          \end{array}
          
          Derivation
          1. Initial program 99.9%

            \[\left(x \cdot y + z\right) \cdot y + t \]
          2. Add Preprocessing
          3. Taylor expanded in z around 0

            \[\leadsto \color{blue}{t + x \cdot {y}^{2}} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{x \cdot {y}^{2} + t} \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{{y}^{2} \cdot x} + t \]
            3. lower-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left({y}^{2}, x, t\right)} \]
            4. unpow2N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot y}, x, t\right) \]
            5. lower-*.f6479.0

              \[\leadsto \mathsf{fma}\left(\color{blue}{y \cdot y}, x, t\right) \]
          5. Applied rewrites79.0%

            \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot y, x, t\right)} \]
          6. Taylor expanded in t around inf

            \[\leadsto t \cdot \color{blue}{\left(1 + \frac{x \cdot {y}^{2}}{t}\right)} \]
          7. Step-by-step derivation
            1. Applied rewrites76.8%

              \[\leadsto \mathsf{fma}\left(x, \frac{y \cdot y}{t}, 1\right) \cdot \color{blue}{t} \]
            2. Taylor expanded in t around inf

              \[\leadsto 1 \cdot t \]
            3. Step-by-step derivation
              1. Applied rewrites40.0%

                \[\leadsto 1 \cdot t \]
              2. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2024243 
              (FPCore (x y z t)
                :name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
                :precision binary64
                (+ (* (+ (* x y) z) y) t))