Diagrams.Color.HSV:lerp from diagrams-contrib-1.3.0.5

Percentage Accurate: 97.8% → 100.0%
Time: 7.7s
Alternatives: 7
Speedup: 1.7×

Specification

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

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

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

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

Alternative 1: 100.0% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y - \left(x \cdot y - x \cdot z\right)} \]
    10. distribute-lft-out--N/A

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

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

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

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

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

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

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

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

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

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

Alternative 2: 60.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.42 \cdot 10^{+160}:\\
\;\;\;\;x \cdot \left(-y\right)\\

\mathbf{elif}\;x \leq -6.6 \cdot 10^{-108}:\\
\;\;\;\;x \cdot z\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.42000000000000007e160

    1. Initial program 90.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      5. lower-neg.f6458.7

        \[\leadsto y \cdot \color{blue}{\left(-x\right)} \]
    8. Simplified58.7%

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

    if -2.42000000000000007e160 < x < -6.6000000000000004e-108 or 0.00209999999999999987 < x

    1. Initial program 95.9%

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

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

        \[\leadsto \color{blue}{x \cdot z} \]
    5. Simplified69.7%

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

    if -6.6000000000000004e-108 < x < 0.00209999999999999987

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot x} \]
      5. lower-*.f6470.7

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

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

        \[\leadsto y - \color{blue}{x \cdot y} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y + y \]
      7. distribute-lft-neg-outN/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, y\right)} \]
      11. lower-neg.f6470.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.2% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 3350000:\\
\;\;\;\;\mathsf{fma}\left(-y, x, y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.56000000000000009e-108 or 3.35e6 < x

    1. Initial program 94.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.56000000000000009e-108 < x < 3.35e6

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot x} \]
      5. lower-*.f6471.3

        \[\leadsto y - \color{blue}{y \cdot x} \]
    5. Simplified71.3%

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

        \[\leadsto y - \color{blue}{x \cdot y} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y + y \]
      7. distribute-lft-neg-outN/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, y\right)} \]
      11. lower-neg.f6471.4

        \[\leadsto \mathsf{fma}\left(\color{blue}{-y}, x, y\right) \]
    7. Applied egg-rr71.4%

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

Alternative 4: 84.2% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 3350000:\\
\;\;\;\;y - x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.0000000000000002e-109 or 3.35e6 < x

    1. Initial program 94.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.0000000000000002e-109 < x < 3.35e6

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot x} \]
      5. lower-*.f6471.3

        \[\leadsto y - \color{blue}{y \cdot x} \]
    5. Simplified71.3%

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

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

Alternative 5: 84.1% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.7e-108 or 0.00209999999999999987 < x

    1. Initial program 94.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.7e-108 < x < 0.00209999999999999987

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot x} \]
      5. lower-*.f6470.7

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

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

        \[\leadsto y - \color{blue}{x \cdot y} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y + y \]
      7. distribute-lft-neg-outN/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, y\right)} \]
      11. lower-neg.f6470.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 60.5% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{-108}:\\
\;\;\;\;x \cdot z\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.59999999999999992e-108 or 0.00209999999999999987 < x

    1. Initial program 94.6%

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

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

        \[\leadsto \color{blue}{x \cdot z} \]
    5. Simplified63.8%

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

    if -4.59999999999999992e-108 < x < 0.00209999999999999987

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto y - \color{blue}{y \cdot x} \]
      5. lower-*.f6470.7

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

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

        \[\leadsto y - \color{blue}{x \cdot y} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot y + y \]
      7. distribute-lft-neg-outN/A

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(y\right), x, y\right)} \]
      11. lower-neg.f6470.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 41.7% accurate, 2.8× speedup?

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

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

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

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

      \[\leadsto \color{blue}{x \cdot z} \]
  5. Simplified48.2%

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

Developer Target 1: 100.0% accurate, 1.4× speedup?

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

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

Reproduce

?
herbie shell --seed 2024207 
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"
  :precision binary64

  :alt
  (! :herbie-platform default (- y (* x (- y z))))

  (+ (* (- 1.0 x) y) (* x z)))