SynthBasics:oscSampleBasedAux from YampaSynth-0.2

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 7 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.2× speedup?

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

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

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

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

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

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

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

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

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

Alternative 2: 61.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{+270}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -4.3 \cdot 10^{+61}:\\ \;\;\;\;\left(-x\right) \cdot y\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{-55}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-45}:\\ \;\;\;\;1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.9e+270)
   (* y z)
   (if (<= y -4.3e+61)
     (* (- x) y)
     (if (<= y -1.7e-55) (* y z) (if (<= y 6e-45) (* 1.0 x) (* y z))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.9e+270) {
		tmp = y * z;
	} else if (y <= -4.3e+61) {
		tmp = -x * y;
	} else if (y <= -1.7e-55) {
		tmp = y * z;
	} else if (y <= 6e-45) {
		tmp = 1.0 * x;
	} else {
		tmp = y * z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-3.9d+270)) then
        tmp = y * z
    else if (y <= (-4.3d+61)) then
        tmp = -x * y
    else if (y <= (-1.7d-55)) then
        tmp = y * z
    else if (y <= 6d-45) then
        tmp = 1.0d0 * x
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.9e+270) {
		tmp = y * z;
	} else if (y <= -4.3e+61) {
		tmp = -x * y;
	} else if (y <= -1.7e-55) {
		tmp = y * z;
	} else if (y <= 6e-45) {
		tmp = 1.0 * x;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -3.9e+270:
		tmp = y * z
	elif y <= -4.3e+61:
		tmp = -x * y
	elif y <= -1.7e-55:
		tmp = y * z
	elif y <= 6e-45:
		tmp = 1.0 * x
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.9e+270)
		tmp = Float64(y * z);
	elseif (y <= -4.3e+61)
		tmp = Float64(Float64(-x) * y);
	elseif (y <= -1.7e-55)
		tmp = Float64(y * z);
	elseif (y <= 6e-45)
		tmp = Float64(1.0 * x);
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -3.9e+270)
		tmp = y * z;
	elseif (y <= -4.3e+61)
		tmp = -x * y;
	elseif (y <= -1.7e-55)
		tmp = y * z;
	elseif (y <= 6e-45)
		tmp = 1.0 * x;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -3.9e+270], N[(y * z), $MachinePrecision], If[LessEqual[y, -4.3e+61], N[((-x) * y), $MachinePrecision], If[LessEqual[y, -1.7e-55], N[(y * z), $MachinePrecision], If[LessEqual[y, 6e-45], N[(1.0 * x), $MachinePrecision], N[(y * z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{+270}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq -4.3 \cdot 10^{+61}:\\
\;\;\;\;\left(-x\right) \cdot y\\

\mathbf{elif}\;y \leq -1.7 \cdot 10^{-55}:\\
\;\;\;\;y \cdot z\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.8999999999999999e270 or -4.3000000000000001e61 < y < -1.69999999999999986e-55 or 6.00000000000000022e-45 < y

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{z \cdot y} \]
      2. lower-*.f6458.1

        \[\leadsto \color{blue}{z \cdot y} \]
    5. Applied rewrites58.1%

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

    if -3.8999999999999999e270 < y < -4.3000000000000001e61

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \left(-1 \cdot x\right) \cdot y \]
    7. Step-by-step derivation
      1. Applied rewrites67.4%

        \[\leadsto \left(-x\right) \cdot y \]

      if -1.69999999999999986e-55 < y < 6.00000000000000022e-45

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(1 - y\right)} \cdot x \]
        10. lower--.f6476.8

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

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

        \[\leadsto 1 \cdot x \]
      7. Step-by-step derivation
        1. Applied rewrites76.8%

          \[\leadsto 1 \cdot x \]
      8. Recombined 3 regimes into one program.
      9. Final simplification68.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{+270}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -4.3 \cdot 10^{+61}:\\ \;\;\;\;\left(-x\right) \cdot y\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{-55}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-45}:\\ \;\;\;\;1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
      10. Add Preprocessing

      Alternative 3: 98.9% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1620000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1:\\ \;\;\;\;y \cdot z + x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* y (- z x))))
         (if (<= y -1620000.0) t_0 (if (<= y 1.0) (+ (* y z) x) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = y * (z - x);
      	double tmp;
      	if (y <= -1620000.0) {
      		tmp = t_0;
      	} else if (y <= 1.0) {
      		tmp = (y * z) + x;
      	} 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 = y * (z - x)
          if (y <= (-1620000.0d0)) then
              tmp = t_0
          else if (y <= 1.0d0) then
              tmp = (y * z) + x
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = y * (z - x);
      	double tmp;
      	if (y <= -1620000.0) {
      		tmp = t_0;
      	} else if (y <= 1.0) {
      		tmp = (y * z) + x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = y * (z - x)
      	tmp = 0
      	if y <= -1620000.0:
      		tmp = t_0
      	elif y <= 1.0:
      		tmp = (y * z) + x
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(y * Float64(z - x))
      	tmp = 0.0
      	if (y <= -1620000.0)
      		tmp = t_0;
      	elseif (y <= 1.0)
      		tmp = Float64(Float64(y * z) + x);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = y * (z - x);
      	tmp = 0.0;
      	if (y <= -1620000.0)
      		tmp = t_0;
      	elseif (y <= 1.0)
      		tmp = (y * z) + x;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1620000.0], t$95$0, If[LessEqual[y, 1.0], N[(N[(y * z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := y \cdot \left(z - x\right)\\
      \mathbf{if}\;y \leq -1620000:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 1:\\
      \;\;\;\;y \cdot z + x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -1.62e6 or 1 < y

        1. Initial program 99.9%

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

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

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

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

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

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

        if -1.62e6 < y < 1

        1. Initial program 100.0%

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

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

            \[\leadsto x + \color{blue}{z \cdot y} \]
          2. lower-*.f6499.2

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

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

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

      Alternative 4: 84.3% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{-55}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 13500:\\ \;\;\;\;\left(1 - y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* y (- z x))))
         (if (<= y -1.7e-55) t_0 (if (<= y 13500.0) (* (- 1.0 y) x) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = y * (z - x);
      	double tmp;
      	if (y <= -1.7e-55) {
      		tmp = t_0;
      	} else if (y <= 13500.0) {
      		tmp = (1.0 - y) * x;
      	} 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 = y * (z - x)
          if (y <= (-1.7d-55)) then
              tmp = t_0
          else if (y <= 13500.0d0) then
              tmp = (1.0d0 - y) * x
          else
              tmp = t_0
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = y * (z - x);
      	double tmp;
      	if (y <= -1.7e-55) {
      		tmp = t_0;
      	} else if (y <= 13500.0) {
      		tmp = (1.0 - y) * x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = y * (z - x)
      	tmp = 0
      	if y <= -1.7e-55:
      		tmp = t_0
      	elif y <= 13500.0:
      		tmp = (1.0 - y) * x
      	else:
      		tmp = t_0
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(y * Float64(z - x))
      	tmp = 0.0
      	if (y <= -1.7e-55)
      		tmp = t_0;
      	elseif (y <= 13500.0)
      		tmp = Float64(Float64(1.0 - y) * x);
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = y * (z - x);
      	tmp = 0.0;
      	if (y <= -1.7e-55)
      		tmp = t_0;
      	elseif (y <= 13500.0)
      		tmp = (1.0 - y) * x;
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.7e-55], t$95$0, If[LessEqual[y, 13500.0], N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := y \cdot \left(z - x\right)\\
      \mathbf{if}\;y \leq -1.7 \cdot 10^{-55}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 13500:\\
      \;\;\;\;\left(1 - y\right) \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -1.69999999999999986e-55 or 13500 < y

        1. Initial program 100.0%

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

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

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

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

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

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

        if -1.69999999999999986e-55 < y < 13500

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(1 - y\right)} \cdot x \]
          10. lower--.f6475.6

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

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

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

      Alternative 5: 75.9% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+119}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+79}:\\ \;\;\;\;\left(1 - y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (<= z -4.2e+119) (* y z) (if (<= z 8e+79) (* (- 1.0 y) x) (* y z))))
      double code(double x, double y, double z) {
      	double tmp;
      	if (z <= -4.2e+119) {
      		tmp = y * z;
      	} else if (z <= 8e+79) {
      		tmp = (1.0 - y) * x;
      	} else {
      		tmp = y * z;
      	}
      	return tmp;
      }
      
      real(8) function code(x, y, z)
          real(8), intent (in) :: x
          real(8), intent (in) :: y
          real(8), intent (in) :: z
          real(8) :: tmp
          if (z <= (-4.2d+119)) then
              tmp = y * z
          else if (z <= 8d+79) then
              tmp = (1.0d0 - y) * x
          else
              tmp = y * z
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double tmp;
      	if (z <= -4.2e+119) {
      		tmp = y * z;
      	} else if (z <= 8e+79) {
      		tmp = (1.0 - y) * x;
      	} else {
      		tmp = y * z;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	tmp = 0
      	if z <= -4.2e+119:
      		tmp = y * z
      	elif z <= 8e+79:
      		tmp = (1.0 - y) * x
      	else:
      		tmp = y * z
      	return tmp
      
      function code(x, y, z)
      	tmp = 0.0
      	if (z <= -4.2e+119)
      		tmp = Float64(y * z);
      	elseif (z <= 8e+79)
      		tmp = Float64(Float64(1.0 - y) * x);
      	else
      		tmp = Float64(y * z);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	tmp = 0.0;
      	if (z <= -4.2e+119)
      		tmp = y * z;
      	elseif (z <= 8e+79)
      		tmp = (1.0 - y) * x;
      	else
      		tmp = y * z;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := If[LessEqual[z, -4.2e+119], N[(y * z), $MachinePrecision], If[LessEqual[z, 8e+79], N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision], N[(y * z), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;z \leq -4.2 \cdot 10^{+119}:\\
      \;\;\;\;y \cdot z\\
      
      \mathbf{elif}\;z \leq 8 \cdot 10^{+79}:\\
      \;\;\;\;\left(1 - y\right) \cdot x\\
      
      \mathbf{else}:\\
      \;\;\;\;y \cdot z\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if z < -4.19999999999999966e119 or 7.99999999999999974e79 < z

        1. Initial program 100.0%

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

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

            \[\leadsto \color{blue}{z \cdot y} \]
          2. lower-*.f6480.5

            \[\leadsto \color{blue}{z \cdot y} \]
        5. Applied rewrites80.5%

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

        if -4.19999999999999966e119 < z < 7.99999999999999974e79

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(1 - y\right)} \cdot x \]
          10. lower--.f6481.0

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

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

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

      Alternative 6: 61.4% accurate, 0.7× speedup?

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

        1. Initial program 100.0%

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

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

            \[\leadsto \color{blue}{z \cdot y} \]
          2. lower-*.f6454.1

            \[\leadsto \color{blue}{z \cdot y} \]
        5. Applied rewrites54.1%

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

        if -1.69999999999999986e-55 < y < 6.00000000000000022e-45

        1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\left(1 - y\right)} \cdot x \]
          10. lower--.f6476.8

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

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

          \[\leadsto 1 \cdot x \]
        7. Step-by-step derivation
          1. Applied rewrites76.8%

            \[\leadsto 1 \cdot x \]
        8. Recombined 2 regimes into one program.
        9. Final simplification64.7%

          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-55}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-45}:\\ \;\;\;\;1 \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
        10. Add Preprocessing

        Alternative 7: 41.1% accurate, 2.0× speedup?

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

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

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

            \[\leadsto \color{blue}{z \cdot y} \]
          2. lower-*.f6441.0

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

          \[\leadsto \color{blue}{z \cdot y} \]
        6. Final simplification41.0%

          \[\leadsto y \cdot z \]
        7. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2024240 
        (FPCore (x y z)
          :name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
          :precision binary64
          (+ x (* y (- z x))))