SynthBasics:oscSampleBasedAux from YampaSynth-0.2

Percentage Accurate: 100.0% → 100.0%
Time: 3.8s
Alternatives: 6
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 6 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.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 2: 61.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -6.5 \cdot 10^{+189}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{+122}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1.95 \cdot 10^{+68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-18}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+188}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (- x))))
   (if (<= y -6.5e+189)
     t_0
     (if (<= y -1.6e+122)
       (* y z)
       (if (<= y -1.95e+68)
         t_0
         (if (<= y -2.8e-18)
           (* y z)
           (if (<= y 1.35e-16) x (if (<= y 9.8e+188) (* y z) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = y * -x;
	double tmp;
	if (y <= -6.5e+189) {
		tmp = t_0;
	} else if (y <= -1.6e+122) {
		tmp = y * z;
	} else if (y <= -1.95e+68) {
		tmp = t_0;
	} else if (y <= -2.8e-18) {
		tmp = y * z;
	} else if (y <= 1.35e-16) {
		tmp = x;
	} else if (y <= 9.8e+188) {
		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 <= (-6.5d+189)) then
        tmp = t_0
    else if (y <= (-1.6d+122)) then
        tmp = y * z
    else if (y <= (-1.95d+68)) then
        tmp = t_0
    else if (y <= (-2.8d-18)) then
        tmp = y * z
    else if (y <= 1.35d-16) then
        tmp = x
    else if (y <= 9.8d+188) 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 <= -6.5e+189) {
		tmp = t_0;
	} else if (y <= -1.6e+122) {
		tmp = y * z;
	} else if (y <= -1.95e+68) {
		tmp = t_0;
	} else if (y <= -2.8e-18) {
		tmp = y * z;
	} else if (y <= 1.35e-16) {
		tmp = x;
	} else if (y <= 9.8e+188) {
		tmp = y * z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * -x
	tmp = 0
	if y <= -6.5e+189:
		tmp = t_0
	elif y <= -1.6e+122:
		tmp = y * z
	elif y <= -1.95e+68:
		tmp = t_0
	elif y <= -2.8e-18:
		tmp = y * z
	elif y <= 1.35e-16:
		tmp = x
	elif y <= 9.8e+188:
		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 <= -6.5e+189)
		tmp = t_0;
	elseif (y <= -1.6e+122)
		tmp = Float64(y * z);
	elseif (y <= -1.95e+68)
		tmp = t_0;
	elseif (y <= -2.8e-18)
		tmp = Float64(y * z);
	elseif (y <= 1.35e-16)
		tmp = x;
	elseif (y <= 9.8e+188)
		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 <= -6.5e+189)
		tmp = t_0;
	elseif (y <= -1.6e+122)
		tmp = y * z;
	elseif (y <= -1.95e+68)
		tmp = t_0;
	elseif (y <= -2.8e-18)
		tmp = y * z;
	elseif (y <= 1.35e-16)
		tmp = x;
	elseif (y <= 9.8e+188)
		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, -6.5e+189], t$95$0, If[LessEqual[y, -1.6e+122], N[(y * z), $MachinePrecision], If[LessEqual[y, -1.95e+68], t$95$0, If[LessEqual[y, -2.8e-18], N[(y * z), $MachinePrecision], If[LessEqual[y, 1.35e-16], x, If[LessEqual[y, 9.8e+188], N[(y * z), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -6.5 \cdot 10^{+189}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq -1.95 \cdot 10^{+68}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -2.8 \cdot 10^{-18}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-16}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 9.8 \cdot 10^{+188}:\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.50000000000000027e189 or -1.60000000000000006e122 < y < -1.95000000000000009e68 or 9.8e188 < y

    1. Initial program 100.0%

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

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

        \[\leadsto x + \color{blue}{\left(-x \cdot y\right)} \]
      2. distribute-lft-neg-out66.1%

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

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

      \[\leadsto x + \color{blue}{y \cdot \left(-x\right)} \]
    5. Taylor expanded in y around inf 66.1%

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
    6. Step-by-step derivation
      1. associate-*r*66.1%

        \[\leadsto \color{blue}{\left(-1 \cdot x\right) \cdot y} \]
      2. mul-1-neg66.1%

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

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

    if -6.50000000000000027e189 < y < -1.60000000000000006e122 or -1.95000000000000009e68 < y < -2.80000000000000012e-18 or 1.35e-16 < y < 9.8e188

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{y \cdot z} \]
    3. Taylor expanded in x around 0 71.0%

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

    if -2.80000000000000012e-18 < y < 1.35e-16

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{y \cdot z} \]
    3. Taylor expanded in x around inf 77.8%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification72.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+189}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -1.6 \cdot 10^{+122}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -1.95 \cdot 10^{+68}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-18}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+188}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]

Alternative 3: 75.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+189} \lor \neg \left(y \leq -5.6 \cdot 10^{+122}\right) \land \left(y \leq -1.9 \cdot 10^{+70} \lor \neg \left(y \leq 5.5 \cdot 10^{+182}\right)\right):\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -8.5e+189)
         (and (not (<= y -5.6e+122))
              (or (<= y -1.9e+70) (not (<= y 5.5e+182)))))
   (* y (- x))
   (+ x (* y z))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -8.5e+189) || (!(y <= -5.6e+122) && ((y <= -1.9e+70) || !(y <= 5.5e+182)))) {
		tmp = y * -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 <= (-8.5d+189)) .or. (.not. (y <= (-5.6d+122))) .and. (y <= (-1.9d+70)) .or. (.not. (y <= 5.5d+182))) then
        tmp = y * -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 <= -8.5e+189) || (!(y <= -5.6e+122) && ((y <= -1.9e+70) || !(y <= 5.5e+182)))) {
		tmp = y * -x;
	} else {
		tmp = x + (y * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -8.5e+189) or (not (y <= -5.6e+122) and ((y <= -1.9e+70) or not (y <= 5.5e+182))):
		tmp = y * -x
	else:
		tmp = x + (y * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -8.5e+189) || (!(y <= -5.6e+122) && ((y <= -1.9e+70) || !(y <= 5.5e+182))))
		tmp = Float64(y * Float64(-x));
	else
		tmp = Float64(x + Float64(y * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -8.5e+189) || (~((y <= -5.6e+122)) && ((y <= -1.9e+70) || ~((y <= 5.5e+182)))))
		tmp = y * -x;
	else
		tmp = x + (y * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e+189], And[N[Not[LessEqual[y, -5.6e+122]], $MachinePrecision], Or[LessEqual[y, -1.9e+70], N[Not[LessEqual[y, 5.5e+182]], $MachinePrecision]]]], N[(y * (-x)), $MachinePrecision], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{+189} \lor \neg \left(y \leq -5.6 \cdot 10^{+122}\right) \land \left(y \leq -1.9 \cdot 10^{+70} \lor \neg \left(y \leq 5.5 \cdot 10^{+182}\right)\right):\\
\;\;\;\;y \cdot \left(-x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.4999999999999998e189 or -5.5999999999999999e122 < y < -1.8999999999999999e70 or 5.49999999999999977e182 < y

    1. Initial program 100.0%

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

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

        \[\leadsto x + \color{blue}{\left(-x \cdot y\right)} \]
      2. distribute-lft-neg-out65.7%

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

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

      \[\leadsto x + \color{blue}{y \cdot \left(-x\right)} \]
    5. Taylor expanded in y around inf 65.7%

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot y\right)} \]
    6. Step-by-step derivation
      1. associate-*r*65.7%

        \[\leadsto \color{blue}{\left(-1 \cdot x\right) \cdot y} \]
      2. mul-1-neg65.7%

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

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

    if -8.4999999999999998e189 < y < -5.5999999999999999e122 or -1.8999999999999999e70 < y < 5.49999999999999977e182

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+189} \lor \neg \left(y \leq -5.6 \cdot 10^{+122}\right) \land \left(y \leq -1.9 \cdot 10^{+70} \lor \neg \left(y \leq 5.5 \cdot 10^{+182}\right)\right):\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]

Alternative 4: 86.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-84} \lor \neg \left(z \leq 6.5 \cdot 10^{-20}\right):\\
\;\;\;\;x + y \cdot z\\

\mathbf{else}:\\
\;\;\;\;x - x \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.95000000000000011e-84 or 6.50000000000000032e-20 < z

    1. Initial program 100.0%

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

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

    if -1.95000000000000011e-84 < z < 6.50000000000000032e-20

    1. Initial program 100.0%

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

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

        \[\leadsto x + \color{blue}{\left(-x \cdot y\right)} \]
      2. distribute-lft-neg-out90.2%

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

        \[\leadsto x + \color{blue}{y \cdot \left(-x\right)} \]
    4. Simplified90.2%

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

        \[\leadsto x + \color{blue}{\left(-x\right) \cdot y} \]
      2. distribute-lft-neg-out90.2%

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

        \[\leadsto \color{blue}{x - x \cdot y} \]
    6. Applied egg-rr90.2%

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

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

Alternative 5: 61.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{-17} \lor \neg \left(y \leq 5 \cdot 10^{-20}\right):\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.50000000000000003e-17 or 4.9999999999999999e-20 < y

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{y \cdot z} \]
    3. Taylor expanded in x around 0 55.2%

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

    if -1.50000000000000003e-17 < y < 4.9999999999999999e-20

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{y \cdot z} \]
    3. Taylor expanded in x around inf 77.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-17} \lor \neg \left(y \leq 5 \cdot 10^{-20}\right):\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 6: 36.0% 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 z around inf 75.4%

    \[\leadsto x + \color{blue}{y \cdot z} \]
  3. Taylor expanded in x around inf 36.0%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification36.0%

    \[\leadsto x \]

Reproduce

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