SynthBasics:oscSampleBasedAux from YampaSynth-0.2

Percentage Accurate: 100.0% → 100.0%
Time: 6.0s
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: 60.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -12500000:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-54}:\\
\;\;\;\;1 \cdot x\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{+19}:\\
\;\;\;\;y \cdot z\\

\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.25e7 or 1.1e-54 < y < 1.6e19

    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-*.f6468.8

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

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

    if -1.25e7 < y < 1.1e-54

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

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

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

        \[\leadsto 1 \cdot x \]

      if 1.6e19 < 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--.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 rewrites64.1%

          \[\leadsto \left(-x\right) \cdot y \]
      8. Recombined 3 regimes into one program.
      9. Final simplification70.5%

        \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -12500000:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-54}:\\ \;\;\;\;1 \cdot x\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+19}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot y\\ \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 -1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-7}:\\ \;\;\;\;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 -1.0) t_0 (if (<= y 9.2e-7) (+ (* y z) x) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = y * (z - x);
      	double tmp;
      	if (y <= -1.0) {
      		tmp = t_0;
      	} else if (y <= 9.2e-7) {
      		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 <= (-1.0d0)) then
              tmp = t_0
          else if (y <= 9.2d-7) 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 <= -1.0) {
      		tmp = t_0;
      	} else if (y <= 9.2e-7) {
      		tmp = (y * z) + x;
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = y * (z - x)
      	tmp = 0
      	if y <= -1.0:
      		tmp = t_0
      	elif y <= 9.2e-7:
      		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 <= -1.0)
      		tmp = t_0;
      	elseif (y <= 9.2e-7)
      		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 <= -1.0)
      		tmp = t_0;
      	elseif (y <= 9.2e-7)
      		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, -1.0], t$95$0, If[LessEqual[y, 9.2e-7], 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 -1:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 9.2 \cdot 10^{-7}:\\
      \;\;\;\;y \cdot z + x\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -1 or 9.1999999999999998e-7 < 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--.f6499.2

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

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

        if -1 < y < 9.1999999999999998e-7

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

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

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

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

      Alternative 4: 84.0% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -12500000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-54}:\\ \;\;\;\;\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 -12500000.0) t_0 (if (<= y 1.1e-54) (* (- 1.0 y) x) t_0))))
      double code(double x, double y, double z) {
      	double t_0 = y * (z - x);
      	double tmp;
      	if (y <= -12500000.0) {
      		tmp = t_0;
      	} else if (y <= 1.1e-54) {
      		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 <= (-12500000.0d0)) then
              tmp = t_0
          else if (y <= 1.1d-54) 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 <= -12500000.0) {
      		tmp = t_0;
      	} else if (y <= 1.1e-54) {
      		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 <= -12500000.0:
      		tmp = t_0
      	elif y <= 1.1e-54:
      		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 <= -12500000.0)
      		tmp = t_0;
      	elseif (y <= 1.1e-54)
      		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 <= -12500000.0)
      		tmp = t_0;
      	elseif (y <= 1.1e-54)
      		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, -12500000.0], t$95$0, If[LessEqual[y, 1.1e-54], 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 -12500000:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;y \leq 1.1 \cdot 10^{-54}:\\
      \;\;\;\;\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.25e7 or 1.1e-54 < 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--.f6498.5

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

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

        if -1.25e7 < y < 1.1e-54

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

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

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

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

      Alternative 5: 75.7% accurate, 0.6× speedup?

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

        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--.f6478.1

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

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

        if -3.64999999999999991e-152 < x < 9.5e-91

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

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

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

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

      Alternative 6: 59.6% accurate, 0.7× speedup?

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

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

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

        if -1.25e7 < y < 1.1e-54

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

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

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

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

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

        Alternative 7: 41.5% 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-*.f6442.1

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

          \[\leadsto \color{blue}{z \cdot y} \]
        6. Final simplification42.1%

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

        Reproduce

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