Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B

Percentage Accurate: 99.8% → 100.0%
Time: 6.1s
Alternatives: 9
Speedup: 1.2×

Specification

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

\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\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 9 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: 99.8% accurate, 1.0× speedup?

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

\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}

Alternative 1: 100.0% accurate, 1.2× speedup?

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

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

    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
  2. Step-by-step derivation
    1. remove-double-neg100.0%

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

      \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
    3. times-frac100.0%

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

      \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
    5. div-sub100.0%

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
    6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
    15. times-frac100.0%

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

      \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
    17. *-inverses100.0%

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

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

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

Alternative 2: 78.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{+157} \lor \neg \left(y \leq -4.1 \cdot 10^{+63} \lor \neg \left(y \leq -420000000\right) \land y \leq 1.75 \cdot 10^{+103}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -3.4e+157)
         (not
          (or (<= y -4.1e+63)
              (and (not (<= y -420000000.0)) (<= y 1.75e+103)))))
   (* -4.0 (/ y z))
   (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.4e+157) || !((y <= -4.1e+63) || (!(y <= -420000000.0) && (y <= 1.75e+103)))) {
		tmp = -4.0 * (y / z);
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-3.4d+157)) .or. (.not. (y <= (-4.1d+63)) .or. (.not. (y <= (-420000000.0d0))) .and. (y <= 1.75d+103))) then
        tmp = (-4.0d0) * (y / z)
    else
        tmp = 4.0d0 * ((-0.5d0) + (x / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -3.4e+157) || !((y <= -4.1e+63) || (!(y <= -420000000.0) && (y <= 1.75e+103)))) {
		tmp = -4.0 * (y / z);
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -3.4e+157) or not ((y <= -4.1e+63) or (not (y <= -420000000.0) and (y <= 1.75e+103))):
		tmp = -4.0 * (y / z)
	else:
		tmp = 4.0 * (-0.5 + (x / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -3.4e+157) || !((y <= -4.1e+63) || (!(y <= -420000000.0) && (y <= 1.75e+103))))
		tmp = Float64(-4.0 * Float64(y / z));
	else
		tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -3.4e+157) || ~(((y <= -4.1e+63) || (~((y <= -420000000.0)) && (y <= 1.75e+103)))))
		tmp = -4.0 * (y / z);
	else
		tmp = 4.0 * (-0.5 + (x / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+157], N[Not[Or[LessEqual[y, -4.1e+63], And[N[Not[LessEqual[y, -420000000.0]], $MachinePrecision], LessEqual[y, 1.75e+103]]]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+157} \lor \neg \left(y \leq -4.1 \cdot 10^{+63} \lor \neg \left(y \leq -420000000\right) \land y \leq 1.75 \cdot 10^{+103}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\

\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.39999999999999979e157 or -4.09999999999999993e63 < y < -4.2e8 or 1.75e103 < y

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative86.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot -4} \]
    7. Simplified86.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot -4} \]

    if -3.39999999999999979e157 < y < -4.09999999999999993e63 or -4.2e8 < y < 1.75e103

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \left(0.5 - \frac{x}{z}\right)} \]
    6. Step-by-step derivation
      1. sub-neg91.2%

        \[\leadsto -4 \cdot \color{blue}{\left(0.5 + \left(-\frac{x}{z}\right)\right)} \]
      2. +-commutative91.2%

        \[\leadsto -4 \cdot \color{blue}{\left(\left(-\frac{x}{z}\right) + 0.5\right)} \]
      3. neg-sub091.2%

        \[\leadsto -4 \cdot \left(\color{blue}{\left(0 - \frac{x}{z}\right)} + 0.5\right) \]
      4. associate-+l-91.2%

        \[\leadsto -4 \cdot \color{blue}{\left(0 - \left(\frac{x}{z} - 0.5\right)\right)} \]
      5. neg-sub091.2%

        \[\leadsto -4 \cdot \color{blue}{\left(-\left(\frac{x}{z} - 0.5\right)\right)} \]
      6. neg-mul-191.2%

        \[\leadsto -4 \cdot \color{blue}{\left(-1 \cdot \left(\frac{x}{z} - 0.5\right)\right)} \]
      7. associate-*r*91.2%

        \[\leadsto \color{blue}{\left(-4 \cdot -1\right) \cdot \left(\frac{x}{z} - 0.5\right)} \]
      8. metadata-eval91.2%

        \[\leadsto \color{blue}{4} \cdot \left(\frac{x}{z} - 0.5\right) \]
      9. sub-neg91.2%

        \[\leadsto 4 \cdot \color{blue}{\left(\frac{x}{z} + \left(-0.5\right)\right)} \]
      10. metadata-eval91.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.4 \cdot 10^{+157} \lor \neg \left(y \leq -4.1 \cdot 10^{+63} \lor \neg \left(y \leq -420000000\right) \land y \leq 1.75 \cdot 10^{+103}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 52.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot 4}{z}\\ t_1 := -4 \cdot \frac{y}{z}\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{+101}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -8.9 \cdot 10^{-57}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-256}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{+116}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x 4.0) z)) (t_1 (* -4.0 (/ y z))))
   (if (<= x -9.5e+101)
     t_0
     (if (<= x -8.9e-57)
       t_1
       (if (<= x -1.9e-256) -2.0 (if (<= x 3.9e+116) t_1 t_0))))))
double code(double x, double y, double z) {
	double t_0 = (x * 4.0) / z;
	double t_1 = -4.0 * (y / z);
	double tmp;
	if (x <= -9.5e+101) {
		tmp = t_0;
	} else if (x <= -8.9e-57) {
		tmp = t_1;
	} else if (x <= -1.9e-256) {
		tmp = -2.0;
	} else if (x <= 3.9e+116) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x * 4.0d0) / z
    t_1 = (-4.0d0) * (y / z)
    if (x <= (-9.5d+101)) then
        tmp = t_0
    else if (x <= (-8.9d-57)) then
        tmp = t_1
    else if (x <= (-1.9d-256)) then
        tmp = -2.0d0
    else if (x <= 3.9d+116) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x * 4.0) / z;
	double t_1 = -4.0 * (y / z);
	double tmp;
	if (x <= -9.5e+101) {
		tmp = t_0;
	} else if (x <= -8.9e-57) {
		tmp = t_1;
	} else if (x <= -1.9e-256) {
		tmp = -2.0;
	} else if (x <= 3.9e+116) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x * 4.0) / z
	t_1 = -4.0 * (y / z)
	tmp = 0
	if x <= -9.5e+101:
		tmp = t_0
	elif x <= -8.9e-57:
		tmp = t_1
	elif x <= -1.9e-256:
		tmp = -2.0
	elif x <= 3.9e+116:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x * 4.0) / z)
	t_1 = Float64(-4.0 * Float64(y / z))
	tmp = 0.0
	if (x <= -9.5e+101)
		tmp = t_0;
	elseif (x <= -8.9e-57)
		tmp = t_1;
	elseif (x <= -1.9e-256)
		tmp = -2.0;
	elseif (x <= 3.9e+116)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x * 4.0) / z;
	t_1 = -4.0 * (y / z);
	tmp = 0.0;
	if (x <= -9.5e+101)
		tmp = t_0;
	elseif (x <= -8.9e-57)
		tmp = t_1;
	elseif (x <= -1.9e-256)
		tmp = -2.0;
	elseif (x <= 3.9e+116)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.5e+101], t$95$0, If[LessEqual[x, -8.9e-57], t$95$1, If[LessEqual[x, -1.9e-256], -2.0, If[LessEqual[x, 3.9e+116], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{+101}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -8.9 \cdot 10^{-57}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -1.9 \cdot 10^{-256}:\\
\;\;\;\;-2\\

\mathbf{elif}\;x \leq 3.9 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.49999999999999947e101 or 3.90000000000000032e116 < x

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative81.4%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot 4} \]
      2. associate-*l/81.4%

        \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} \]
    7. Simplified81.4%

      \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} \]

    if -9.49999999999999947e101 < x < -8.8999999999999997e-57 or -1.89999999999999988e-256 < x < 3.90000000000000032e116

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative56.3%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot -4} \]
    7. Simplified56.3%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot -4} \]

    if -8.8999999999999997e-57 < x < -1.89999999999999988e-256

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+101}:\\ \;\;\;\;\frac{x \cdot 4}{z}\\ \mathbf{elif}\;x \leq -8.9 \cdot 10^{-57}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{-256}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{+116}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 4}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 52.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{4}{z}\\ t_1 := -4 \cdot \frac{y}{z}\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{+101}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-53}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-256}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+115}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ 4.0 z))) (t_1 (* -4.0 (/ y z))))
   (if (<= x -9.5e+101)
     t_0
     (if (<= x -2.8e-53)
       t_1
       (if (<= x -3.2e-256) -2.0 (if (<= x 8e+115) t_1 t_0))))))
double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double t_1 = -4.0 * (y / z);
	double tmp;
	if (x <= -9.5e+101) {
		tmp = t_0;
	} else if (x <= -2.8e-53) {
		tmp = t_1;
	} else if (x <= -3.2e-256) {
		tmp = -2.0;
	} else if (x <= 8e+115) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (4.0d0 / z)
    t_1 = (-4.0d0) * (y / z)
    if (x <= (-9.5d+101)) then
        tmp = t_0
    else if (x <= (-2.8d-53)) then
        tmp = t_1
    else if (x <= (-3.2d-256)) then
        tmp = -2.0d0
    else if (x <= 8d+115) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double t_1 = -4.0 * (y / z);
	double tmp;
	if (x <= -9.5e+101) {
		tmp = t_0;
	} else if (x <= -2.8e-53) {
		tmp = t_1;
	} else if (x <= -3.2e-256) {
		tmp = -2.0;
	} else if (x <= 8e+115) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (4.0 / z)
	t_1 = -4.0 * (y / z)
	tmp = 0
	if x <= -9.5e+101:
		tmp = t_0
	elif x <= -2.8e-53:
		tmp = t_1
	elif x <= -3.2e-256:
		tmp = -2.0
	elif x <= 8e+115:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(4.0 / z))
	t_1 = Float64(-4.0 * Float64(y / z))
	tmp = 0.0
	if (x <= -9.5e+101)
		tmp = t_0;
	elseif (x <= -2.8e-53)
		tmp = t_1;
	elseif (x <= -3.2e-256)
		tmp = -2.0;
	elseif (x <= 8e+115)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (4.0 / z);
	t_1 = -4.0 * (y / z);
	tmp = 0.0;
	if (x <= -9.5e+101)
		tmp = t_0;
	elseif (x <= -2.8e-53)
		tmp = t_1;
	elseif (x <= -3.2e-256)
		tmp = -2.0;
	elseif (x <= 8e+115)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.5e+101], t$95$0, If[LessEqual[x, -2.8e-53], t$95$1, If[LessEqual[x, -3.2e-256], -2.0, If[LessEqual[x, 8e+115], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{+101}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -2.8 \cdot 10^{-53}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -3.2 \cdot 10^{-256}:\\
\;\;\;\;-2\\

\mathbf{elif}\;x \leq 8 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -9.49999999999999947e101 or 8.0000000000000001e115 < x

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative81.4%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot 4} \]
      2. associate-*l/81.4%

        \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} \]
    7. Simplified81.4%

      \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} \]
    8. Step-by-step derivation
      1. associate-/l*81.2%

        \[\leadsto \color{blue}{x \cdot \frac{4}{z}} \]
      2. *-commutative81.2%

        \[\leadsto \color{blue}{\frac{4}{z} \cdot x} \]
    9. Applied egg-rr81.2%

      \[\leadsto \color{blue}{\frac{4}{z} \cdot x} \]

    if -9.49999999999999947e101 < x < -2.79999999999999985e-53 or -3.1999999999999999e-256 < x < 8.0000000000000001e115

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{z}} \]
    6. Step-by-step derivation
      1. *-commutative56.3%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot -4} \]
    7. Simplified56.3%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot -4} \]

    if -2.79999999999999985e-53 < x < -3.1999999999999999e-256

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{+101}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-53}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-256}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+115}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 52.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{4}{z}\\ t_1 := y \cdot \frac{-4}{z}\\ \mathbf{if}\;x \leq -2 \cdot 10^{+103}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-59}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-256}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+115}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ 4.0 z))) (t_1 (* y (/ -4.0 z))))
   (if (<= x -2e+103)
     t_0
     (if (<= x -3e-59)
       t_1
       (if (<= x -2.5e-256) -2.0 (if (<= x 1.6e+115) t_1 t_0))))))
double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double t_1 = y * (-4.0 / z);
	double tmp;
	if (x <= -2e+103) {
		tmp = t_0;
	} else if (x <= -3e-59) {
		tmp = t_1;
	} else if (x <= -2.5e-256) {
		tmp = -2.0;
	} else if (x <= 1.6e+115) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * (4.0d0 / z)
    t_1 = y * ((-4.0d0) / z)
    if (x <= (-2d+103)) then
        tmp = t_0
    else if (x <= (-3d-59)) then
        tmp = t_1
    else if (x <= (-2.5d-256)) then
        tmp = -2.0d0
    else if (x <= 1.6d+115) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double t_1 = y * (-4.0 / z);
	double tmp;
	if (x <= -2e+103) {
		tmp = t_0;
	} else if (x <= -3e-59) {
		tmp = t_1;
	} else if (x <= -2.5e-256) {
		tmp = -2.0;
	} else if (x <= 1.6e+115) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (4.0 / z)
	t_1 = y * (-4.0 / z)
	tmp = 0
	if x <= -2e+103:
		tmp = t_0
	elif x <= -3e-59:
		tmp = t_1
	elif x <= -2.5e-256:
		tmp = -2.0
	elif x <= 1.6e+115:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(4.0 / z))
	t_1 = Float64(y * Float64(-4.0 / z))
	tmp = 0.0
	if (x <= -2e+103)
		tmp = t_0;
	elseif (x <= -3e-59)
		tmp = t_1;
	elseif (x <= -2.5e-256)
		tmp = -2.0;
	elseif (x <= 1.6e+115)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (4.0 / z);
	t_1 = y * (-4.0 / z);
	tmp = 0.0;
	if (x <= -2e+103)
		tmp = t_0;
	elseif (x <= -3e-59)
		tmp = t_1;
	elseif (x <= -2.5e-256)
		tmp = -2.0;
	elseif (x <= 1.6e+115)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2e+103], t$95$0, If[LessEqual[x, -3e-59], t$95$1, If[LessEqual[x, -2.5e-256], -2.0, If[LessEqual[x, 1.6e+115], t$95$1, t$95$0]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := y \cdot \frac{-4}{z}\\
\mathbf{if}\;x \leq -2 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -3 \cdot 10^{-59}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -2.5 \cdot 10^{-256}:\\
\;\;\;\;-2\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2e103 or 1.6e115 < x

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{4 \cdot \frac{x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative81.4%

        \[\leadsto \color{blue}{\frac{x}{z} \cdot 4} \]
      2. associate-*l/81.4%

        \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} \]
    7. Simplified81.4%

      \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} \]
    8. Step-by-step derivation
      1. associate-/l*81.2%

        \[\leadsto \color{blue}{x \cdot \frac{4}{z}} \]
      2. *-commutative81.2%

        \[\leadsto \color{blue}{\frac{4}{z} \cdot x} \]
    9. Applied egg-rr81.2%

      \[\leadsto \color{blue}{\frac{4}{z} \cdot x} \]

    if -2e103 < x < -3.0000000000000001e-59 or -2.5e-256 < x < 1.6e115

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y - x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative70.1%

        \[\leadsto \color{blue}{\frac{y - x}{z} \cdot -4} \]
    7. Simplified70.1%

      \[\leadsto \color{blue}{\frac{y - x}{z} \cdot -4} \]
    8. Taylor expanded in y around inf 56.3%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{z}} \]
    9. Step-by-step derivation
      1. associate-*r/56.3%

        \[\leadsto \color{blue}{\frac{-4 \cdot y}{z}} \]
      2. *-commutative56.3%

        \[\leadsto \frac{\color{blue}{y \cdot -4}}{z} \]
      3. associate-/l*56.2%

        \[\leadsto \color{blue}{y \cdot \frac{-4}{z}} \]
    10. Simplified56.2%

      \[\leadsto \color{blue}{y \cdot \frac{-4}{z}} \]

    if -3.0000000000000001e-59 < x < -2.5e-256

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{+103}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-59}:\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-256}:\\ \;\;\;\;-2\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+115}:\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 86.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -29000 \lor \neg \left(y \leq 1.02 \cdot 10^{+96}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z} + -2\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -29000.0) (not (<= y 1.02e+96)))
   (+ (* -4.0 (/ y z)) -2.0)
   (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -29000.0) || !(y <= 1.02e+96)) {
		tmp = (-4.0 * (y / z)) + -2.0;
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-29000.0d0)) .or. (.not. (y <= 1.02d+96))) then
        tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
    else
        tmp = 4.0d0 * ((-0.5d0) + (x / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -29000.0) || !(y <= 1.02e+96)) {
		tmp = (-4.0 * (y / z)) + -2.0;
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -29000.0) or not (y <= 1.02e+96):
		tmp = (-4.0 * (y / z)) + -2.0
	else:
		tmp = 4.0 * (-0.5 + (x / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -29000.0) || !(y <= 1.02e+96))
		tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0);
	else
		tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -29000.0) || ~((y <= 1.02e+96)))
		tmp = (-4.0 * (y / z)) + -2.0;
	else
		tmp = 4.0 * (-0.5 + (x / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -29000.0], N[Not[LessEqual[y, 1.02e+96]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -29000 \lor \neg \left(y \leq 1.02 \cdot 10^{+96}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\

\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -29000 or 1.02000000000000001e96 < y

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

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

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{y}{z} + 0.5\right)} \]
      2. distribute-rgt-in90.4%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot -4 + 0.5 \cdot -4} \]
      3. metadata-eval90.4%

        \[\leadsto \frac{y}{z} \cdot -4 + \color{blue}{-2} \]
    7. Simplified90.4%

      \[\leadsto \color{blue}{\frac{y}{z} \cdot -4 + -2} \]

    if -29000 < y < 1.02000000000000001e96

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \left(0.5 - \frac{x}{z}\right)} \]
    6. Step-by-step derivation
      1. sub-neg93.2%

        \[\leadsto -4 \cdot \color{blue}{\left(0.5 + \left(-\frac{x}{z}\right)\right)} \]
      2. +-commutative93.2%

        \[\leadsto -4 \cdot \color{blue}{\left(\left(-\frac{x}{z}\right) + 0.5\right)} \]
      3. neg-sub093.2%

        \[\leadsto -4 \cdot \left(\color{blue}{\left(0 - \frac{x}{z}\right)} + 0.5\right) \]
      4. associate-+l-93.2%

        \[\leadsto -4 \cdot \color{blue}{\left(0 - \left(\frac{x}{z} - 0.5\right)\right)} \]
      5. neg-sub093.2%

        \[\leadsto -4 \cdot \color{blue}{\left(-\left(\frac{x}{z} - 0.5\right)\right)} \]
      6. neg-mul-193.2%

        \[\leadsto -4 \cdot \color{blue}{\left(-1 \cdot \left(\frac{x}{z} - 0.5\right)\right)} \]
      7. associate-*r*93.2%

        \[\leadsto \color{blue}{\left(-4 \cdot -1\right) \cdot \left(\frac{x}{z} - 0.5\right)} \]
      8. metadata-eval93.2%

        \[\leadsto \color{blue}{4} \cdot \left(\frac{x}{z} - 0.5\right) \]
      9. sub-neg93.2%

        \[\leadsto 4 \cdot \color{blue}{\left(\frac{x}{z} + \left(-0.5\right)\right)} \]
      10. metadata-eval93.2%

        \[\leadsto 4 \cdot \left(\frac{x}{z} + \color{blue}{-0.5}\right) \]
    7. Simplified93.2%

      \[\leadsto \color{blue}{4 \cdot \left(\frac{x}{z} + -0.5\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -29000 \lor \neg \left(y \leq 1.02 \cdot 10^{+96}\right):\\ \;\;\;\;-4 \cdot \frac{y}{z} + -2\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -410000000 \lor \neg \left(y \leq 2.8 \cdot 10^{+87}\right):\\ \;\;\;\;-4 \cdot \frac{y - x}{z}\\ \mathbf{else}:\\ \;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -410000000.0) (not (<= y 2.8e+87)))
   (* -4.0 (/ (- y x) z))
   (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -410000000.0) || !(y <= 2.8e+87)) {
		tmp = -4.0 * ((y - x) / z);
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-410000000.0d0)) .or. (.not. (y <= 2.8d+87))) then
        tmp = (-4.0d0) * ((y - x) / z)
    else
        tmp = 4.0d0 * ((-0.5d0) + (x / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -410000000.0) || !(y <= 2.8e+87)) {
		tmp = -4.0 * ((y - x) / z);
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -410000000.0) or not (y <= 2.8e+87):
		tmp = -4.0 * ((y - x) / z)
	else:
		tmp = 4.0 * (-0.5 + (x / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -410000000.0) || !(y <= 2.8e+87))
		tmp = Float64(-4.0 * Float64(Float64(y - x) / z));
	else
		tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -410000000.0) || ~((y <= 2.8e+87)))
		tmp = -4.0 * ((y - x) / z);
	else
		tmp = 4.0 * (-0.5 + (x / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -410000000.0], N[Not[LessEqual[y, 2.8e+87]], $MachinePrecision]], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -410000000 \lor \neg \left(y \leq 2.8 \cdot 10^{+87}\right):\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\

\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.1e8 or 2.80000000000000015e87 < y

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y - x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative84.8%

        \[\leadsto \color{blue}{\frac{y - x}{z} \cdot -4} \]
    7. Simplified84.8%

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

    if -4.1e8 < y < 2.80000000000000015e87

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \left(0.5 - \frac{x}{z}\right)} \]
    6. Step-by-step derivation
      1. sub-neg93.2%

        \[\leadsto -4 \cdot \color{blue}{\left(0.5 + \left(-\frac{x}{z}\right)\right)} \]
      2. +-commutative93.2%

        \[\leadsto -4 \cdot \color{blue}{\left(\left(-\frac{x}{z}\right) + 0.5\right)} \]
      3. neg-sub093.2%

        \[\leadsto -4 \cdot \left(\color{blue}{\left(0 - \frac{x}{z}\right)} + 0.5\right) \]
      4. associate-+l-93.2%

        \[\leadsto -4 \cdot \color{blue}{\left(0 - \left(\frac{x}{z} - 0.5\right)\right)} \]
      5. neg-sub093.2%

        \[\leadsto -4 \cdot \color{blue}{\left(-\left(\frac{x}{z} - 0.5\right)\right)} \]
      6. neg-mul-193.2%

        \[\leadsto -4 \cdot \color{blue}{\left(-1 \cdot \left(\frac{x}{z} - 0.5\right)\right)} \]
      7. associate-*r*93.2%

        \[\leadsto \color{blue}{\left(-4 \cdot -1\right) \cdot \left(\frac{x}{z} - 0.5\right)} \]
      8. metadata-eval93.2%

        \[\leadsto \color{blue}{4} \cdot \left(\frac{x}{z} - 0.5\right) \]
      9. sub-neg93.2%

        \[\leadsto 4 \cdot \color{blue}{\left(\frac{x}{z} + \left(-0.5\right)\right)} \]
      10. metadata-eval93.2%

        \[\leadsto 4 \cdot \left(\frac{x}{z} + \color{blue}{-0.5}\right) \]
    7. Simplified93.2%

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

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

Alternative 8: 51.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-106} \lor \neg \left(y \leq 6.6 \cdot 10^{+82}\right):\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -2.5e-106) (not (<= y 6.6e+82))) (* y (/ -4.0 z)) -2.0))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -2.5e-106) || !(y <= 6.6e+82)) {
		tmp = y * (-4.0 / z);
	} else {
		tmp = -2.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-2.5d-106)) .or. (.not. (y <= 6.6d+82))) then
        tmp = y * ((-4.0d0) / z)
    else
        tmp = -2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -2.5e-106) || !(y <= 6.6e+82)) {
		tmp = y * (-4.0 / z);
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -2.5e-106) or not (y <= 6.6e+82):
		tmp = y * (-4.0 / z)
	else:
		tmp = -2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -2.5e-106) || !(y <= 6.6e+82))
		tmp = Float64(y * Float64(-4.0 / z));
	else
		tmp = -2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -2.5e-106) || ~((y <= 6.6e+82)))
		tmp = y * (-4.0 / z);
	else
		tmp = -2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.5e-106], N[Not[LessEqual[y, 6.6e+82]], $MachinePrecision]], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-106} \lor \neg \left(y \leq 6.6 \cdot 10^{+82}\right):\\
\;\;\;\;y \cdot \frac{-4}{z}\\

\mathbf{else}:\\
\;\;\;\;-2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.49999999999999991e-106 or 6.5999999999999997e82 < y

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

      \[\leadsto \color{blue}{-4 \cdot \frac{y - x}{z}} \]
    6. Step-by-step derivation
      1. *-commutative83.6%

        \[\leadsto \color{blue}{\frac{y - x}{z} \cdot -4} \]
    7. Simplified83.6%

      \[\leadsto \color{blue}{\frac{y - x}{z} \cdot -4} \]
    8. Taylor expanded in y around inf 67.5%

      \[\leadsto \color{blue}{-4 \cdot \frac{y}{z}} \]
    9. Step-by-step derivation
      1. associate-*r/67.5%

        \[\leadsto \color{blue}{\frac{-4 \cdot y}{z}} \]
      2. *-commutative67.5%

        \[\leadsto \frac{\color{blue}{y \cdot -4}}{z} \]
      3. associate-/l*67.3%

        \[\leadsto \color{blue}{y \cdot \frac{-4}{z}} \]
    10. Simplified67.3%

      \[\leadsto \color{blue}{y \cdot \frac{-4}{z}} \]

    if -2.49999999999999991e-106 < y < 6.5999999999999997e82

    1. Initial program 100.0%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg100.0%

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

        \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
      3. times-frac100.0%

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

        \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
      5. div-sub100.0%

        \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
      6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
      15. times-frac100.0%

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

        \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
      17. *-inverses100.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-106} \lor \neg \left(y \leq 6.6 \cdot 10^{+82}\right):\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 34.8% accurate, 11.0× speedup?

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

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

    \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
  2. Step-by-step derivation
    1. remove-double-neg100.0%

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

      \[\leadsto \frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{\color{blue}{-1 \cdot \left(-z\right)}} \]
    3. times-frac100.0%

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

      \[\leadsto \color{blue}{-4} \cdot \frac{\left(x - y\right) - z \cdot 0.5}{-z} \]
    5. div-sub100.0%

      \[\leadsto -4 \cdot \color{blue}{\left(\frac{x - y}{-z} - \frac{z \cdot 0.5}{-z}\right)} \]
    6. distribute-frac-neg2100.0%

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

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

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

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

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

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

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

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

      \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \frac{0.5 \cdot z}{\color{blue}{-1 \cdot z}}\right) \]
    15. times-frac100.0%

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

      \[\leadsto -4 \cdot \left(\frac{y - x}{z} - \color{blue}{-0.5} \cdot \frac{z}{z}\right) \]
    17. *-inverses100.0%

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

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

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

    \[\leadsto \color{blue}{-2} \]
  6. Add Preprocessing

Developer Target 1: 98.0% accurate, 0.8× speedup?

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

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

Reproduce

?
herbie shell --seed 2024141 
(FPCore (x y z)
  :name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
  :precision binary64

  :alt
  (! :herbie-platform default (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z)))))

  (/ (* 4.0 (- (- x y) (* z 0.5))) z))