SynthBasics:oscSampleBasedAux from YampaSynth-0.2

Percentage Accurate: 100.0% → 100.0%
Time: 5.1s
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. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto x + y \cdot \left(z - x\right) \]
  4. Add Preprocessing

Alternative 2: 59.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.9 \cdot 10^{+158}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -220000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -0.0066:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{-125}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+15} \lor \neg \left(y \leq 2.85 \cdot 10^{+116}\right) \land y \leq 9 \cdot 10^{+167}:\\ \;\;\;\;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.9e+158)
     (* y z)
     (if (<= y -220000000000.0)
       t_0
       (if (<= y -0.0066)
         (* y z)
         (if (<= y 1.16e-125)
           x
           (if (or (<= y 7e+15) (and (not (<= y 2.85e+116)) (<= y 9e+167)))
             (* y z)
             t_0)))))))
double code(double x, double y, double z) {
	double t_0 = y * -x;
	double tmp;
	if (y <= -1.9e+158) {
		tmp = y * z;
	} else if (y <= -220000000000.0) {
		tmp = t_0;
	} else if (y <= -0.0066) {
		tmp = y * z;
	} else if (y <= 1.16e-125) {
		tmp = x;
	} else if ((y <= 7e+15) || (!(y <= 2.85e+116) && (y <= 9e+167))) {
		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.9d+158)) then
        tmp = y * z
    else if (y <= (-220000000000.0d0)) then
        tmp = t_0
    else if (y <= (-0.0066d0)) then
        tmp = y * z
    else if (y <= 1.16d-125) then
        tmp = x
    else if ((y <= 7d+15) .or. (.not. (y <= 2.85d+116)) .and. (y <= 9d+167)) 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.9e+158) {
		tmp = y * z;
	} else if (y <= -220000000000.0) {
		tmp = t_0;
	} else if (y <= -0.0066) {
		tmp = y * z;
	} else if (y <= 1.16e-125) {
		tmp = x;
	} else if ((y <= 7e+15) || (!(y <= 2.85e+116) && (y <= 9e+167))) {
		tmp = y * z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * -x
	tmp = 0
	if y <= -1.9e+158:
		tmp = y * z
	elif y <= -220000000000.0:
		tmp = t_0
	elif y <= -0.0066:
		tmp = y * z
	elif y <= 1.16e-125:
		tmp = x
	elif (y <= 7e+15) or (not (y <= 2.85e+116) and (y <= 9e+167)):
		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.9e+158)
		tmp = Float64(y * z);
	elseif (y <= -220000000000.0)
		tmp = t_0;
	elseif (y <= -0.0066)
		tmp = Float64(y * z);
	elseif (y <= 1.16e-125)
		tmp = x;
	elseif ((y <= 7e+15) || (!(y <= 2.85e+116) && (y <= 9e+167)))
		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.9e+158)
		tmp = y * z;
	elseif (y <= -220000000000.0)
		tmp = t_0;
	elseif (y <= -0.0066)
		tmp = y * z;
	elseif (y <= 1.16e-125)
		tmp = x;
	elseif ((y <= 7e+15) || (~((y <= 2.85e+116)) && (y <= 9e+167)))
		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.9e+158], N[(y * z), $MachinePrecision], If[LessEqual[y, -220000000000.0], t$95$0, If[LessEqual[y, -0.0066], N[(y * z), $MachinePrecision], If[LessEqual[y, 1.16e-125], x, If[Or[LessEqual[y, 7e+15], And[N[Not[LessEqual[y, 2.85e+116]], $MachinePrecision], LessEqual[y, 9e+167]]], 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.9 \cdot 10^{+158}:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq -220000000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -0.0066:\\
\;\;\;\;y \cdot z\\

\mathbf{elif}\;y \leq 1.16 \cdot 10^{-125}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 7 \cdot 10^{+15} \lor \neg \left(y \leq 2.85 \cdot 10^{+116}\right) \land y \leq 9 \cdot 10^{+167}:\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8999999999999999e158 or -2.2e11 < y < -0.0066 or 1.15999999999999995e-125 < y < 7e15 or 2.84999999999999991e116 < y < 8.9999999999999998e167

    1. Initial program 100.0%

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

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

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

    if -1.8999999999999999e158 < y < -2.2e11 or 7e15 < y < 2.84999999999999991e116 or 8.9999999999999998e167 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -0.0066 < y < 1.15999999999999995e-125

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+158}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -220000000000:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -0.0066:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{-125}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+15} \lor \neg \left(y \leq 2.85 \cdot 10^{+116}\right) \land y \leq 9 \cdot 10^{+167}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + y \cdot z\\ t_1 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -7.5 \cdot 10^{+149}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -900000000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{+116} \lor \neg \left(y \leq 1.15 \cdot 10^{+168}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (* y z))) (t_1 (* y (- x))))
   (if (<= y -7.5e+149)
     t_0
     (if (<= y -900000000000.0)
       t_1
       (if (<= y 6.5e+15)
         t_0
         (if (or (<= y 1.22e+116) (not (<= y 1.15e+168))) t_1 (* y z)))))))
double code(double x, double y, double z) {
	double t_0 = x + (y * z);
	double t_1 = y * -x;
	double tmp;
	if (y <= -7.5e+149) {
		tmp = t_0;
	} else if (y <= -900000000000.0) {
		tmp = t_1;
	} else if (y <= 6.5e+15) {
		tmp = t_0;
	} else if ((y <= 1.22e+116) || !(y <= 1.15e+168)) {
		tmp = t_1;
	} 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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x + (y * z)
    t_1 = y * -x
    if (y <= (-7.5d+149)) then
        tmp = t_0
    else if (y <= (-900000000000.0d0)) then
        tmp = t_1
    else if (y <= 6.5d+15) then
        tmp = t_0
    else if ((y <= 1.22d+116) .or. (.not. (y <= 1.15d+168))) then
        tmp = t_1
    else
        tmp = y * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x + (y * z);
	double t_1 = y * -x;
	double tmp;
	if (y <= -7.5e+149) {
		tmp = t_0;
	} else if (y <= -900000000000.0) {
		tmp = t_1;
	} else if (y <= 6.5e+15) {
		tmp = t_0;
	} else if ((y <= 1.22e+116) || !(y <= 1.15e+168)) {
		tmp = t_1;
	} else {
		tmp = y * z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x + (y * z)
	t_1 = y * -x
	tmp = 0
	if y <= -7.5e+149:
		tmp = t_0
	elif y <= -900000000000.0:
		tmp = t_1
	elif y <= 6.5e+15:
		tmp = t_0
	elif (y <= 1.22e+116) or not (y <= 1.15e+168):
		tmp = t_1
	else:
		tmp = y * z
	return tmp
function code(x, y, z)
	t_0 = Float64(x + Float64(y * z))
	t_1 = Float64(y * Float64(-x))
	tmp = 0.0
	if (y <= -7.5e+149)
		tmp = t_0;
	elseif (y <= -900000000000.0)
		tmp = t_1;
	elseif (y <= 6.5e+15)
		tmp = t_0;
	elseif ((y <= 1.22e+116) || !(y <= 1.15e+168))
		tmp = t_1;
	else
		tmp = Float64(y * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x + (y * z);
	t_1 = y * -x;
	tmp = 0.0;
	if (y <= -7.5e+149)
		tmp = t_0;
	elseif (y <= -900000000000.0)
		tmp = t_1;
	elseif (y <= 6.5e+15)
		tmp = t_0;
	elseif ((y <= 1.22e+116) || ~((y <= 1.15e+168)))
		tmp = t_1;
	else
		tmp = y * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * (-x)), $MachinePrecision]}, If[LessEqual[y, -7.5e+149], t$95$0, If[LessEqual[y, -900000000000.0], t$95$1, If[LessEqual[y, 6.5e+15], t$95$0, If[Or[LessEqual[y, 1.22e+116], N[Not[LessEqual[y, 1.15e+168]], $MachinePrecision]], t$95$1, N[(y * z), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x + y \cdot z\\
t_1 := y \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{+149}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -900000000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.22 \cdot 10^{+116} \lor \neg \left(y \leq 1.15 \cdot 10^{+168}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.50000000000000031e149 or -9e11 < y < 6.5e15

    1. Initial program 100.0%

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

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

    if -7.50000000000000031e149 < y < -9e11 or 6.5e15 < y < 1.21999999999999993e116 or 1.15e168 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 1.21999999999999993e116 < y < 1.15e168

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+149}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq -900000000000:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+15}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{+116} \lor \neg \left(y \leq 1.15 \cdot 10^{+168}\right):\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.28 \cdot 10^{-17} \lor \neg \left(x \leq 2.05 \cdot 10^{+108}\right):\\
\;\;\;\;x - x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.28e-17 or 2.05e108 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x - x \cdot y} \]
    7. Applied egg-rr92.3%

      \[\leadsto \color{blue}{x - x \cdot y} \]

    if -1.28e-17 < x < 2.05e108

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.28 \cdot 10^{-17} \lor \neg \left(x \leq 2.05 \cdot 10^{+108}\right):\\ \;\;\;\;x - x \cdot y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 59.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0066 \lor \neg \left(y \leq 1.16 \cdot 10^{-125}\right):\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.0066 or 1.15999999999999995e-125 < y

    1. Initial program 100.0%

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

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

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

    if -0.0066 < y < 1.15999999999999995e-125

    1. Initial program 100.0%

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

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

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

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

Alternative 6: 37.2% 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. Add Preprocessing
  3. Taylor expanded in z around inf 71.8%

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification32.4%

    \[\leadsto x \]
  6. Add Preprocessing

Reproduce

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