SynthBasics:oscSampleBasedAux from YampaSynth-0.2

Percentage Accurate: 100.0% → 100.0%
Time: 5.0s
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: 62.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -3.6 \cdot 10^{+124}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -6.3 \cdot 10^{+29}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-9}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 270000000000 \lor \neg \left(y \leq 2.6 \cdot 10^{+242}\right) \land y \leq 1.15 \cdot 10^{+303}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (- x))))
   (if (<= y -3.6e+124)
     (* y z)
     (if (<= y -6.3e+29)
       t_0
       (if (<= y -1e-9)
         (* y z)
         (if (<= y 1.7e-10)
           x
           (if (or (<= y 270000000000.0)
                   (and (not (<= y 2.6e+242)) (<= y 1.15e+303)))
             (* y z)
             t_0)))))))
double code(double x, double y, double z) {
	double t_0 = y * -x;
	double tmp;
	if (y <= -3.6e+124) {
		tmp = y * z;
	} else if (y <= -6.3e+29) {
		tmp = t_0;
	} else if (y <= -1e-9) {
		tmp = y * z;
	} else if (y <= 1.7e-10) {
		tmp = x;
	} else if ((y <= 270000000000.0) || (!(y <= 2.6e+242) && (y <= 1.15e+303))) {
		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 <= (-3.6d+124)) then
        tmp = y * z
    else if (y <= (-6.3d+29)) then
        tmp = t_0
    else if (y <= (-1d-9)) then
        tmp = y * z
    else if (y <= 1.7d-10) then
        tmp = x
    else if ((y <= 270000000000.0d0) .or. (.not. (y <= 2.6d+242)) .and. (y <= 1.15d+303)) 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 <= -3.6e+124) {
		tmp = y * z;
	} else if (y <= -6.3e+29) {
		tmp = t_0;
	} else if (y <= -1e-9) {
		tmp = y * z;
	} else if (y <= 1.7e-10) {
		tmp = x;
	} else if ((y <= 270000000000.0) || (!(y <= 2.6e+242) && (y <= 1.15e+303))) {
		tmp = y * z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * -x
	tmp = 0
	if y <= -3.6e+124:
		tmp = y * z
	elif y <= -6.3e+29:
		tmp = t_0
	elif y <= -1e-9:
		tmp = y * z
	elif y <= 1.7e-10:
		tmp = x
	elif (y <= 270000000000.0) or (not (y <= 2.6e+242) and (y <= 1.15e+303)):
		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 <= -3.6e+124)
		tmp = Float64(y * z);
	elseif (y <= -6.3e+29)
		tmp = t_0;
	elseif (y <= -1e-9)
		tmp = Float64(y * z);
	elseif (y <= 1.7e-10)
		tmp = x;
	elseif ((y <= 270000000000.0) || (!(y <= 2.6e+242) && (y <= 1.15e+303)))
		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 <= -3.6e+124)
		tmp = y * z;
	elseif (y <= -6.3e+29)
		tmp = t_0;
	elseif (y <= -1e-9)
		tmp = y * z;
	elseif (y <= 1.7e-10)
		tmp = x;
	elseif ((y <= 270000000000.0) || (~((y <= 2.6e+242)) && (y <= 1.15e+303)))
		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, -3.6e+124], N[(y * z), $MachinePrecision], If[LessEqual[y, -6.3e+29], t$95$0, If[LessEqual[y, -1e-9], N[(y * z), $MachinePrecision], If[LessEqual[y, 1.7e-10], x, If[Or[LessEqual[y, 270000000000.0], And[N[Not[LessEqual[y, 2.6e+242]], $MachinePrecision], LessEqual[y, 1.15e+303]]], N[(y * z), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -6.3 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -1 \cdot 10^{-9}:\\
\;\;\;\;y \cdot z\\

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

\mathbf{elif}\;y \leq 270000000000 \lor \neg \left(y \leq 2.6 \cdot 10^{+242}\right) \land y \leq 1.15 \cdot 10^{+303}:\\
\;\;\;\;y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.59999999999999986e124 or -6.2999999999999998e29 < y < -1.00000000000000006e-9 or 1.70000000000000007e-10 < y < 2.7e11 or 2.5999999999999998e242 < y < 1.15e303

    1. Initial program 100.0%

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

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

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

    if -3.59999999999999986e124 < y < -6.2999999999999998e29 or 2.7e11 < y < 2.5999999999999998e242 or 1.15e303 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000006e-9 < y < 1.70000000000000007e-10

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+124}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -6.3 \cdot 10^{+29}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-9}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.7 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 270000000000 \lor \neg \left(y \leq 2.6 \cdot 10^{+242}\right) \land y \leq 1.15 \cdot 10^{+303}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 77.2% 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 -1.15 \cdot 10^{+125}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{+30}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 950000000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{+242} \lor \neg \left(y \leq 4.2 \cdot 10^{+301}\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 -1.15e+125)
     t_0
     (if (<= y -2.7e+30)
       t_1
       (if (<= y 950000000000.0)
         t_0
         (if (or (<= y 2.75e+242) (not (<= y 4.2e+301))) 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 <= -1.15e+125) {
		tmp = t_0;
	} else if (y <= -2.7e+30) {
		tmp = t_1;
	} else if (y <= 950000000000.0) {
		tmp = t_0;
	} else if ((y <= 2.75e+242) || !(y <= 4.2e+301)) {
		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 <= (-1.15d+125)) then
        tmp = t_0
    else if (y <= (-2.7d+30)) then
        tmp = t_1
    else if (y <= 950000000000.0d0) then
        tmp = t_0
    else if ((y <= 2.75d+242) .or. (.not. (y <= 4.2d+301))) 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 <= -1.15e+125) {
		tmp = t_0;
	} else if (y <= -2.7e+30) {
		tmp = t_1;
	} else if (y <= 950000000000.0) {
		tmp = t_0;
	} else if ((y <= 2.75e+242) || !(y <= 4.2e+301)) {
		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 <= -1.15e+125:
		tmp = t_0
	elif y <= -2.7e+30:
		tmp = t_1
	elif y <= 950000000000.0:
		tmp = t_0
	elif (y <= 2.75e+242) or not (y <= 4.2e+301):
		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 <= -1.15e+125)
		tmp = t_0;
	elseif (y <= -2.7e+30)
		tmp = t_1;
	elseif (y <= 950000000000.0)
		tmp = t_0;
	elseif ((y <= 2.75e+242) || !(y <= 4.2e+301))
		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 <= -1.15e+125)
		tmp = t_0;
	elseif (y <= -2.7e+30)
		tmp = t_1;
	elseif (y <= 950000000000.0)
		tmp = t_0;
	elseif ((y <= 2.75e+242) || ~((y <= 4.2e+301)))
		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, -1.15e+125], t$95$0, If[LessEqual[y, -2.7e+30], t$95$1, If[LessEqual[y, 950000000000.0], t$95$0, If[Or[LessEqual[y, 2.75e+242], N[Not[LessEqual[y, 4.2e+301]], $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 -1.15 \cdot 10^{+125}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -2.7 \cdot 10^{+30}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 950000000000:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 2.75 \cdot 10^{+242} \lor \neg \left(y \leq 4.2 \cdot 10^{+301}\right):\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.15000000000000006e125 or -2.6999999999999999e30 < y < 9.5e11

    1. Initial program 100.0%

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

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

    if -1.15000000000000006e125 < y < -2.6999999999999999e30 or 9.5e11 < y < 2.75000000000000011e242 or 4.1999999999999999e301 < y

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if 2.75000000000000011e242 < y < 4.1999999999999999e301

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.15 \cdot 10^{+125}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{+30}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq 950000000000:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 2.75 \cdot 10^{+242} \lor \neg \left(y \leq 4.2 \cdot 10^{+301}\right):\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.2% accurate, 0.5× speedup?

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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -7.49999999999999934e78 < x < 1.4e-70

    1. Initial program 100.0%

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

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

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

Alternative 5: 61.5% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.49999999999999995e-10 or 2.45000000000000006e-17 < y

    1. Initial program 100.0%

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

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

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

    if -7.49999999999999995e-10 < y < 2.45000000000000006e-17

    1. Initial program 100.0%

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

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

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

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

Alternative 6: 36.7% 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 74.7%

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

    \[\leadsto \color{blue}{x} \]
  5. Final simplification38.6%

    \[\leadsto x \]
  6. Add Preprocessing

Reproduce

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