Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3

Percentage Accurate: 97.9% → 100.0%
Time: 7.6s
Alternatives: 6
Speedup: 1.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 97.9% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.7× speedup?

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

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

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

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

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

      \[\leadsto x \cdot \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right) + z \]
    3. remove-double-negN/A

      \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right)\right) + z \]
    4. mul-1-negN/A

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\mathsf{neg}\left(-1 \cdot y\right)\right) + \left(\mathsf{neg}\left(z\right)\right)}, z\right) \]
    10. mul-1-negN/A

      \[\leadsto \mathsf{fma}\left(x, \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right), z\right) \]
    11. remove-double-negN/A

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{y} + \left(\mathsf{neg}\left(z\right)\right), z\right) \]
    12. unsub-negN/A

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

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

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

Alternative 2: 61.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;x \leq -1.3 \cdot 10^{+159}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-15}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 0.0052:\\ \;\;\;\;\mathsf{fma}\left(z, x, z\right)\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+207}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- z))))
   (if (<= x -1.3e+159)
     t_0
     (if (<= x -3.2e-15)
       (* x y)
       (if (<= x 0.0052) (fma z x z) (if (<= x 3.8e+207) (* x y) t_0))))))
double code(double x, double y, double z) {
	double t_0 = x * -z;
	double tmp;
	if (x <= -1.3e+159) {
		tmp = t_0;
	} else if (x <= -3.2e-15) {
		tmp = x * y;
	} else if (x <= 0.0052) {
		tmp = fma(z, x, z);
	} else if (x <= 3.8e+207) {
		tmp = x * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(x * Float64(-z))
	tmp = 0.0
	if (x <= -1.3e+159)
		tmp = t_0;
	elseif (x <= -3.2e-15)
		tmp = Float64(x * y);
	elseif (x <= 0.0052)
		tmp = fma(z, x, z);
	elseif (x <= 3.8e+207)
		tmp = Float64(x * y);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[x, -1.3e+159], t$95$0, If[LessEqual[x, -3.2e-15], N[(x * y), $MachinePrecision], If[LessEqual[x, 0.0052], N[(z * x + z), $MachinePrecision], If[LessEqual[x, 3.8e+207], N[(x * y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+159}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -3.2 \cdot 10^{-15}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq 0.0052:\\
\;\;\;\;\mathsf{fma}\left(z, x, z\right)\\

\mathbf{elif}\;x \leq 3.8 \cdot 10^{+207}:\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.3e159 or 3.79999999999999986e207 < x

    1. Initial program 90.4%

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

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

        \[\leadsto x \cdot \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right) \]
      2. remove-double-negN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right)\right) \]
      3. mul-1-negN/A

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

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

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

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

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot y + z\right)}\right)\right) \]
      8. distribute-neg-inN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot y\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right)} \]
      9. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right) \]
      10. remove-double-negN/A

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot z\right)} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(x \cdot z\right)} \]
      2. distribute-rgt-neg-inN/A

        \[\leadsto \color{blue}{x \cdot \left(\mathsf{neg}\left(z\right)\right)} \]
      3. mul-1-negN/A

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

        \[\leadsto \color{blue}{x \cdot \left(-1 \cdot z\right)} \]
      5. mul-1-negN/A

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

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

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

    if -1.3e159 < x < -3.1999999999999999e-15 or 0.0051999999999999998 < x < 3.79999999999999986e207

    1. Initial program 97.5%

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

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

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

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

    if -3.1999999999999999e-15 < x < 0.0051999999999999998

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{z \cdot \left(1 - x\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-out--N/A

        \[\leadsto \color{blue}{1 \cdot z - x \cdot z} \]
      2. *-lft-identityN/A

        \[\leadsto \color{blue}{z} - x \cdot z \]
      3. lower--.f64N/A

        \[\leadsto \color{blue}{z - x \cdot z} \]
      4. *-commutativeN/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      5. lower-*.f6478.1

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Applied rewrites78.1%

      \[\leadsto \color{blue}{z - z \cdot x} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      2. sub-negN/A

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), x, z\right)} \]
      7. lower-neg.f6478.1

        \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, x, z\right) \]
    7. Applied rewrites78.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-z, x, z\right)} \]
    8. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{0 - z}, x, z\right) \]
      2. flip3--N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{{0}^{3} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}}, x, z\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{0} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      4. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\mathsf{neg}\left({z}^{3}\right)}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      5. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{z}^{\left(\frac{3}{2}\right)} \cdot {z}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(z \cdot z\right)}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      7. sqr-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\color{blue}{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      8. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      9. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right)}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      10. pow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      11. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{3}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\color{blue}{\left(\mathsf{neg}\left(z\right)\right)}}^{3}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      13. cube-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({z}^{3}\right)\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      14. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{\left(0 - {z}^{3}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\left(\color{blue}{{0}^{3}} - {z}^{3}\right)\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      16. distribute-neg-fracN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\frac{{0}^{3} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}\right)}, x, z\right) \]
      17. flip3--N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(0 - z\right)}\right), x, z\right) \]
      18. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right), x, z\right) \]
      19. remove-double-neg77.0

        \[\leadsto \mathsf{fma}\left(\color{blue}{z}, x, z\right) \]
    9. Applied rewrites77.0%

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

Alternative 3: 85.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-8}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 0.23:\\ \;\;\;\;z - x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- y z))))
   (if (<= x -1.2e-8) t_0 (if (<= x 0.23) (- z (* x z)) t_0))))
double code(double x, double y, double z) {
	double t_0 = x * (y - z);
	double tmp;
	if (x <= -1.2e-8) {
		tmp = t_0;
	} else if (x <= 0.23) {
		tmp = z - (x * 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 <= (-1.2d-8)) then
        tmp = t_0
    else if (x <= 0.23d0) then
        tmp = z - (x * 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 <= -1.2e-8) {
		tmp = t_0;
	} else if (x <= 0.23) {
		tmp = z - (x * z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y - z)
	tmp = 0
	if x <= -1.2e-8:
		tmp = t_0
	elif x <= 0.23:
		tmp = z - (x * z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(y - z))
	tmp = 0.0
	if (x <= -1.2e-8)
		tmp = t_0;
	elseif (x <= 0.23)
		tmp = Float64(z - Float64(x * 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 <= -1.2e-8)
		tmp = t_0;
	elseif (x <= 0.23)
		tmp = z - (x * 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, -1.2e-8], t$95$0, If[LessEqual[x, 0.23], N[(z - N[(x * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(y - z\right)\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 0.23:\\
\;\;\;\;z - x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.19999999999999999e-8 or 0.23000000000000001 < x

    1. Initial program 94.7%

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

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

        \[\leadsto x \cdot \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right) \]
      2. remove-double-negN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right)\right) \]
      3. mul-1-negN/A

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

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

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

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

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot y + z\right)}\right)\right) \]
      8. distribute-neg-inN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot y\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right)} \]
      9. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right) \]
      10. remove-double-negN/A

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

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

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

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

    if -1.19999999999999999e-8 < x < 0.23000000000000001

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{z \cdot \left(1 - x\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-out--N/A

        \[\leadsto \color{blue}{1 \cdot z - x \cdot z} \]
      2. *-lft-identityN/A

        \[\leadsto \color{blue}{z} - x \cdot z \]
      3. lower--.f64N/A

        \[\leadsto \color{blue}{z - x \cdot z} \]
      4. *-commutativeN/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      5. lower-*.f6478.1

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Applied rewrites78.1%

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

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

Alternative 4: 85.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -3.1 \cdot 10^{-15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 0.0052:\\ \;\;\;\;\mathsf{fma}\left(z, x, z\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (- y z))))
   (if (<= x -3.1e-15) t_0 (if (<= x 0.0052) (fma z x z) t_0))))
double code(double x, double y, double z) {
	double t_0 = x * (y - z);
	double tmp;
	if (x <= -3.1e-15) {
		tmp = t_0;
	} else if (x <= 0.0052) {
		tmp = fma(z, x, z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(x * Float64(y - z))
	tmp = 0.0
	if (x <= -3.1e-15)
		tmp = t_0;
	elseif (x <= 0.0052)
		tmp = fma(z, x, z);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.1e-15], t$95$0, If[LessEqual[x, 0.0052], N[(z * x + z), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(y - z\right)\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 0.0052:\\
\;\;\;\;\mathsf{fma}\left(z, x, z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.0999999999999999e-15 or 0.0051999999999999998 < x

    1. Initial program 94.7%

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

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

        \[\leadsto x \cdot \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right) \]
      2. remove-double-negN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right)} + \left(\mathsf{neg}\left(z\right)\right)\right) \]
      3. mul-1-negN/A

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

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

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

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

        \[\leadsto x \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot y + z\right)}\right)\right) \]
      8. distribute-neg-inN/A

        \[\leadsto x \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot y\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right)} \]
      9. mul-1-negN/A

        \[\leadsto x \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(y\right)\right)}\right)\right) + \left(\mathsf{neg}\left(z\right)\right)\right) \]
      10. remove-double-negN/A

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

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

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

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

    if -3.0999999999999999e-15 < x < 0.0051999999999999998

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{z \cdot \left(1 - x\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-out--N/A

        \[\leadsto \color{blue}{1 \cdot z - x \cdot z} \]
      2. *-lft-identityN/A

        \[\leadsto \color{blue}{z} - x \cdot z \]
      3. lower--.f64N/A

        \[\leadsto \color{blue}{z - x \cdot z} \]
      4. *-commutativeN/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      5. lower-*.f6478.1

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Applied rewrites78.1%

      \[\leadsto \color{blue}{z - z \cdot x} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      2. sub-negN/A

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), x, z\right)} \]
      7. lower-neg.f6478.1

        \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, x, z\right) \]
    7. Applied rewrites78.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-z, x, z\right)} \]
    8. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{0 - z}, x, z\right) \]
      2. flip3--N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{{0}^{3} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}}, x, z\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{0} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      4. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\mathsf{neg}\left({z}^{3}\right)}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      5. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{z}^{\left(\frac{3}{2}\right)} \cdot {z}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(z \cdot z\right)}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      7. sqr-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\color{blue}{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      8. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      9. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right)}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      10. pow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      11. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{3}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\color{blue}{\left(\mathsf{neg}\left(z\right)\right)}}^{3}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      13. cube-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({z}^{3}\right)\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      14. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{\left(0 - {z}^{3}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\left(\color{blue}{{0}^{3}} - {z}^{3}\right)\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      16. distribute-neg-fracN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\frac{{0}^{3} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}\right)}, x, z\right) \]
      17. flip3--N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(0 - z\right)}\right), x, z\right) \]
      18. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right), x, z\right) \]
      19. remove-double-neg77.0

        \[\leadsto \mathsf{fma}\left(\color{blue}{z}, x, z\right) \]
    9. Applied rewrites77.0%

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

Alternative 5: 61.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3.2 \cdot 10^{-15}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 0.0052:\\ \;\;\;\;\mathsf{fma}\left(z, x, z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -3.2e-15) (* x y) (if (<= x 0.0052) (fma z x z) (* x y))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.2e-15) {
		tmp = x * y;
	} else if (x <= 0.0052) {
		tmp = fma(z, x, z);
	} else {
		tmp = x * y;
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (x <= -3.2e-15)
		tmp = Float64(x * y);
	elseif (x <= 0.0052)
		tmp = fma(z, x, z);
	else
		tmp = Float64(x * y);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[x, -3.2e-15], N[(x * y), $MachinePrecision], If[LessEqual[x, 0.0052], N[(z * x + z), $MachinePrecision], N[(x * y), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 0.0052:\\
\;\;\;\;\mathsf{fma}\left(z, x, z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.1999999999999999e-15 or 0.0051999999999999998 < x

    1. Initial program 94.7%

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

      \[\leadsto \color{blue}{x \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6455.3

        \[\leadsto \color{blue}{x \cdot y} \]
    5. Applied rewrites55.3%

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

    if -3.1999999999999999e-15 < x < 0.0051999999999999998

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{z \cdot \left(1 - x\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt-out--N/A

        \[\leadsto \color{blue}{1 \cdot z - x \cdot z} \]
      2. *-lft-identityN/A

        \[\leadsto \color{blue}{z} - x \cdot z \]
      3. lower--.f64N/A

        \[\leadsto \color{blue}{z - x \cdot z} \]
      4. *-commutativeN/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      5. lower-*.f6478.1

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Applied rewrites78.1%

      \[\leadsto \color{blue}{z - z \cdot x} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto z - \color{blue}{z \cdot x} \]
      2. sub-negN/A

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(z\right), x, z\right)} \]
      7. lower-neg.f6478.1

        \[\leadsto \mathsf{fma}\left(\color{blue}{-z}, x, z\right) \]
    7. Applied rewrites78.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-z, x, z\right)} \]
    8. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{0 - z}, x, z\right) \]
      2. flip3--N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{{0}^{3} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}}, x, z\right) \]
      3. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{0} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      4. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\mathsf{neg}\left({z}^{3}\right)}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      5. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{z}^{\left(\frac{3}{2}\right)} \cdot {z}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      6. pow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(z \cdot z\right)}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      7. sqr-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\color{blue}{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      8. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      9. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right)}^{\left(\frac{3}{2}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      10. pow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(\mathsf{neg}\left(z\right)\right)}^{\left(\frac{3}{2}\right)}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      11. sqr-powN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{{\left(\mathsf{neg}\left(z\right)\right)}^{3}}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left({\color{blue}{\left(\mathsf{neg}\left(z\right)\right)}}^{3}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      13. cube-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({z}^{3}\right)\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      14. sub0-negN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\color{blue}{\left(0 - {z}^{3}\right)}\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{fma}\left(\frac{\mathsf{neg}\left(\left(\color{blue}{{0}^{3}} - {z}^{3}\right)\right)}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      16. distribute-neg-fracN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(\frac{{0}^{3} - {z}^{3}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}\right)}, x, z\right) \]
      17. flip3--N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(0 - z\right)}\right), x, z\right) \]
      18. neg-sub0N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right), x, z\right) \]
      19. remove-double-neg77.0

        \[\leadsto \mathsf{fma}\left(\color{blue}{z}, x, z\right) \]
    9. Applied rewrites77.0%

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

Alternative 6: 41.3% accurate, 2.8× speedup?

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

\\
x \cdot y
\end{array}
Derivation
  1. Initial program 97.2%

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

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

      \[\leadsto \color{blue}{x \cdot y} \]
  5. Applied rewrites40.2%

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

Reproduce

?
herbie shell --seed 2024219 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
  :precision binary64
  (+ (* x y) (* (- 1.0 x) z)))