Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C

Percentage Accurate: 99.9% → 100.0%
Time: 6.3s
Alternatives: 10
Speedup: 1.1×

Specification

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

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

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

Alternative 1: 100.0% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{\left(z + y\right)} \cdot x\right) \]
    10. lower-+.f64100.0

      \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{\left(z + y\right)} \cdot x\right) \]
  4. Applied rewrites100.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, 5, \left(z + y\right) \cdot x\right)} \]
  5. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right) \]
  6. Add Preprocessing

Alternative 2: 61.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-15}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-25}:\\ \;\;\;\;5 \cdot z\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+112}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -6e-15)
   (* x y)
   (if (<= x 7.2e-25) (* 5.0 z) (if (<= x 4e+112) (* x y) (* x z)))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -6e-15) {
		tmp = x * y;
	} else if (x <= 7.2e-25) {
		tmp = 5.0 * z;
	} else if (x <= 4e+112) {
		tmp = x * y;
	} else {
		tmp = x * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (x <= (-6d-15)) then
        tmp = x * y
    else if (x <= 7.2d-25) then
        tmp = 5.0d0 * z
    else if (x <= 4d+112) then
        tmp = x * y
    else
        tmp = x * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -6e-15) {
		tmp = x * y;
	} else if (x <= 7.2e-25) {
		tmp = 5.0 * z;
	} else if (x <= 4e+112) {
		tmp = x * y;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -6e-15:
		tmp = x * y
	elif x <= 7.2e-25:
		tmp = 5.0 * z
	elif x <= 4e+112:
		tmp = x * y
	else:
		tmp = x * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -6e-15)
		tmp = Float64(x * y);
	elseif (x <= 7.2e-25)
		tmp = Float64(5.0 * z);
	elseif (x <= 4e+112)
		tmp = Float64(x * y);
	else
		tmp = Float64(x * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -6e-15)
		tmp = x * y;
	elseif (x <= 7.2e-25)
		tmp = 5.0 * z;
	elseif (x <= 4e+112)
		tmp = x * y;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -6e-15], N[(x * y), $MachinePrecision], If[LessEqual[x, 7.2e-25], N[(5.0 * z), $MachinePrecision], If[LessEqual[x, 4e+112], N[(x * y), $MachinePrecision], N[(x * z), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -6 \cdot 10^{-15}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq 7.2 \cdot 10^{-25}:\\
\;\;\;\;5 \cdot z\\

\mathbf{elif}\;x \leq 4 \cdot 10^{+112}:\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6e-15 or 7.1999999999999998e-25 < x < 3.9999999999999997e112

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{y \cdot x} \]
      2. lower-*.f6463.9

        \[\leadsto \color{blue}{y \cdot x} \]
    5. Applied rewrites63.9%

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

    if -6e-15 < x < 7.1999999999999998e-25

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{5 \cdot z} \]
    4. Step-by-step derivation
      1. lower-*.f6470.4

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

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

    if 3.9999999999999997e112 < x

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(z + y\right) \cdot x} \]
    6. Taylor expanded in z around inf

      \[\leadsto x \cdot \color{blue}{z} \]
    7. Step-by-step derivation
      1. Applied rewrites69.5%

        \[\leadsto z \cdot \color{blue}{x} \]
    8. Recombined 3 regimes into one program.
    9. Final simplification67.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-15}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-25}:\\ \;\;\;\;5 \cdot z\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+112}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
    10. Add Preprocessing

    Alternative 3: 98.3% accurate, 0.7× speedup?

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

      if -5 < x < 5

      1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{\left(z + y\right)} \cdot x\right) \]
        10. lower-+.f64100.0

          \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{\left(z + y\right)} \cdot x\right) \]
      4. Applied rewrites100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, 5, \left(z + y\right) \cdot x\right)} \]
      5. Taylor expanded in z around 0

        \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{x \cdot y}\right) \]
      6. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(z, 5, \color{blue}{y \cdot x}\right) \]
        2. lower-*.f6499.3

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

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

      if 5 < x

      1. Initial program 99.9%

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

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

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

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

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

          \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
      5. Applied rewrites99.4%

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

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

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

      Alternative 4: 98.3% accurate, 0.7× speedup?

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

        1. Initial program 100.0%

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

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

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

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

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

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

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

        if -5 < x < 5

        1. Initial program 99.9%

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

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

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

            \[\leadsto x \cdot \color{blue}{\left(y + z\right)} + z \cdot 5 \]
          4. distribute-rgt-inN/A

            \[\leadsto \color{blue}{\left(y \cdot x + z \cdot x\right)} + z \cdot 5 \]
          5. associate-+l+N/A

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

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

            \[\leadsto \mathsf{fma}\left(y, x, z \cdot x + \color{blue}{z \cdot 5}\right) \]
          8. distribute-lft-outN/A

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, z \cdot \left(x + 5\right)\right)} \]
        5. Taylor expanded in x around 0

          \[\leadsto \mathsf{fma}\left(y, x, z \cdot \color{blue}{5}\right) \]
        6. Step-by-step derivation
          1. Applied rewrites99.3%

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

          if 5 < x

          1. Initial program 99.9%

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

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

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

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

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

              \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
          5. Applied rewrites99.4%

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

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

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

          Alternative 5: 78.8% accurate, 0.8× speedup?

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

            1. Initial program 99.9%

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

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

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

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

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

                \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
            5. Applied rewrites80.9%

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

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

              if -3.69999999999999998e-40 < y < 9.5e18

              1. Initial program 100.0%

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

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

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

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

                  \[\leadsto \color{blue}{\left(x + 5\right)} \cdot z \]
                4. metadata-evalN/A

                  \[\leadsto \left(x + \color{blue}{\left(\mathsf{neg}\left(-5\right)\right)}\right) \cdot z \]
                5. sub-negN/A

                  \[\leadsto \color{blue}{\left(x - -5\right)} \cdot z \]
                6. lower--.f6487.2

                  \[\leadsto \color{blue}{\left(x - -5\right)} \cdot z \]
              5. Applied rewrites87.2%

                \[\leadsto \color{blue}{\left(x - -5\right) \cdot z} \]

              if 9.5e18 < y

              1. Initial program 99.9%

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
              5. Applied rewrites88.1%

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

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

            Alternative 6: 79.3% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y + z\right)\\ \mathbf{if}\;y \leq -3.7 \cdot 10^{-40}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+18}:\\ \;\;\;\;\left(x - -5\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (let* ((t_0 (* x (+ y z))))
               (if (<= y -3.7e-40) t_0 (if (<= y 9.5e+18) (* (- x -5.0) z) t_0))))
            double code(double x, double y, double z) {
            	double t_0 = x * (y + z);
            	double tmp;
            	if (y <= -3.7e-40) {
            		tmp = t_0;
            	} else if (y <= 9.5e+18) {
            		tmp = (x - -5.0) * z;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            real(8) function code(x, y, z)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: t_0
                real(8) :: tmp
                t_0 = x * (y + z)
                if (y <= (-3.7d-40)) then
                    tmp = t_0
                else if (y <= 9.5d+18) then
                    tmp = (x - (-5.0d0)) * z
                else
                    tmp = t_0
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double t_0 = x * (y + z);
            	double tmp;
            	if (y <= -3.7e-40) {
            		tmp = t_0;
            	} else if (y <= 9.5e+18) {
            		tmp = (x - -5.0) * z;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	t_0 = x * (y + z)
            	tmp = 0
            	if y <= -3.7e-40:
            		tmp = t_0
            	elif y <= 9.5e+18:
            		tmp = (x - -5.0) * z
            	else:
            		tmp = t_0
            	return tmp
            
            function code(x, y, z)
            	t_0 = Float64(x * Float64(y + z))
            	tmp = 0.0
            	if (y <= -3.7e-40)
            		tmp = t_0;
            	elseif (y <= 9.5e+18)
            		tmp = Float64(Float64(x - -5.0) * z);
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	t_0 = x * (y + z);
            	tmp = 0.0;
            	if (y <= -3.7e-40)
            		tmp = t_0;
            	elseif (y <= 9.5e+18)
            		tmp = (x - -5.0) * z;
            	else
            		tmp = t_0;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.7e-40], t$95$0, If[LessEqual[y, 9.5e+18], N[(N[(x - -5.0), $MachinePrecision] * z), $MachinePrecision], t$95$0]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := x \cdot \left(y + z\right)\\
            \mathbf{if}\;y \leq -3.7 \cdot 10^{-40}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;y \leq 9.5 \cdot 10^{+18}:\\
            \;\;\;\;\left(x - -5\right) \cdot z\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if y < -3.69999999999999998e-40 or 9.5e18 < y

              1. Initial program 99.9%

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

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

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

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

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

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

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

              if -3.69999999999999998e-40 < y < 9.5e18

              1. Initial program 100.0%

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

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

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

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

                  \[\leadsto \color{blue}{\left(x + 5\right)} \cdot z \]
                4. metadata-evalN/A

                  \[\leadsto \left(x + \color{blue}{\left(\mathsf{neg}\left(-5\right)\right)}\right) \cdot z \]
                5. sub-negN/A

                  \[\leadsto \color{blue}{\left(x - -5\right)} \cdot z \]
                6. lower--.f6487.2

                  \[\leadsto \color{blue}{\left(x - -5\right)} \cdot z \]
              5. Applied rewrites87.2%

                \[\leadsto \color{blue}{\left(x - -5\right) \cdot z} \]
            3. Recombined 2 regimes into one program.
            4. Final simplification85.9%

              \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-40}:\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+18}:\\ \;\;\;\;\left(x - -5\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + z\right)\\ \end{array} \]
            5. Add Preprocessing

            Alternative 7: 84.5% accurate, 0.8× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y + z\right)\\ \mathbf{if}\;x \leq -6 \cdot 10^{-15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-25}:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (let* ((t_0 (* x (+ y z))))
               (if (<= x -6e-15) t_0 (if (<= x 7.2e-25) (* 5.0 z) t_0))))
            double code(double x, double y, double z) {
            	double t_0 = x * (y + z);
            	double tmp;
            	if (x <= -6e-15) {
            		tmp = t_0;
            	} else if (x <= 7.2e-25) {
            		tmp = 5.0 * z;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            real(8) function code(x, y, z)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: t_0
                real(8) :: tmp
                t_0 = x * (y + z)
                if (x <= (-6d-15)) then
                    tmp = t_0
                else if (x <= 7.2d-25) then
                    tmp = 5.0d0 * z
                else
                    tmp = t_0
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double t_0 = x * (y + z);
            	double tmp;
            	if (x <= -6e-15) {
            		tmp = t_0;
            	} else if (x <= 7.2e-25) {
            		tmp = 5.0 * z;
            	} else {
            		tmp = t_0;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	t_0 = x * (y + z)
            	tmp = 0
            	if x <= -6e-15:
            		tmp = t_0
            	elif x <= 7.2e-25:
            		tmp = 5.0 * z
            	else:
            		tmp = t_0
            	return tmp
            
            function code(x, y, z)
            	t_0 = Float64(x * Float64(y + z))
            	tmp = 0.0
            	if (x <= -6e-15)
            		tmp = t_0;
            	elseif (x <= 7.2e-25)
            		tmp = Float64(5.0 * z);
            	else
            		tmp = t_0;
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	t_0 = x * (y + z);
            	tmp = 0.0;
            	if (x <= -6e-15)
            		tmp = t_0;
            	elseif (x <= 7.2e-25)
            		tmp = 5.0 * z;
            	else
            		tmp = t_0;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6e-15], t$95$0, If[LessEqual[x, 7.2e-25], N[(5.0 * z), $MachinePrecision], t$95$0]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_0 := x \cdot \left(y + z\right)\\
            \mathbf{if}\;x \leq -6 \cdot 10^{-15}:\\
            \;\;\;\;t\_0\\
            
            \mathbf{elif}\;x \leq 7.2 \cdot 10^{-25}:\\
            \;\;\;\;5 \cdot z\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_0\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -6e-15 or 7.1999999999999998e-25 < x

              1. Initial program 100.0%

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

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

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

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

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

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

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

              if -6e-15 < x < 7.1999999999999998e-25

              1. Initial program 99.9%

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

                \[\leadsto \color{blue}{5 \cdot z} \]
              4. Step-by-step derivation
                1. lower-*.f6470.4

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

                \[\leadsto \color{blue}{5 \cdot z} \]
            3. Recombined 2 regimes into one program.
            4. Final simplification85.1%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-15}:\\ \;\;\;\;x \cdot \left(y + z\right)\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-25}:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + z\right)\\ \end{array} \]
            5. Add Preprocessing

            Alternative 8: 60.9% accurate, 0.9× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -0.00166:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq 5:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= x -0.00166) (* x z) (if (<= x 5.0) (* 5.0 z) (* x z))))
            double code(double x, double y, double z) {
            	double tmp;
            	if (x <= -0.00166) {
            		tmp = x * z;
            	} else if (x <= 5.0) {
            		tmp = 5.0 * z;
            	} else {
            		tmp = x * z;
            	}
            	return tmp;
            }
            
            real(8) function code(x, y, z)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: tmp
                if (x <= (-0.00166d0)) then
                    tmp = x * z
                else if (x <= 5.0d0) then
                    tmp = 5.0d0 * z
                else
                    tmp = x * z
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z) {
            	double tmp;
            	if (x <= -0.00166) {
            		tmp = x * z;
            	} else if (x <= 5.0) {
            		tmp = 5.0 * z;
            	} else {
            		tmp = x * z;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if x <= -0.00166:
            		tmp = x * z
            	elif x <= 5.0:
            		tmp = 5.0 * z
            	else:
            		tmp = x * z
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if (x <= -0.00166)
            		tmp = Float64(x * z);
            	elseif (x <= 5.0)
            		tmp = Float64(5.0 * z);
            	else
            		tmp = Float64(x * z);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z)
            	tmp = 0.0;
            	if (x <= -0.00166)
            		tmp = x * z;
            	elseif (x <= 5.0)
            		tmp = 5.0 * z;
            	else
            		tmp = x * z;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[LessEqual[x, -0.00166], N[(x * z), $MachinePrecision], If[LessEqual[x, 5.0], N[(5.0 * z), $MachinePrecision], N[(x * z), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -0.00166:\\
            \;\;\;\;x \cdot z\\
            
            \mathbf{elif}\;x \leq 5:\\
            \;\;\;\;5 \cdot z\\
            
            \mathbf{else}:\\
            \;\;\;\;x \cdot z\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -0.00166 or 5 < x

              1. Initial program 100.0%

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

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

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

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

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

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

                \[\leadsto \color{blue}{\left(z + y\right) \cdot x} \]
              6. Taylor expanded in z around inf

                \[\leadsto x \cdot \color{blue}{z} \]
              7. Step-by-step derivation
                1. Applied rewrites52.6%

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

                if -0.00166 < x < 5

                1. Initial program 99.9%

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

                  \[\leadsto \color{blue}{5 \cdot z} \]
                4. Step-by-step derivation
                  1. lower-*.f6467.3

                    \[\leadsto \color{blue}{5 \cdot z} \]
                5. Applied rewrites67.3%

                  \[\leadsto \color{blue}{5 \cdot z} \]
              8. Recombined 2 regimes into one program.
              9. Final simplification59.8%

                \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -0.00166:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;x \leq 5:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
              10. Add Preprocessing

              Alternative 9: 98.8% accurate, 1.1× speedup?

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

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

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

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

                  \[\leadsto x \cdot \color{blue}{\left(y + z\right)} + z \cdot 5 \]
                4. distribute-rgt-inN/A

                  \[\leadsto \color{blue}{\left(y \cdot x + z \cdot x\right)} + z \cdot 5 \]
                5. associate-+l+N/A

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

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

                  \[\leadsto \mathsf{fma}\left(y, x, z \cdot x + \color{blue}{z \cdot 5}\right) \]
                8. distribute-lft-outN/A

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

                  \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{z \cdot \left(x + 5\right)}\right) \]
                10. lower-+.f6498.4

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, z \cdot \left(x + 5\right)\right)} \]
              5. Final simplification98.4%

                \[\leadsto \mathsf{fma}\left(y, x, \left(x + 5\right) \cdot z\right) \]
              6. Add Preprocessing

              Alternative 10: 28.0% accurate, 2.8× speedup?

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\left(z + y\right)} \cdot x \]
              5. Applied rewrites67.8%

                \[\leadsto \color{blue}{\left(z + y\right) \cdot x} \]
              6. Taylor expanded in z around inf

                \[\leadsto x \cdot \color{blue}{z} \]
              7. Step-by-step derivation
                1. Applied rewrites28.6%

                  \[\leadsto z \cdot \color{blue}{x} \]
                2. Final simplification28.6%

                  \[\leadsto x \cdot z \]
                3. Add Preprocessing

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

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

                Reproduce

                ?
                herbie shell --seed 2024235 
                (FPCore (x y z)
                  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
                  :precision binary64
                
                  :alt
                  (! :herbie-platform default (+ (* (+ x 5) z) (* x y)))
                
                  (+ (* x (+ y z)) (* z 5.0)))