SynthBasics:oscSampleBasedAux from YampaSynth-0.2

Percentage Accurate: 100.0% → 100.0%
Time: 4.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: 61.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \left(-y\right) \cdot x\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.55 \cdot 10^{-53}:\\
\;\;\;\;1 \cdot x\\

\mathbf{elif}\;y \leq 1.45 \cdot 10^{+254}:\\
\;\;\;\;z \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1 or 1.45e254 < y

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
      3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

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

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

      if -1 < y < 1.55000000000000008e-53

      1. Initial program 100.0%

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

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

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

          \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
        3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

          \[\leadsto 1 \cdot x \]

        if 1.55000000000000008e-53 < y < 1.45e254

        1. Initial program 100.0%

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

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

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

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

          \[\leadsto \color{blue}{z \cdot y} \]
      8. Recombined 3 regimes into one program.
      9. Add Preprocessing

      Alternative 3: 85.0% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -850000 \lor \neg \left(y \leq 0.48\right):\\ \;\;\;\;\left(z - x\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, y, x\right)\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (if (or (<= y -850000.0) (not (<= y 0.48))) (* (- z x) y) (fma (- x) y x)))
      double code(double x, double y, double z) {
      	double tmp;
      	if ((y <= -850000.0) || !(y <= 0.48)) {
      		tmp = (z - x) * y;
      	} else {
      		tmp = fma(-x, y, x);
      	}
      	return tmp;
      }
      
      function code(x, y, z)
      	tmp = 0.0
      	if ((y <= -850000.0) || !(y <= 0.48))
      		tmp = Float64(Float64(z - x) * y);
      	else
      		tmp = fma(Float64(-x), y, x);
      	end
      	return tmp
      end
      
      code[x_, y_, z_] := If[Or[LessEqual[y, -850000.0], N[Not[LessEqual[y, 0.48]], $MachinePrecision]], N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision], N[((-x) * y + x), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;y \leq -850000 \lor \neg \left(y \leq 0.48\right):\\
      \;\;\;\;\left(z - x\right) \cdot y\\
      
      \mathbf{else}:\\
      \;\;\;\;\mathsf{fma}\left(-x, y, x\right)\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if y < -8.5e5 or 0.47999999999999998 < y

        1. Initial program 100.0%

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

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

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

            \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
          3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

            \[\leadsto 1 \cdot x \]
          2. Taylor expanded in y around inf

            \[\leadsto \color{blue}{y \cdot \left(z - x\right)} \]
          3. 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.7

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

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

          if -8.5e5 < y < 0.47999999999999998

          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. Taylor expanded in x around inf

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

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

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

            \[\leadsto \mathsf{fma}\left(\color{blue}{-x}, y, x\right) \]
        8. Recombined 2 regimes into one program.
        9. Final simplification89.2%

          \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -850000 \lor \neg \left(y \leq 0.48\right):\\ \;\;\;\;\left(z - x\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-x, y, x\right)\\ \end{array} \]
        10. Add Preprocessing

        Alternative 4: 85.0% accurate, 0.6× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -850000 \lor \neg \left(y \leq 0.48\right):\\ \;\;\;\;\left(z - x\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(1 - y\right) \cdot x\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (if (or (<= y -850000.0) (not (<= y 0.48))) (* (- z x) y) (* (- 1.0 y) x)))
        double code(double x, double y, double z) {
        	double tmp;
        	if ((y <= -850000.0) || !(y <= 0.48)) {
        		tmp = (z - x) * y;
        	} else {
        		tmp = (1.0 - y) * x;
        	}
        	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 <= (-850000.0d0)) .or. (.not. (y <= 0.48d0))) then
                tmp = (z - x) * y
            else
                tmp = (1.0d0 - y) * x
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double tmp;
        	if ((y <= -850000.0) || !(y <= 0.48)) {
        		tmp = (z - x) * y;
        	} else {
        		tmp = (1.0 - y) * x;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	tmp = 0
        	if (y <= -850000.0) or not (y <= 0.48):
        		tmp = (z - x) * y
        	else:
        		tmp = (1.0 - y) * x
        	return tmp
        
        function code(x, y, z)
        	tmp = 0.0
        	if ((y <= -850000.0) || !(y <= 0.48))
        		tmp = Float64(Float64(z - x) * y);
        	else
        		tmp = Float64(Float64(1.0 - y) * x);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	tmp = 0.0;
        	if ((y <= -850000.0) || ~((y <= 0.48)))
        		tmp = (z - x) * y;
        	else
        		tmp = (1.0 - y) * x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := If[Or[LessEqual[y, -850000.0], N[Not[LessEqual[y, 0.48]], $MachinePrecision]], N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision], N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;y \leq -850000 \lor \neg \left(y \leq 0.48\right):\\
        \;\;\;\;\left(z - x\right) \cdot y\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(1 - y\right) \cdot x\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if y < -8.5e5 or 0.47999999999999998 < y

          1. Initial program 100.0%

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

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

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

              \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
            3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

              \[\leadsto 1 \cdot x \]
            2. Taylor expanded in y around inf

              \[\leadsto \color{blue}{y \cdot \left(z - x\right)} \]
            3. 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.7

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

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

            if -8.5e5 < y < 0.47999999999999998

            1. Initial program 100.0%

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

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

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

                \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
              3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -850000 \lor \neg \left(y \leq 0.48\right):\\ \;\;\;\;\left(z - x\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(1 - y\right) \cdot x\\ \end{array} \]
          10. Add Preprocessing

          Alternative 5: 75.8% accurate, 0.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{-60} \lor \neg \left(x \leq 2.35 \cdot 10^{-80}\right):\\ \;\;\;\;\left(1 - y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (or (<= x -6.8e-60) (not (<= x 2.35e-80))) (* (- 1.0 y) x) (* z y)))
          double code(double x, double y, double z) {
          	double tmp;
          	if ((x <= -6.8e-60) || !(x <= 2.35e-80)) {
          		tmp = (1.0 - y) * x;
          	} else {
          		tmp = z * 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 ((x <= (-6.8d-60)) .or. (.not. (x <= 2.35d-80))) then
                  tmp = (1.0d0 - y) * x
              else
                  tmp = z * y
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if ((x <= -6.8e-60) || !(x <= 2.35e-80)) {
          		tmp = (1.0 - y) * x;
          	} else {
          		tmp = z * y;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if (x <= -6.8e-60) or not (x <= 2.35e-80):
          		tmp = (1.0 - y) * x
          	else:
          		tmp = z * y
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if ((x <= -6.8e-60) || !(x <= 2.35e-80))
          		tmp = Float64(Float64(1.0 - y) * x);
          	else
          		tmp = Float64(z * y);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if ((x <= -6.8e-60) || ~((x <= 2.35e-80)))
          		tmp = (1.0 - y) * x;
          	else
          		tmp = z * y;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[Or[LessEqual[x, -6.8e-60], N[Not[LessEqual[x, 2.35e-80]], $MachinePrecision]], N[(N[(1.0 - y), $MachinePrecision] * x), $MachinePrecision], N[(z * y), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq -6.8 \cdot 10^{-60} \lor \neg \left(x \leq 2.35 \cdot 10^{-80}\right):\\
          \;\;\;\;\left(1 - y\right) \cdot x\\
          
          \mathbf{else}:\\
          \;\;\;\;z \cdot y\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if x < -6.80000000000000013e-60 or 2.34999999999999986e-80 < x

            1. Initial program 100.0%

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

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

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

                \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
              3. fp-cancel-sign-sub-invN/A

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

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

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

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

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

            if -6.80000000000000013e-60 < x < 2.34999999999999986e-80

            1. Initial program 100.0%

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.8 \cdot 10^{-60} \lor \neg \left(x \leq 2.35 \cdot 10^{-80}\right):\\ \;\;\;\;\left(1 - y\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
          5. Add Preprocessing

          Alternative 6: 61.7% accurate, 0.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-12} \lor \neg \left(y \leq 1.55 \cdot 10^{-53}\right):\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (or (<= y -2.6e-12) (not (<= y 1.55e-53))) (* z y) (* 1.0 x)))
          double code(double x, double y, double z) {
          	double tmp;
          	if ((y <= -2.6e-12) || !(y <= 1.55e-53)) {
          		tmp = z * y;
          	} else {
          		tmp = 1.0 * x;
          	}
          	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 <= (-2.6d-12)) .or. (.not. (y <= 1.55d-53))) then
                  tmp = z * y
              else
                  tmp = 1.0d0 * x
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if ((y <= -2.6e-12) || !(y <= 1.55e-53)) {
          		tmp = z * y;
          	} else {
          		tmp = 1.0 * x;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if (y <= -2.6e-12) or not (y <= 1.55e-53):
          		tmp = z * y
          	else:
          		tmp = 1.0 * x
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if ((y <= -2.6e-12) || !(y <= 1.55e-53))
          		tmp = Float64(z * y);
          	else
          		tmp = Float64(1.0 * x);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if ((y <= -2.6e-12) || ~((y <= 1.55e-53)))
          		tmp = z * y;
          	else
          		tmp = 1.0 * x;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[Or[LessEqual[y, -2.6e-12], N[Not[LessEqual[y, 1.55e-53]], $MachinePrecision]], N[(z * y), $MachinePrecision], N[(1.0 * x), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -2.6 \cdot 10^{-12} \lor \neg \left(y \leq 1.55 \cdot 10^{-53}\right):\\
          \;\;\;\;z \cdot y\\
          
          \mathbf{else}:\\
          \;\;\;\;1 \cdot x\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if y < -2.59999999999999983e-12 or 1.55000000000000008e-53 < y

            1. Initial program 100.0%

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

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

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

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

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

            if -2.59999999999999983e-12 < y < 1.55000000000000008e-53

            1. Initial program 100.0%

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

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

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

                \[\leadsto \color{blue}{\left(1 + -1 \cdot y\right) \cdot x} \]
              3. fp-cancel-sign-sub-invN/A

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

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

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

                \[\leadsto \color{blue}{\left(1 - y\right)} \cdot x \]
            5. Applied rewrites78.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 rewrites78.8%

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-12} \lor \neg \left(y \leq 1.55 \cdot 10^{-53}\right):\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;1 \cdot x\\ \end{array} \]
            10. Add Preprocessing

            Alternative 7: 41.3% accurate, 2.0× speedup?

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

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

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

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

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

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

            Reproduce

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