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

Percentage Accurate: 99.9% → 99.9%
Time: 6.1s
Alternatives: 7
Speedup: 1.0×

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.0× speedup?

\[\begin{array}{l} \\ y \cdot \left(z + x \cdot y\right) + t \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (* y (+ z (* x y))) t))
double code(double x, double y, double z, double t) {
	return (y * (z + (x * 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 = (y * (z + (x * y))) + t
end function
public static double code(double x, double y, double z, double t) {
	return (y * (z + (x * y))) + t;
}
def code(x, y, z, t):
	return (y * (z + (x * y))) + t
function code(x, y, z, t)
	return Float64(Float64(y * Float64(z + Float64(x * y))) + t)
end
function tmp = code(x, y, z, t)
	tmp = (y * (z + (x * y))) + t;
end
code[x_, y_, z_, t_] := N[(N[(y * N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
\begin{array}{l}

\\
y \cdot \left(z + x \cdot y\right) + t
\end{array}
Derivation
  1. Initial program 100.0%

    \[\left(x \cdot y + z\right) \cdot y + t \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto y \cdot \left(z + x \cdot y\right) + t \]
  4. Add Preprocessing

Alternative 2: 89.6% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0.005:\\
\;\;\;\;\mathsf{fma}\left(y, z, t\right)\\

\mathbf{elif}\;t\_1 \leq 4 \cdot 10^{+168}:\\
\;\;\;\;\mathsf{fma}\left(y, x \cdot y, t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (+.f64 (*.f64 x y) z) y) < -5.0000000000000001e172 or 3.9999999999999997e168 < (*.f64 (+.f64 (*.f64 x y) z) y)

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{{y}^{2} \cdot \left(x + \frac{z}{y}\right)} \]
    4. Applied rewrites95.7%

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

    if -5.0000000000000001e172 < (*.f64 (+.f64 (*.f64 x y) z) y) < 0.0050000000000000001

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in x 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. lower-fma.f6495.7

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

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

    if 0.0050000000000000001 < (*.f64 (+.f64 (*.f64 x y) z) y) < 3.9999999999999997e168

    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. unpow2N/A

        \[\leadsto x \cdot \color{blue}{\left(y \cdot y\right)} + t \]
      3. associate-*r*N/A

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y \cdot x, t\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z + x \cdot y\right) \leq -5 \cdot 10^{+172}:\\ \;\;\;\;y \cdot \mathsf{fma}\left(y, x, z\right)\\ \mathbf{elif}\;y \cdot \left(z + x \cdot y\right) \leq 0.005:\\ \;\;\;\;\mathsf{fma}\left(y, z, t\right)\\ \mathbf{elif}\;y \cdot \left(z + x \cdot y\right) \leq 4 \cdot 10^{+168}:\\ \;\;\;\;\mathsf{fma}\left(y, x \cdot y, t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \mathsf{fma}\left(y, x, z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.2% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(y, z, 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) < -5.0000000000000001e172 or 5.0000000000000002e-23 < (*.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 y around inf

      \[\leadsto \color{blue}{{y}^{2} \cdot \left(x + \frac{z}{y}\right)} \]
    4. Applied rewrites90.0%

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

    if -5.0000000000000001e172 < (*.f64 (+.f64 (*.f64 x y) z) y) < 5.0000000000000002e-23

    1. Initial program 100.0%

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in x 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. lower-fma.f6495.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z + x \cdot y\right) \leq -5 \cdot 10^{+172}:\\ \;\;\;\;y \cdot \mathsf{fma}\left(y, x, z\right)\\ \mathbf{elif}\;y \cdot \left(z + x \cdot y\right) \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\mathsf{fma}\left(y, z, t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \mathsf{fma}\left(y, x, z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.0% accurate, 0.3× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot y\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (+.f64 (*.f64 x y) z) y) < -inf.0

    1. Initial program 100.0%

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

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

        \[\leadsto x \cdot \color{blue}{\left(y \cdot y\right)} \]
      2. associate-*r*N/A

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(y \cdot x\right)} \]
      6. lower-*.f6489.7

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

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

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

      if -inf.0 < (*.f64 (+.f64 (*.f64 x y) z) y) < 2.0000000000000001e289

      1. Initial program 99.9%

        \[\left(x \cdot y + z\right) \cdot y + t \]
      2. Add Preprocessing
      3. Taylor expanded in x 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. lower-fma.f6484.0

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

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

      if 2.0000000000000001e289 < (*.f64 (+.f64 (*.f64 x y) z) y)

      1. Initial program 100.0%

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

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

          \[\leadsto x \cdot \color{blue}{\left(y \cdot y\right)} \]
        2. associate-*r*N/A

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z + x \cdot y\right) \leq -\infty:\\ \;\;\;\;x \cdot \left(y \cdot y\right)\\ \mathbf{elif}\;y \cdot \left(z + x \cdot y\right) \leq 2 \cdot 10^{+289}:\\ \;\;\;\;\mathsf{fma}\left(y, z, t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \end{array} \]
    9. Add Preprocessing

    Alternative 5: 80.6% accurate, 0.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(z + x \cdot y\right)\\ t_2 := y \cdot \left(x \cdot y\right)\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+289}:\\ \;\;\;\;\mathsf{fma}\left(y, z, t\right)\\ \mathbf{else}:\\ \;\;\;\;t\_2\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (* y (+ z (* x y)))) (t_2 (* y (* x y))))
       (if (<= t_1 (- INFINITY)) t_2 (if (<= t_1 2e+289) (fma y z t) t_2))))
    double code(double x, double y, double z, double t) {
    	double t_1 = y * (z + (x * y));
    	double t_2 = y * (x * y);
    	double tmp;
    	if (t_1 <= -((double) INFINITY)) {
    		tmp = t_2;
    	} else if (t_1 <= 2e+289) {
    		tmp = fma(y, z, t);
    	} else {
    		tmp = t_2;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = Float64(y * Float64(z + Float64(x * y)))
    	t_2 = Float64(y * Float64(x * y))
    	tmp = 0.0
    	if (t_1 <= Float64(-Inf))
    		tmp = t_2;
    	elseif (t_1 <= 2e+289)
    		tmp = fma(y, z, t);
    	else
    		tmp = t_2;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(z + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, 2e+289], N[(y * z + t), $MachinePrecision], t$95$2]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := y \cdot \left(z + x \cdot y\right)\\
    t_2 := y \cdot \left(x \cdot y\right)\\
    \mathbf{if}\;t\_1 \leq -\infty:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+289}:\\
    \;\;\;\;\mathsf{fma}\left(y, z, 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) < -inf.0 or 2.0000000000000001e289 < (*.f64 (+.f64 (*.f64 x y) z) y)

      1. Initial program 100.0%

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

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

          \[\leadsto x \cdot \color{blue}{\left(y \cdot y\right)} \]
        2. associate-*r*N/A

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

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

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

          \[\leadsto y \cdot \color{blue}{\left(y \cdot x\right)} \]
        6. lower-*.f6482.2

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

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

      if -inf.0 < (*.f64 (+.f64 (*.f64 x y) z) y) < 2.0000000000000001e289

      1. Initial program 99.9%

        \[\left(x \cdot y + z\right) \cdot y + t \]
      2. Add Preprocessing
      3. Taylor expanded in x 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. lower-fma.f6484.0

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \left(z + x \cdot y\right) \leq -\infty:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{elif}\;y \cdot \left(z + x \cdot y\right) \leq 2 \cdot 10^{+289}:\\ \;\;\;\;\mathsf{fma}\left(y, z, t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \end{array} \]
    5. Add Preprocessing

    Alternative 6: 65.8% accurate, 2.4× speedup?

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

      \[\left(x \cdot y + z\right) \cdot y + t \]
    2. Add Preprocessing
    3. Taylor expanded in x 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. lower-fma.f6467.5

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

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

    Alternative 7: 29.1% accurate, 2.8× speedup?

    \[\begin{array}{l} \\ y \cdot z \end{array} \]
    (FPCore (x y z t) :precision binary64 (* y z))
    double code(double x, double y, double z, double t) {
    	return y * z;
    }
    
    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 = y * z
    end function
    
    public static double code(double x, double y, double z, double t) {
    	return y * z;
    }
    
    def code(x, y, z, t):
    	return y * z
    
    function code(x, y, z, t)
    	return Float64(y * z)
    end
    
    function tmp = code(x, y, z, t)
    	tmp = y * z;
    end
    
    code[x_, y_, z_, t_] := N[(y * z), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    y \cdot z
    \end{array}
    
    Derivation
    1. Initial program 100.0%

      \[\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. lower-*.f6432.4

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

      \[\leadsto \color{blue}{y \cdot z} \]
    6. Add Preprocessing

    Reproduce

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