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

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

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

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

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

    \[\left(\frac{x}{2} + y \cdot x\right) + z \]
  2. Add Preprocessing
  3. Final simplification100.0%

    \[\leadsto \left(\frac{x}{2} + x \cdot y\right) + z \]
  4. Add Preprocessing

Alternative 2: 60.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+32}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-66}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{-89}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-249}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-184}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+33}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.25e+32)
   (* x y)
   (if (<= y -1.12e-66)
     z
     (if (<= y -1.7e-89)
       (* x 0.5)
       (if (<= y 1.4e-249)
         z
         (if (<= y 9.6e-184) (* x 0.5) (if (<= y 1.25e+33) z (* x y))))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.25e+32) {
		tmp = x * y;
	} else if (y <= -1.12e-66) {
		tmp = z;
	} else if (y <= -1.7e-89) {
		tmp = x * 0.5;
	} else if (y <= 1.4e-249) {
		tmp = z;
	} else if (y <= 9.6e-184) {
		tmp = x * 0.5;
	} else if (y <= 1.25e+33) {
		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 <= (-1.25d+32)) then
        tmp = x * y
    else if (y <= (-1.12d-66)) then
        tmp = z
    else if (y <= (-1.7d-89)) then
        tmp = x * 0.5d0
    else if (y <= 1.4d-249) then
        tmp = z
    else if (y <= 9.6d-184) then
        tmp = x * 0.5d0
    else if (y <= 1.25d+33) 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 <= -1.25e+32) {
		tmp = x * y;
	} else if (y <= -1.12e-66) {
		tmp = z;
	} else if (y <= -1.7e-89) {
		tmp = x * 0.5;
	} else if (y <= 1.4e-249) {
		tmp = z;
	} else if (y <= 9.6e-184) {
		tmp = x * 0.5;
	} else if (y <= 1.25e+33) {
		tmp = z;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.25e+32:
		tmp = x * y
	elif y <= -1.12e-66:
		tmp = z
	elif y <= -1.7e-89:
		tmp = x * 0.5
	elif y <= 1.4e-249:
		tmp = z
	elif y <= 9.6e-184:
		tmp = x * 0.5
	elif y <= 1.25e+33:
		tmp = z
	else:
		tmp = x * y
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.25e+32)
		tmp = Float64(x * y);
	elseif (y <= -1.12e-66)
		tmp = z;
	elseif (y <= -1.7e-89)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.4e-249)
		tmp = z;
	elseif (y <= 9.6e-184)
		tmp = Float64(x * 0.5);
	elseif (y <= 1.25e+33)
		tmp = z;
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.25e+32)
		tmp = x * y;
	elseif (y <= -1.12e-66)
		tmp = z;
	elseif (y <= -1.7e-89)
		tmp = x * 0.5;
	elseif (y <= 1.4e-249)
		tmp = z;
	elseif (y <= 9.6e-184)
		tmp = x * 0.5;
	elseif (y <= 1.25e+33)
		tmp = z;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.25e+32], N[(x * y), $MachinePrecision], If[LessEqual[y, -1.12e-66], z, If[LessEqual[y, -1.7e-89], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.4e-249], z, If[LessEqual[y, 9.6e-184], N[(x * 0.5), $MachinePrecision], If[LessEqual[y, 1.25e+33], z, N[(x * y), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+32}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;y \leq -1.12 \cdot 10^{-66}:\\
\;\;\;\;z\\

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

\mathbf{elif}\;y \leq 1.4 \cdot 10^{-249}:\\
\;\;\;\;z\\

\mathbf{elif}\;y \leq 9.6 \cdot 10^{-184}:\\
\;\;\;\;x \cdot 0.5\\

\mathbf{elif}\;y \leq 1.25 \cdot 10^{+33}:\\
\;\;\;\;z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.2499999999999999e32 or 1.24999999999999993e33 < 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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 z around 0 72.2%

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

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

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

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

    if -1.2499999999999999e32 < y < -1.12000000000000004e-66 or -1.7e-89 < y < 1.4e-249 or 9.60000000000000097e-184 < y < 1.24999999999999993e33

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 68.7%

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

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

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

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

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

    if -1.12000000000000004e-66 < y < -1.7e-89 or 1.4e-249 < y < 9.60000000000000097e-184

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 z around 0 73.4%

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

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

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

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

        \[\leadsto \color{blue}{x \cdot 0.5} \]
    10. Simplified73.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+32}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-66}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{-89}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-249}:\\ \;\;\;\;z\\ \mathbf{elif}\;y \leq 9.6 \cdot 10^{-184}:\\ \;\;\;\;x \cdot 0.5\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+33}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.1% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -800000 \lor \neg \left(z \leq 1.8 \cdot 10^{-114}\right):\\
\;\;\;\;z + x \cdot y\\

\mathbf{else}:\\
\;\;\;\;x \cdot \left(y + 0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8e5 or 1.80000000000000009e-114 < z

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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.0%

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

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

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

      \[\leadsto z - \color{blue}{x \cdot \left(-y\right)} \]
    8. Step-by-step derivation
      1. sub-neg91.0%

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

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

        \[\leadsto z + \color{blue}{x \cdot y} \]
      4. +-commutative91.0%

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

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

    if -8e5 < z < 1.80000000000000009e-114

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 z around 0 86.5%

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

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

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

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

Alternative 4: 98.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1400000 \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 -1400000.0) (not (<= y 0.5))) (+ z (* x y)) (- z (* x -0.5))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1400000.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 <= (-1400000.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 <= -1400000.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 <= -1400000.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 <= -1400000.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 <= -1400000.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, -1400000.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 -1400000 \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 < -1.4e6 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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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. mul-1-neg99.5%

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

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

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

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

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

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

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

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

    if -1.4e6 < 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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 99.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1400000 \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 5: 74.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+40}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+52}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -7.5e+40) z (if (<= z 7e+52) (* x (+ y 0.5)) z)))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -7.5e+40) {
		tmp = z;
	} else if (z <= 7e+52) {
		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 (z <= (-7.5d+40)) then
        tmp = z
    else if (z <= 7d+52) 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 (z <= -7.5e+40) {
		tmp = z;
	} else if (z <= 7e+52) {
		tmp = x * (y + 0.5);
	} else {
		tmp = z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -7.5e+40:
		tmp = z
	elif z <= 7e+52:
		tmp = x * (y + 0.5)
	else:
		tmp = z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -7.5e+40)
		tmp = z;
	elseif (z <= 7e+52)
		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 (z <= -7.5e+40)
		tmp = z;
	elseif (z <= 7e+52)
		tmp = x * (y + 0.5);
	else
		tmp = z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -7.5e+40], z, If[LessEqual[z, 7e+52], N[(x * N[(y + 0.5), $MachinePrecision]), $MachinePrecision], z]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+40}:\\
\;\;\;\;z\\

\mathbf{elif}\;z \leq 7 \cdot 10^{+52}:\\
\;\;\;\;x \cdot \left(y + 0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.4999999999999996e40 or 7e52 < z

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 96.1%

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

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

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

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

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

    if -7.4999999999999996e40 < z < 7e52

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 z around 0 78.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+40}:\\ \;\;\;\;z\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+52}:\\ \;\;\;\;x \cdot \left(y + 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 51.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+77} \lor \neg \left(x \leq 8.6 \cdot 10^{+86}\right):\\
\;\;\;\;x \cdot 0.5\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.29999999999999995e77 or 8.6000000000000004e86 < x

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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 z around 0 87.7%

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

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

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

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

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

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

    if -2.29999999999999995e77 < x < 8.6000000000000004e86

    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. *-commutative100.0%

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

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

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

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

        \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
      12. distribute-lft-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.1%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.3 \cdot 10^{+77} \lor \neg \left(x \leq 8.6 \cdot 10^{+86}\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. *-commutative100.0%

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

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

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

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

      \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
    12. distribute-lft-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.9% 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. *-commutative100.0%

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

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

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

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

      \[\leadsto z - \left(\color{blue}{x \cdot \frac{-1}{2}} - x \cdot y\right) \]
    12. distribute-lft-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 76.8%

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

      \[\leadsto z - \color{blue}{\left(-x \cdot y\right)} \]
    2. distribute-rgt-neg-out76.8%

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

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

    \[\leadsto \color{blue}{z} \]
  9. Final simplification46.0%

    \[\leadsto z \]
  10. Add Preprocessing

Reproduce

?
herbie shell --seed 2024095 
(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))