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

Percentage Accurate: 98.1% → 100.0%
Time: 7.3s
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: 98.1% 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 96.8%

    \[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. Simplified100.0%

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

Alternative 2: 60.9% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;x \leq -6 \cdot 10^{-69}:\\
\;\;\;\;x \cdot y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -8.2e253 or 1.8999999999999999 < x

    1. Initial program 93.1%

      \[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--.f6498.2

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

      \[\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.f6464.8

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

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

    if -8.2e253 < x < -5.99999999999999978e-69

    1. Initial program 96.0%

      \[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-*.f6454.2

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

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

    if -5.99999999999999978e-69 < x < 1.8999999999999999

    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-*.f6475.5

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Simplified75.5%

      \[\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.f6475.5

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

      \[\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. cube-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\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)}}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      8. unpow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\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{{\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      10. lift-neg.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{{z}^{3}}{z \cdot \color{blue}{z}}, x, z\right) \]
      19. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{{z}^{3}}{\color{blue}{{z}^{2}}}, x, z\right) \]
      20. pow-divN/A

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

        \[\leadsto \mathsf{fma}\left({z}^{\color{blue}{1}}, x, z\right) \]
      22. unpow175.1

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

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

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

Alternative 3: 84.4% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{-69}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-13}:\\ \;\;\;\;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 -2.7e-69) t_0 (if (<= x 1.4e-13) (- z (* x z)) t_0))))
double code(double x, double y, double z) {
	double t_0 = x * (y - z);
	double tmp;
	if (x <= -2.7e-69) {
		tmp = t_0;
	} else if (x <= 1.4e-13) {
		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 <= (-2.7d-69)) then
        tmp = t_0
    else if (x <= 1.4d-13) 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 <= -2.7e-69) {
		tmp = t_0;
	} else if (x <= 1.4e-13) {
		tmp = z - (x * z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (y - z)
	tmp = 0
	if x <= -2.7e-69:
		tmp = t_0
	elif x <= 1.4e-13:
		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 <= -2.7e-69)
		tmp = t_0;
	elseif (x <= 1.4e-13)
		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 <= -2.7e-69)
		tmp = t_0;
	elseif (x <= 1.4e-13)
		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, -2.7e-69], t$95$0, If[LessEqual[x, 1.4e-13], 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 -2.7 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-13}:\\
\;\;\;\;z - x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.6999999999999997e-69 or 1.4000000000000001e-13 < x

    1. Initial program 94.8%

      \[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--.f6492.6

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

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

    if -2.6999999999999997e-69 < x < 1.4000000000000001e-13

    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-*.f6477.9

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Simplified77.9%

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

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

Alternative 4: 84.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{-69}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-16}:\\ \;\;\;\;\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 -2.7e-69) t_0 (if (<= x 1.9e-16) (fma z x z) t_0))))
double code(double x, double y, double z) {
	double t_0 = x * (y - z);
	double tmp;
	if (x <= -2.7e-69) {
		tmp = t_0;
	} else if (x <= 1.9e-16) {
		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 <= -2.7e-69)
		tmp = t_0;
	elseif (x <= 1.9e-16)
		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, -2.7e-69], t$95$0, If[LessEqual[x, 1.9e-16], 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 -2.7 \cdot 10^{-69}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.9 \cdot 10^{-16}:\\
\;\;\;\;\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 < -2.6999999999999997e-69 or 1.90000000000000006e-16 < x

    1. Initial program 94.8%

      \[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--.f6492.1

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

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

    if -2.6999999999999997e-69 < x < 1.90000000000000006e-16

    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.5

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Simplified78.5%

      \[\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.5

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

      \[\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. cube-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\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)}}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      8. unpow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\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{{\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      10. lift-neg.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{{z}^{3}}{z \cdot \color{blue}{z}}, x, z\right) \]
      19. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{{z}^{3}}{\color{blue}{{z}^{2}}}, x, z\right) \]
      20. pow-divN/A

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

        \[\leadsto \mathsf{fma}\left({z}^{\color{blue}{1}}, x, z\right) \]
      22. unpow178.5

        \[\leadsto \mathsf{fma}\left(\color{blue}{z}, x, z\right) \]
    9. Applied egg-rr78.5%

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

Alternative 5: 60.9% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-16}:\\
\;\;\;\;\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 < -5.99999999999999978e-69 or 1.35e-16 < x

    1. Initial program 94.8%

      \[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-*.f6448.7

        \[\leadsto \color{blue}{x \cdot y} \]
    5. Simplified48.7%

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

    if -5.99999999999999978e-69 < x < 1.35e-16

    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.5

        \[\leadsto z - \color{blue}{z \cdot x} \]
    5. Simplified78.5%

      \[\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.5

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

      \[\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. cube-negN/A

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

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

        \[\leadsto \mathsf{fma}\left(\frac{\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)}}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      8. unpow-prod-downN/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{{\left(\left(\mathsf{neg}\left(z\right)\right) \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\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{{\left(\color{blue}{\left(\mathsf{neg}\left(z\right)\right)} \cdot \left(\mathsf{neg}\left(z\right)\right)\right)}^{\left(\frac{3}{2}\right)}}{0 \cdot 0 + \left(z \cdot z + 0 \cdot z\right)}, x, z\right) \]
      10. lift-neg.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{{z}^{3}}{z \cdot \color{blue}{z}}, x, z\right) \]
      19. pow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{{z}^{3}}{\color{blue}{{z}^{2}}}, x, z\right) \]
      20. pow-divN/A

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

        \[\leadsto \mathsf{fma}\left({z}^{\color{blue}{1}}, x, z\right) \]
      22. unpow178.5

        \[\leadsto \mathsf{fma}\left(\color{blue}{z}, x, z\right) \]
    9. Applied egg-rr78.5%

      \[\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 96.8%

    \[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-*.f6439.0

      \[\leadsto \color{blue}{x \cdot y} \]
  5. Simplified39.0%

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

Reproduce

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