SynthBasics:oscSampleBasedAux from YampaSynth-0.2

Percentage Accurate: 100.0% → 100.0%
Time: 4.5s
Alternatives: 8
Speedup: 1.0×

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 8 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, 0.1× speedup?

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

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

    \[x + y \cdot \left(z - x\right) \]
  2. Step-by-step derivation
    1. +-commutative100.0%

      \[\leadsto \color{blue}{y \cdot \left(z - x\right) + x} \]
    2. fma-def100.0%

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

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

    \[\leadsto \mathsf{fma}\left(y, z - x, x\right) \]

Alternative 2: 60.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-76}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+68} \lor \neg \left(y \leq 6.6 \cdot 10^{+150} \lor \neg \left(y \leq 4 \cdot 10^{+255}\right) \land y \leq 1.25 \cdot 10^{+278}\right):\\ \;\;\;\;y \cdot z\\ \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 1e-105)
       x
       (if (<= y 6.5e-76)
         (* y z)
         (if (<= y 6.5e-19)
           x
           (if (or (<= y 2e+68)
                   (not
                    (or (<= y 6.6e+150)
                        (and (not (<= y 4e+255)) (<= y 1.25e+278)))))
             (* y z)
             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 <= 1e-105) {
		tmp = x;
	} else if (y <= 6.5e-76) {
		tmp = y * z;
	} else if (y <= 6.5e-19) {
		tmp = x;
	} else if ((y <= 2e+68) || !((y <= 6.6e+150) || (!(y <= 4e+255) && (y <= 1.25e+278)))) {
		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 = y * -x
    if (y <= (-1.0d0)) then
        tmp = t_0
    else if (y <= 1d-105) then
        tmp = x
    else if (y <= 6.5d-76) then
        tmp = y * z
    else if (y <= 6.5d-19) then
        tmp = x
    else if ((y <= 2d+68) .or. (.not. (y <= 6.6d+150) .or. (.not. (y <= 4d+255)) .and. (y <= 1.25d+278))) 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 = y * -x;
	double tmp;
	if (y <= -1.0) {
		tmp = t_0;
	} else if (y <= 1e-105) {
		tmp = x;
	} else if (y <= 6.5e-76) {
		tmp = y * z;
	} else if (y <= 6.5e-19) {
		tmp = x;
	} else if ((y <= 2e+68) || !((y <= 6.6e+150) || (!(y <= 4e+255) && (y <= 1.25e+278)))) {
		tmp = y * z;
	} 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 <= 1e-105:
		tmp = x
	elif y <= 6.5e-76:
		tmp = y * z
	elif y <= 6.5e-19:
		tmp = x
	elif (y <= 2e+68) or not ((y <= 6.6e+150) or (not (y <= 4e+255) and (y <= 1.25e+278))):
		tmp = y * z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(-x))
	tmp = 0.0
	if (y <= -1.0)
		tmp = t_0;
	elseif (y <= 1e-105)
		tmp = x;
	elseif (y <= 6.5e-76)
		tmp = Float64(y * z);
	elseif (y <= 6.5e-19)
		tmp = x;
	elseif ((y <= 2e+68) || !((y <= 6.6e+150) || (!(y <= 4e+255) && (y <= 1.25e+278))))
		tmp = Float64(y * z);
	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 <= 1e-105)
		tmp = x;
	elseif (y <= 6.5e-76)
		tmp = y * z;
	elseif (y <= 6.5e-19)
		tmp = x;
	elseif ((y <= 2e+68) || ~(((y <= 6.6e+150) || (~((y <= 4e+255)) && (y <= 1.25e+278)))))
		tmp = y * z;
	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, 1e-105], x, If[LessEqual[y, 6.5e-76], N[(y * z), $MachinePrecision], If[LessEqual[y, 6.5e-19], x, If[Or[LessEqual[y, 2e+68], N[Not[Or[LessEqual[y, 6.6e+150], And[N[Not[LessEqual[y, 4e+255]], $MachinePrecision], LessEqual[y, 1.25e+278]]]], $MachinePrecision]], N[(y * z), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 10^{-105}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{-76}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{-19}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 2 \cdot 10^{+68} \lor \neg \left(y \leq 6.6 \cdot 10^{+150} \lor \neg \left(y \leq 4 \cdot 10^{+255}\right) \land y \leq 1.25 \cdot 10^{+278}\right):\\
\;\;\;\;y \cdot z\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1 or 1.99999999999999991e68 < y < 6.59999999999999962e150 or 3.99999999999999995e255 < y < 1.25000000000000007e278

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{-x \cdot y} \]
      2. distribute-lft-neg-out63.4%

        \[\leadsto \color{blue}{\left(-x\right) \cdot y} \]
      3. *-commutative63.4%

        \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
    5. Simplified63.4%

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

    if -1 < y < 9.99999999999999965e-106 or 6.5e-76 < y < 6.5000000000000001e-19

    1. Initial program 100.0%

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

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

    if 9.99999999999999965e-106 < y < 6.5e-76 or 6.5000000000000001e-19 < y < 1.99999999999999991e68 or 6.59999999999999962e150 < y < 3.99999999999999995e255 or 1.25000000000000007e278 < y

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-76}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+68} \lor \neg \left(y \leq 6.6 \cdot 10^{+150} \lor \neg \left(y \leq 4 \cdot 10^{+255}\right) \land y \leq 1.25 \cdot 10^{+278}\right):\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]

Alternative 3: 74.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+71} \lor \neg \left(z \leq -3.8 \cdot 10^{+31}\right) \land \left(z \leq -1.2 \cdot 10^{-14} \lor \neg \left(z \leq 2.1 \cdot 10^{+38}\right)\right):\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.9e+71)
         (and (not (<= z -3.8e+31)) (or (<= z -1.2e-14) (not (<= z 2.1e+38)))))
   (* y z)
   (* x (- 1.0 y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.9e+71) || (!(z <= -3.8e+31) && ((z <= -1.2e-14) || !(z <= 2.1e+38)))) {
		tmp = y * z;
	} else {
		tmp = x * (1.0 - 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 ((z <= (-1.9d+71)) .or. (.not. (z <= (-3.8d+31))) .and. (z <= (-1.2d-14)) .or. (.not. (z <= 2.1d+38))) then
        tmp = y * z
    else
        tmp = x * (1.0d0 - y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.9e+71) || (!(z <= -3.8e+31) && ((z <= -1.2e-14) || !(z <= 2.1e+38)))) {
		tmp = y * z;
	} else {
		tmp = x * (1.0 - y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.9e+71) or (not (z <= -3.8e+31) and ((z <= -1.2e-14) or not (z <= 2.1e+38))):
		tmp = y * z
	else:
		tmp = x * (1.0 - y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.9e+71) || (!(z <= -3.8e+31) && ((z <= -1.2e-14) || !(z <= 2.1e+38))))
		tmp = Float64(y * z);
	else
		tmp = Float64(x * Float64(1.0 - y));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.9e+71) || (~((z <= -3.8e+31)) && ((z <= -1.2e-14) || ~((z <= 2.1e+38)))))
		tmp = y * z;
	else
		tmp = x * (1.0 - y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9e+71], And[N[Not[LessEqual[z, -3.8e+31]], $MachinePrecision], Or[LessEqual[z, -1.2e-14], N[Not[LessEqual[z, 2.1e+38]], $MachinePrecision]]]], N[(y * z), $MachinePrecision], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+71} \lor \neg \left(z \leq -3.8 \cdot 10^{+31}\right) \land \left(z \leq -1.2 \cdot 10^{-14} \lor \neg \left(z \leq 2.1 \cdot 10^{+38}\right)\right):\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.9e71 or -3.8000000000000001e31 < z < -1.2e-14 or 2.1e38 < z

    1. Initial program 100.0%

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

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

    if -1.9e71 < z < -3.8000000000000001e31 or -1.2e-14 < z < 2.1e38

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot y\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg86.5%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-y\right)}\right) \]
      2. unsub-neg86.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.9 \cdot 10^{+71} \lor \neg \left(z \leq -3.8 \cdot 10^{+31}\right) \land \left(z \leq -1.2 \cdot 10^{-14} \lor \neg \left(z \leq 2.1 \cdot 10^{+38}\right)\right):\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \end{array} \]

Alternative 4: 84.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -4.1 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-75}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-15}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (- z x))))
   (if (<= y -4.1e-48)
     t_0
     (if (<= y 3.1e-105)
       x
       (if (<= y 6.8e-75) (* y z) (if (<= y 4.6e-15) (* x (- 1.0 y)) t_0))))))
double code(double x, double y, double z) {
	double t_0 = y * (z - x);
	double tmp;
	if (y <= -4.1e-48) {
		tmp = t_0;
	} else if (y <= 3.1e-105) {
		tmp = x;
	} else if (y <= 6.8e-75) {
		tmp = y * z;
	} else if (y <= 4.6e-15) {
		tmp = x * (1.0 - 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 * (z - x)
    if (y <= (-4.1d-48)) then
        tmp = t_0
    else if (y <= 3.1d-105) then
        tmp = x
    else if (y <= 6.8d-75) then
        tmp = y * z
    else if (y <= 4.6d-15) then
        tmp = x * (1.0d0 - 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 * (z - x);
	double tmp;
	if (y <= -4.1e-48) {
		tmp = t_0;
	} else if (y <= 3.1e-105) {
		tmp = x;
	} else if (y <= 6.8e-75) {
		tmp = y * z;
	} else if (y <= 4.6e-15) {
		tmp = x * (1.0 - y);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z - x)
	tmp = 0
	if y <= -4.1e-48:
		tmp = t_0
	elif y <= 3.1e-105:
		tmp = x
	elif y <= 6.8e-75:
		tmp = y * z
	elif y <= 4.6e-15:
		tmp = x * (1.0 - y)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z - x))
	tmp = 0.0
	if (y <= -4.1e-48)
		tmp = t_0;
	elseif (y <= 3.1e-105)
		tmp = x;
	elseif (y <= 6.8e-75)
		tmp = Float64(y * z);
	elseif (y <= 4.6e-15)
		tmp = Float64(x * Float64(1.0 - y));
	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 <= -4.1e-48)
		tmp = t_0;
	elseif (y <= 3.1e-105)
		tmp = x;
	elseif (y <= 6.8e-75)
		tmp = y * z;
	elseif (y <= 4.6e-15)
		tmp = x * (1.0 - y);
	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, -4.1e-48], t$95$0, If[LessEqual[y, 3.1e-105], x, If[LessEqual[y, 6.8e-75], N[(y * z), $MachinePrecision], If[LessEqual[y, 4.6e-15], N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 3.1 \cdot 10^{-105}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 6.8 \cdot 10^{-75}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 4.6 \cdot 10^{-15}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.10000000000000014e-48 or 4.59999999999999981e-15 < y

    1. Initial program 100.0%

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

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

    if -4.10000000000000014e-48 < y < 3.10000000000000014e-105

    1. Initial program 100.0%

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

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

    if 3.10000000000000014e-105 < y < 6.8000000000000003e-75

    1. Initial program 100.0%

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

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

    if 6.8000000000000003e-75 < y < 4.59999999999999981e-15

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot y\right)} \]
    3. Step-by-step derivation
      1. mul-1-neg91.3%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-y\right)}\right) \]
      2. unsub-neg91.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.1 \cdot 10^{-48}:\\ \;\;\;\;y \cdot \left(z - x\right)\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.8 \cdot 10^{-75}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-15}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z - x\right)\\ \end{array} \]

Alternative 5: 60.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-14} \lor \neg \left(y \leq 9.5 \cdot 10^{-114} \lor \neg \left(y \leq 6.2 \cdot 10^{-76}\right) \land y \leq 1.25 \cdot 10^{-17}\right):\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.7e-14)
         (not (or (<= y 9.5e-114) (and (not (<= y 6.2e-76)) (<= y 1.25e-17)))))
   (* y z)
   x))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.7e-14) || !((y <= 9.5e-114) || (!(y <= 6.2e-76) && (y <= 1.25e-17)))) {
		tmp = y * z;
	} else {
		tmp = 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 <= (-3.7d-14)) .or. (.not. (y <= 9.5d-114) .or. (.not. (y <= 6.2d-76)) .and. (y <= 1.25d-17))) then
        tmp = y * z
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.7e-14) || !((y <= 9.5e-114) || (!(y <= 6.2e-76) && (y <= 1.25e-17)))) {
		tmp = y * z;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -3.7e-14) or not ((y <= 9.5e-114) or (not (y <= 6.2e-76) and (y <= 1.25e-17))):
		tmp = y * z
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -3.7e-14) || !((y <= 9.5e-114) || (!(y <= 6.2e-76) && (y <= 1.25e-17))))
		tmp = Float64(y * z);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -3.7e-14) || ~(((y <= 9.5e-114) || (~((y <= 6.2e-76)) && (y <= 1.25e-17)))))
		tmp = y * z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.7e-14], N[Not[Or[LessEqual[y, 9.5e-114], And[N[Not[LessEqual[y, 6.2e-76]], $MachinePrecision], LessEqual[y, 1.25e-17]]]], $MachinePrecision]], N[(y * z), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{-14} \lor \neg \left(y \leq 9.5 \cdot 10^{-114} \lor \neg \left(y \leq 6.2 \cdot 10^{-76}\right) \land y \leq 1.25 \cdot 10^{-17}\right):\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.70000000000000001e-14 or 9.49999999999999958e-114 < y < 6.19999999999999939e-76 or 1.25e-17 < y

    1. Initial program 100.0%

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

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

    if -3.70000000000000001e-14 < y < 9.49999999999999958e-114 or 6.19999999999999939e-76 < y < 1.25e-17

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-14} \lor \neg \left(y \leq 9.5 \cdot 10^{-114} \lor \neg \left(y \leq 6.2 \cdot 10^{-76}\right) \land y \leq 1.25 \cdot 10^{-17}\right):\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 6: 98.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 4.4 \cdot 10^{-13}\right):\\
\;\;\;\;y \cdot \left(z - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1 or 4.39999999999999993e-13 < y

    1. Initial program 100.0%

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

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

    if -1 < y < 4.39999999999999993e-13

    1. Initial program 100.0%

      \[x + y \cdot \left(z - x\right) \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto x + y \cdot \color{blue}{\left(z + \left(-x\right)\right)} \]
      2. distribute-rgt-in100.0%

        \[\leadsto x + \color{blue}{\left(z \cdot y + \left(-x\right) \cdot y\right)} \]
      3. fma-def100.0%

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(z, y, \left(-x\right) \cdot y\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto x + \color{blue}{\mathsf{fma}\left(z, y, \left(-x\right) \cdot y\right)} \]
    4. Taylor expanded in z around inf 99.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 4.4 \cdot 10^{-13}\right):\\ \;\;\;\;y \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]

Alternative 7: 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}
Derivation
  1. Initial program 100.0%

    \[x + y \cdot \left(z - x\right) \]
  2. Final simplification100.0%

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

Alternative 8: 35.9% accurate, 7.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return 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
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 100.0%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification34.9%

    \[\leadsto x \]

Reproduce

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