Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1

Percentage Accurate: 100.0% → 100.0%
Time: 5.6s
Alternatives: 8
Speedup: 0.1×

Specification

?
\[\begin{array}{l} \\ \left(\frac{x}{2} + y \cdot x\right) + z \end{array} \]
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z):
	return ((x / 2.0) + (y * x)) + z
function code(x, y, z)
	return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z)
end
function tmp = code(x, y, z)
	tmp = ((x / 2.0) + (y * x)) + z;
end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{x}{2} + y \cdot x\right) + z
\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} \\ \left(\frac{x}{2} + y \cdot x\right) + z \end{array} \]
(FPCore (x y z) :precision binary64 (+ (+ (/ x 2.0) (* y x)) z))
double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = ((x / 2.0d0) + (y * x)) + z
end function
public static double code(double x, double y, double z) {
	return ((x / 2.0) + (y * x)) + z;
}
def code(x, y, z):
	return ((x / 2.0) + (y * x)) + z
function code(x, y, z)
	return Float64(Float64(Float64(x / 2.0) + Float64(y * x)) + z)
end
function tmp = code(x, y, z)
	tmp = ((x / 2.0) + (y * x)) + z;
end
code[x_, y_, z_] := N[(N[(N[(x / 2.0), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{x}{2} + y \cdot x\right) + z
\end{array}

Alternative 1: 100.0% accurate, 0.1× speedup?

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

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

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

      \[\leadsto \color{blue}{\left(y \cdot x + \frac{x}{2}\right)} + z \]
    2. remove-double-neg100.0%

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

      \[\leadsto \left(y \cdot x + \left(-\color{blue}{\frac{-x}{2}}\right)\right) + z \]
    4. sub-neg100.0%

      \[\leadsto \color{blue}{\left(y \cdot x - \frac{-x}{2}\right)} + z \]
    5. neg-mul-1100.0%

      \[\leadsto \left(y \cdot x - \frac{\color{blue}{-1 \cdot x}}{2}\right) + z \]
    6. associate-/l*99.9%

      \[\leadsto \left(y \cdot x - \color{blue}{\frac{-1}{\frac{2}{x}}}\right) + z \]
    7. associate-/r/100.0%

      \[\leadsto \left(y \cdot x - \color{blue}{\frac{-1}{2} \cdot x}\right) + z \]
    8. distribute-rgt-out--100.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y - \frac{-1}{2}, z\right)} \]
    10. sub-neg100.0%

      \[\leadsto \mathsf{fma}\left(x, \color{blue}{y + \left(-\frac{-1}{2}\right)}, z\right) \]
    11. metadata-eval100.0%

      \[\leadsto \mathsf{fma}\left(x, y + \left(-\color{blue}{-0.5}\right), z\right) \]
    12. metadata-eval100.0%

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

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

    \[\leadsto \mathsf{fma}\left(x, y + 0.5, z\right) \]
  6. Add Preprocessing

Alternative 2: 61.6% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -255000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -2.65 \cdot 10^{-95}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-148}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-220}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-245}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-187}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{-53}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+24}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -255000000000.0)
   (* x y)
   (if (<= y -2.65e-95)
     z
     (if (<= y -1.8e-148)
       (* x 0.5)
       (if (<= y -1.42e-220)
         z
         (if (<= y 8.5e-245)
           (* x 0.5)
           (if (<= y 1.95e-187)
             z
             (if (<= y 1.12e-53)
               (* x 0.5)
               (if (<= y 1.35e+24) z (* x y))))))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -255000000000.0) {
		tmp = x * y;
	} else if (y <= -2.65e-95) {
		tmp = z;
	} else if (y <= -1.8e-148) {
		tmp = x * 0.5;
	} else if (y <= -1.42e-220) {
		tmp = z;
	} else if (y <= 8.5e-245) {
		tmp = x * 0.5;
	} else if (y <= 1.95e-187) {
		tmp = z;
	} else if (y <= 1.12e-53) {
		tmp = x * 0.5;
	} else if (y <= 1.35e+24) {
		tmp = z;
	} else {
		tmp = 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 (y <= (-255000000000.0d0)) then
        tmp = x * y
    else if (y <= (-2.65d-95)) then
        tmp = z
    else if (y <= (-1.8d-148)) then
        tmp = x * 0.5d0
    else if (y <= (-1.42d-220)) then
        tmp = z
    else if (y <= 8.5d-245) then
        tmp = x * 0.5d0
    else if (y <= 1.95d-187) then
        tmp = z
    else if (y <= 1.12d-53) then
        tmp = x * 0.5d0
    else if (y <= 1.35d+24) then
        tmp = z
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -255000000000.0) {
		tmp = x * y;
	} else if (y <= -2.65e-95) {
		tmp = z;
	} else if (y <= -1.8e-148) {
		tmp = x * 0.5;
	} else if (y <= -1.42e-220) {
		tmp = z;
	} else if (y <= 8.5e-245) {
		tmp = x * 0.5;
	} else if (y <= 1.95e-187) {
		tmp = z;
	} else if (y <= 1.12e-53) {
		tmp = x * 0.5;
	} else if (y <= 1.35e+24) {
		tmp = z;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -255000000000.0:
		tmp = x * y
	elif y <= -2.65e-95:
		tmp = z
	elif y <= -1.8e-148:
		tmp = x * 0.5
	elif y <= -1.42e-220:
		tmp = z
	elif y <= 8.5e-245:
		tmp = x * 0.5
	elif y <= 1.95e-187:
		tmp = z
	elif y <= 1.12e-53:
		tmp = x * 0.5
	elif y <= 1.35e+24:
		tmp = z
	else:
		tmp = x * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -255000000000.0)
		tmp = Float64(x * y);
	elseif (y <= -2.65e-95)
		tmp = z;
	elseif (y <= -1.8e-148)
		tmp = Float64(x * 0.5);
	elseif (y <= -1.42e-220)
		tmp = z;
	elseif (y <= 8.5e-245)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.95e-187)
		tmp = z;
	elseif (y <= 1.12e-53)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.35e+24)
		tmp = z;
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -255000000000.0)
		tmp = x * y;
	elseif (y <= -2.65e-95)
		tmp = z;
	elseif (y <= -1.8e-148)
		tmp = x * 0.5;
	elseif (y <= -1.42e-220)
		tmp = z;
	elseif (y <= 8.5e-245)
		tmp = x * 0.5;
	elseif (y <= 1.95e-187)
		tmp = z;
	elseif (y <= 1.12e-53)
		tmp = x * 0.5;
	elseif (y <= 1.35e+24)
		tmp = z;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -255000000000.0], N[(x * y), $MachinePrecision], If[LessEqual[y, -2.65e-95], z, If[LessEqual[y, -1.8e-148], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, -1.42e-220], z, If[LessEqual[y, 8.5e-245], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.95e-187], z, If[LessEqual[y, 1.12e-53], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.35e+24], z, N[(x * y), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -255000000000:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq -2.65 \cdot 10^{-95}:\\
\;\;\;\;z\\

\mathbf{elif}\;y \leq -1.8 \cdot 10^{-148}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq -1.42 \cdot 10^{-220}:\\
\;\;\;\;z\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{-245}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 1.95 \cdot 10^{-187}:\\
\;\;\;\;z\\

\mathbf{elif}\;y \leq 1.12 \cdot 10^{-53}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{+24}:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.55e11 or 1.35e24 < y

    1. Initial program 100.0%

      \[\left(\frac{x}{2} + y \cdot x\right) + z \]
    2. Step-by-step derivation
      1. associate-+l+100.0%

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

        \[\leadsto \frac{x}{2} + \left(\color{blue}{x \cdot y} + z\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} + \left(x \cdot y + z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 79.4%

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

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

      \[\leadsto \color{blue}{x \cdot \left(y + 0.5\right)} \]
    8. Taylor expanded in y around inf 79.4%

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

    if -2.55e11 < y < -2.6499999999999999e-95 or -1.7999999999999999e-148 < y < -1.4200000000000001e-220 or 8.50000000000000022e-245 < y < 1.9499999999999999e-187 or 1.12000000000000008e-53 < y < 1.35e24

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
      2. remove-double-neg100.0%

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

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

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

        \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
      6. unsub-neg100.0%

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

        \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
      8. unsub-neg100.0%

        \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
      9. neg-mul-1100.0%

        \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
      10. associate-/l*99.9%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
      11. associate-/r/100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
      12. distribute-rgt-out--100.0%

        \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 69.4%

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

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

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

      \[\leadsto z - \color{blue}{\left(-x\right) \cdot y} \]
    8. Taylor expanded in z around inf 67.2%

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

    if -2.6499999999999999e-95 < y < -1.7999999999999999e-148 or -1.4200000000000001e-220 < y < 8.50000000000000022e-245 or 1.9499999999999999e-187 < y < 1.12000000000000008e-53

    1. Initial program 100.0%

      \[\left(\frac{x}{2} + y \cdot x\right) + z \]
    2. Step-by-step derivation
      1. associate-+l+100.0%

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

        \[\leadsto \frac{x}{2} + \left(\color{blue}{x \cdot y} + z\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} + \left(x \cdot y + z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 67.8%

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

        \[\leadsto x \cdot \color{blue}{\left(y + 0.5\right)} \]
    7. Simplified67.8%

      \[\leadsto \color{blue}{x \cdot \left(y + 0.5\right)} \]
    8. Taylor expanded in y around 0 67.8%

      \[\leadsto \color{blue}{0.5 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative67.8%

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified67.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -255000000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -2.65 \cdot 10^{-95}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -1.8 \cdot 10^{-148}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-220}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-245}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-187}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{-53}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+24}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.7% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-26} \lor \neg \left(x \leq -5.2 \cdot 10^{-98} \lor \neg \left(x \leq -7.2 \cdot 10^{-145}\right) \land x \leq 1.08 \cdot 10^{-122}\right):\\
\;\;\;\;x \cdot \left(y + 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.0000000000000001e-26 or -5.20000000000000027e-98 < x < -7.2000000000000001e-145 or 1.08e-122 < x

    1. Initial program 100.0%

      \[\left(\frac{x}{2} + y \cdot x\right) + z \]
    2. Step-by-step derivation
      1. associate-+l+100.0%

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

        \[\leadsto \frac{x}{2} + \left(\color{blue}{x \cdot y} + z\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} + \left(x \cdot y + z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 84.6%

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

        \[\leadsto x \cdot \color{blue}{\left(y + 0.5\right)} \]
    7. Simplified84.6%

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

    if -2.0000000000000001e-26 < x < -5.20000000000000027e-98 or -7.2000000000000001e-145 < x < 1.08e-122

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
      2. remove-double-neg100.0%

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

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

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

        \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
      6. unsub-neg100.0%

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

        \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
      8. unsub-neg100.0%

        \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
      9. neg-mul-1100.0%

        \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
      10. associate-/l*100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
      11. associate-/r/100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
      12. distribute-rgt-out--100.0%

        \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 91.2%

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

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

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

      \[\leadsto z - \color{blue}{\left(-x\right) \cdot y} \]
    8. Taylor expanded in z around inf 74.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-26} \lor \neg \left(x \leq -5.2 \cdot 10^{-98} \lor \neg \left(x \leq -7.2 \cdot 10^{-145}\right) \land x \leq 1.08 \cdot 10^{-122}\right):\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+15} \lor \neg \left(x \leq 2.6 \cdot 10^{-54}\right):\\
\;\;\;\;x \cdot \left(y + 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.1e15 or 2.60000000000000002e-54 < x

    1. Initial program 100.0%

      \[\left(\frac{x}{2} + y \cdot x\right) + z \]
    2. Step-by-step derivation
      1. associate-+l+100.0%

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

        \[\leadsto \frac{x}{2} + \left(\color{blue}{x \cdot y} + z\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} + \left(x \cdot y + z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 86.8%

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

        \[\leadsto x \cdot \color{blue}{\left(y + 0.5\right)} \]
    7. Simplified86.8%

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

    if -3.1e15 < x < 2.60000000000000002e-54

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
      2. remove-double-neg100.0%

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

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

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

        \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
      6. unsub-neg100.0%

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

        \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
      8. unsub-neg100.0%

        \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
      9. neg-mul-1100.0%

        \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
      10. associate-/l*100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
      11. associate-/r/100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
      12. distribute-rgt-out--100.0%

        \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 88.6%

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

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

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

      \[\leadsto z - \color{blue}{\left(-x\right) \cdot y} \]
    8. Step-by-step derivation
      1. cancel-sign-sub88.6%

        \[\leadsto \color{blue}{z + x \cdot y} \]
      2. +-commutative88.6%

        \[\leadsto \color{blue}{x \cdot y + z} \]
    9. Applied egg-rr88.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{+15} \lor \neg \left(x \leq 2.6 \cdot 10^{-54}\right):\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -100000 \lor \neg \left(y \leq 0.5\right):\\
\;\;\;\;z + x \cdot y\\

\mathbf{else}:\\
\;\;\;\;z - x \cdot -0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1e5 or 0.5 < y

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
      2. remove-double-neg100.0%

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

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

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

        \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
      6. unsub-neg100.0%

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

        \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
      8. unsub-neg100.0%

        \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
      9. neg-mul-1100.0%

        \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
      10. associate-/l*100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
      11. associate-/r/100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
      12. distribute-rgt-out--100.0%

        \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 99.5%

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

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

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

      \[\leadsto z - \color{blue}{\left(-x\right) \cdot y} \]
    8. Step-by-step derivation
      1. cancel-sign-sub99.5%

        \[\leadsto \color{blue}{z + x \cdot y} \]
      2. +-commutative99.5%

        \[\leadsto \color{blue}{x \cdot y + z} \]
    9. Applied egg-rr99.5%

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

    if -1e5 < y < 0.5

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
      2. remove-double-neg100.0%

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

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

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

        \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
      6. unsub-neg100.0%

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

        \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
      8. unsub-neg100.0%

        \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
      9. neg-mul-1100.0%

        \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
      10. associate-/l*99.9%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
      11. associate-/r/100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
      12. distribute-rgt-out--100.0%

        \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 98.0%

      \[\leadsto z - \color{blue}{-0.5 \cdot x} \]
    6. Step-by-step derivation
      1. *-commutative98.0%

        \[\leadsto z - \color{blue}{x \cdot -0.5} \]
    7. Simplified98.0%

      \[\leadsto z - \color{blue}{x \cdot -0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.7%

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

Alternative 6: 49.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -12500 \lor \neg \left(x \leq 3.5 \cdot 10^{-41}\right):\\
\;\;\;\;x \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -12500 or 3.5e-41 < x

    1. Initial program 100.0%

      \[\left(\frac{x}{2} + y \cdot x\right) + z \]
    2. Step-by-step derivation
      1. associate-+l+100.0%

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

        \[\leadsto \frac{x}{2} + \left(\color{blue}{x \cdot y} + z\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{x}{2} + \left(x \cdot y + z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 87.4%

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

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

      \[\leadsto \color{blue}{x \cdot \left(y + 0.5\right)} \]
    8. Taylor expanded in y around 0 42.5%

      \[\leadsto \color{blue}{0.5 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative42.5%

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified42.5%

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

    if -12500 < x < 3.5e-41

    1. Initial program 100.0%

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

        \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
      2. remove-double-neg100.0%

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

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

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

        \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
      6. unsub-neg100.0%

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

        \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
      8. unsub-neg100.0%

        \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
      9. neg-mul-1100.0%

        \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
      10. associate-/l*100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
      11. associate-/r/100.0%

        \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
      12. distribute-rgt-out--100.0%

        \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
      13. metadata-eval100.0%

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

      \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 87.9%

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

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

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

      \[\leadsto z - \color{blue}{\left(-x\right) \cdot y} \]
    8. Taylor expanded in z around inf 62.7%

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

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

Alternative 7: 100.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ z + x \cdot \left(y - -0.5\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ z (* x (- y -0.5))))
double code(double x, double y, double z) {
	return z + (x * (y - -0.5));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = z + (x * (y - (-0.5d0)))
end function
public static double code(double x, double y, double z) {
	return z + (x * (y - -0.5));
}
def code(x, y, z):
	return z + (x * (y - -0.5))
function code(x, y, z)
	return Float64(z + Float64(x * Float64(y - -0.5)))
end
function tmp = code(x, y, z)
	tmp = z + (x * (y - -0.5));
end
code[x_, y_, z_] := N[(z + N[(x * N[(y - -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
z + x \cdot \left(y - -0.5\right)
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
    2. remove-double-neg100.0%

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

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

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

      \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
    6. unsub-neg100.0%

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

      \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
    8. unsub-neg100.0%

      \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
    9. neg-mul-1100.0%

      \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
    10. associate-/l*99.9%

      \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
    11. associate-/r/100.0%

      \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
    12. distribute-rgt-out--100.0%

      \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
    13. metadata-eval100.0%

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

    \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
  4. Add Preprocessing
  5. Final simplification100.0%

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

Alternative 8: 40.3% accurate, 9.0× speedup?

\[\begin{array}{l} \\ z \end{array} \]
(FPCore (x y z) :precision binary64 z)
double code(double x, double y, double z) {
	return z;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = z
end function
public static double code(double x, double y, double z) {
	return z;
}
def code(x, y, z):
	return z
function code(x, y, z)
	return z
end
function tmp = code(x, y, z)
	tmp = z;
end
code[x_, y_, z_] := z
\begin{array}{l}

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

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

      \[\leadsto \color{blue}{z + \left(\frac{x}{2} + y \cdot x\right)} \]
    2. remove-double-neg100.0%

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

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

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

      \[\leadsto z + \left(-\left(\frac{-x}{2} + \color{blue}{y \cdot \left(-x\right)}\right)\right) \]
    6. unsub-neg100.0%

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

      \[\leadsto z - \left(\frac{-x}{2} + \color{blue}{\left(-y \cdot x\right)}\right) \]
    8. unsub-neg100.0%

      \[\leadsto z - \color{blue}{\left(\frac{-x}{2} - y \cdot x\right)} \]
    9. neg-mul-1100.0%

      \[\leadsto z - \left(\frac{\color{blue}{-1 \cdot x}}{2} - y \cdot x\right) \]
    10. associate-/l*99.9%

      \[\leadsto z - \left(\color{blue}{\frac{-1}{\frac{2}{x}}} - y \cdot x\right) \]
    11. associate-/r/100.0%

      \[\leadsto z - \left(\color{blue}{\frac{-1}{2} \cdot x} - y \cdot x\right) \]
    12. distribute-rgt-out--100.0%

      \[\leadsto z - \color{blue}{x \cdot \left(\frac{-1}{2} - y\right)} \]
    13. metadata-eval100.0%

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

    \[\leadsto \color{blue}{z - x \cdot \left(-0.5 - y\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 73.2%

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

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

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

    \[\leadsto z - \color{blue}{\left(-x\right) \cdot y} \]
  8. Taylor expanded in z around inf 38.1%

    \[\leadsto \color{blue}{z} \]
  9. Final simplification38.1%

    \[\leadsto z \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024024 
(FPCore (x y z)
  :name "Data.Histogram.Bin.BinF:$cfromIndex from histogram-fill-0.8.4.1"
  :precision binary64
  (+ (+ (/ x 2.0) (* y x)) z))