Main:bigenough2 from A

Percentage Accurate: 100.0% → 100.0%
Time: 5.3s
Alternatives: 7
Speedup: 1.2×

Specification

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

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

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

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

Alternative 1: 100.0% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

Alternative 2: 61.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+210}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-28}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{-43}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+87}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.8e+210)
   (* x y)
   (if (<= y -1.4e-28)
     (* z y)
     (if (<= y 3.4e-43) x (if (<= y 1.05e+87) (* z y) (* x y))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.8e+210) {
		tmp = x * y;
	} else if (y <= -1.4e-28) {
		tmp = z * y;
	} else if (y <= 3.4e-43) {
		tmp = x;
	} else if (y <= 1.05e+87) {
		tmp = z * y;
	} else {
		tmp = x * y;
	}
	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 (y <= (-1.8d+210)) then
        tmp = x * y
    else if (y <= (-1.4d-28)) then
        tmp = z * y
    else if (y <= 3.4d-43) then
        tmp = x
    else if (y <= 1.05d+87) then
        tmp = z * y
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.8e+210) {
		tmp = x * y;
	} else if (y <= -1.4e-28) {
		tmp = z * y;
	} else if (y <= 3.4e-43) {
		tmp = x;
	} else if (y <= 1.05e+87) {
		tmp = z * y;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.8e+210:
		tmp = x * y
	elif y <= -1.4e-28:
		tmp = z * y
	elif y <= 3.4e-43:
		tmp = x
	elif y <= 1.05e+87:
		tmp = z * y
	else:
		tmp = x * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.8e+210)
		tmp = Float64(x * y);
	elseif (y <= -1.4e-28)
		tmp = Float64(z * y);
	elseif (y <= 3.4e-43)
		tmp = x;
	elseif (y <= 1.05e+87)
		tmp = Float64(z * y);
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.8e+210)
		tmp = x * y;
	elseif (y <= -1.4e-28)
		tmp = z * y;
	elseif (y <= 3.4e-43)
		tmp = x;
	elseif (y <= 1.05e+87)
		tmp = z * y;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+210], N[(x * y), $MachinePrecision], If[LessEqual[y, -1.4e-28], N[(z * y), $MachinePrecision], If[LessEqual[y, 3.4e-43], x, If[LessEqual[y, 1.05e+87], N[(z * y), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+210}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-28}:\\
\;\;\;\;z \cdot y\\

\mathbf{elif}\;y \leq 3.4 \cdot 10^{-43}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+87}:\\
\;\;\;\;z \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8000000000000001e210 or 1.05e87 < y

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\left(y + 1\right)} \cdot x \]
      3. distribute-lft1-inN/A

        \[\leadsto \color{blue}{y \cdot x + x} \]
      4. accelerator-lowering-fma.f6463.4

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, x\right)} \]
    5. Simplified63.4%

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

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

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

        \[\leadsto \color{blue}{y \cdot x} \]
    8. Simplified63.4%

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

    if -1.8000000000000001e210 < y < -1.3999999999999999e-28 or 3.4000000000000001e-43 < y < 1.05e87

    1. Initial program 100.0%

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

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

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

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

    if -1.3999999999999999e-28 < y < 3.4000000000000001e-43

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x} \]
    4. Step-by-step derivation
      1. Simplified77.8%

        \[\leadsto \color{blue}{x} \]
    5. Recombined 3 regimes into one program.
    6. Final simplification69.1%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+210}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-28}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{-43}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+87}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
    7. Add Preprocessing

    Alternative 3: 98.4% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(x + z\right)\\ \mathbf{if}\;y \leq -52000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-16}:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* y (+ x z))))
       (if (<= y -52000000.0) t_0 (if (<= y 1.3e-16) (fma z y x) t_0))))
    double code(double x, double y, double z) {
    	double t_0 = y * (x + z);
    	double tmp;
    	if (y <= -52000000.0) {
    		tmp = t_0;
    	} else if (y <= 1.3e-16) {
    		tmp = fma(z, y, x);
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(y * Float64(x + z))
    	tmp = 0.0
    	if (y <= -52000000.0)
    		tmp = t_0;
    	elseif (y <= 1.3e-16)
    		tmp = fma(z, y, x);
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x + z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -52000000.0], t$95$0, If[LessEqual[y, 1.3e-16], N[(z * y + x), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := y \cdot \left(x + z\right)\\
    \mathbf{if}\;y \leq -52000000:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;y \leq 1.3 \cdot 10^{-16}:\\
    \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -5.2e7 or 1.2999999999999999e-16 < y

      1. Initial program 100.0%

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

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

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

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

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

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

      if -5.2e7 < y < 1.2999999999999999e-16

      1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{z}, y, x\right) \]
      6. Step-by-step derivation
        1. Simplified100.0%

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

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

      Alternative 4: 81.8% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{+115}:\\ \;\;\;\;\mathsf{fma}\left(y, x, x\right)\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-152}:\\ \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, x\right)\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= x -4.2e+115)
         (fma y x x)
         (if (<= x 3.2e-152) (fma z y x) (fma y x x))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (x <= -4.2e+115) {
      		tmp = fma(y, x, x);
      	} else if (x <= 3.2e-152) {
      		tmp = fma(z, y, x);
      	} else {
      		tmp = fma(y, x, x);
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if (x <= -4.2e+115)
      		tmp = fma(y, x, x);
      	elseif (x <= 3.2e-152)
      		tmp = fma(z, y, x);
      	else
      		tmp = fma(y, x, x);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[LessEqual[x, -4.2e+115], N[(y * x + x), $MachinePrecision], If[LessEqual[x, 3.2e-152], N[(z * y + x), $MachinePrecision], N[(y * x + x), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq -4.2 \cdot 10^{+115}:\\
      \;\;\;\;\mathsf{fma}\left(y, x, x\right)\\
      
      \mathbf{elif}\;x \leq 3.2 \cdot 10^{-152}:\\
      \;\;\;\;\mathsf{fma}\left(z, y, x\right)\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(y, x, x\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < -4.20000000000000007e115 or 3.20000000000000013e-152 < x

        1. Initial program 100.0%

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

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

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

            \[\leadsto \color{blue}{\left(y + 1\right)} \cdot x \]
          3. distribute-lft1-inN/A

            \[\leadsto \color{blue}{y \cdot x + x} \]
          4. accelerator-lowering-fma.f6486.9

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

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

        if -4.20000000000000007e115 < x < 3.20000000000000013e-152

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

        Alternative 5: 74.4% accurate, 0.6× speedup?

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

          1. Initial program 100.0%

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

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

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

              \[\leadsto \color{blue}{\left(y + 1\right)} \cdot x \]
            3. distribute-lft1-inN/A

              \[\leadsto \color{blue}{y \cdot x + x} \]
            4. accelerator-lowering-fma.f6482.9

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

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

          if -2.8000000000000001e-26 < x < 3e-152

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{y \cdot z} \]
          4. Step-by-step derivation
            1. *-lowering-*.f6475.0

              \[\leadsto \color{blue}{y \cdot z} \]
          5. Simplified75.0%

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

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

        Alternative 6: 60.3% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{-15}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 6.7 \cdot 10^{-15}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (<= y -2.8e-15) (* x y) (if (<= y 6.7e-15) x (* x y))))
        double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -2.8e-15) {
        		tmp = x * y;
        	} else if (y <= 6.7e-15) {
        		tmp = x;
        	} else {
        		tmp = x * y;
        	}
        	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 (y <= (-2.8d-15)) then
                tmp = x * y
            else if (y <= 6.7d-15) then
                tmp = x
            else
                tmp = x * y
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if (y <= -2.8e-15) {
        		tmp = x * y;
        	} else if (y <= 6.7e-15) {
        		tmp = x;
        	} else {
        		tmp = x * y;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if y <= -2.8e-15:
        		tmp = x * y
        	elif y <= 6.7e-15:
        		tmp = x
        	else:
        		tmp = x * y
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if (y <= -2.8e-15)
        		tmp = Float64(x * y);
        	elseif (y <= 6.7e-15)
        		tmp = x;
        	else
        		tmp = Float64(x * y);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if (y <= -2.8e-15)
        		tmp = x * y;
        	elseif (y <= 6.7e-15)
        		tmp = x;
        	else
        		tmp = x * y;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[LessEqual[y, -2.8e-15], N[(x * y), $MachinePrecision], If[LessEqual[y, 6.7e-15], x, N[(x * y), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -2.8 \cdot 10^{-15}:\\
        \;\;\;\;x \cdot y\\
        
        \mathbf{elif}\;y \leq 6.7 \cdot 10^{-15}:\\
        \;\;\;\;x\\
        
        \mathbf{else}:\\
        \;\;\;\;x \cdot y\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -2.80000000000000014e-15 or 6.70000000000000001e-15 < y

          1. Initial program 100.0%

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

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

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

              \[\leadsto \color{blue}{\left(y + 1\right)} \cdot x \]
            3. distribute-lft1-inN/A

              \[\leadsto \color{blue}{y \cdot x + x} \]
            4. accelerator-lowering-fma.f6454.3

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

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

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

              \[\leadsto \color{blue}{y \cdot x} \]
            2. *-lowering-*.f6453.8

              \[\leadsto \color{blue}{y \cdot x} \]
          8. Simplified53.8%

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

          if -2.80000000000000014e-15 < y < 6.70000000000000001e-15

          1. Initial program 100.0%

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

            \[\leadsto \color{blue}{x} \]
          4. Step-by-step derivation
            1. Simplified74.4%

              \[\leadsto \color{blue}{x} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification63.4%

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{-15}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 6.7 \cdot 10^{-15}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
          7. Add Preprocessing

          Alternative 7: 36.4% accurate, 12.0× speedup?

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

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

            \[\leadsto \color{blue}{x} \]
          4. Step-by-step derivation
            1. Simplified36.0%

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

            Reproduce

            ?
            herbie shell --seed 2024198 
            (FPCore (x y z)
              :name "Main:bigenough2 from A"
              :precision binary64
              (+ x (* y (+ z x))))