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

Percentage Accurate: 99.7% → 100.0%
Time: 6.7s
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.7% 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: 53.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x \cdot 4}{z}\\ \mathbf{if}\;z \leq -1.2 \cdot 10^{+14}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-248}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-170}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+91}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x 4.0) z)))
   (if (<= z -1.2e+14)
     -2.0
     (if (<= z -5.6e-248)
       t_0
       (if (<= z 2.5e-170) (* -4.0 (/ y z)) (if (<= z 1.45e+91) t_0 -2.0))))))
double code(double x, double y, double z) {
	double t_0 = (x * 4.0) / z;
	double tmp;
	if (z <= -1.2e+14) {
		tmp = -2.0;
	} else if (z <= -5.6e-248) {
		tmp = t_0;
	} else if (z <= 2.5e-170) {
		tmp = -4.0 * (y / z);
	} else if (z <= 1.45e+91) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = (x * 4.0d0) / z
    if (z <= (-1.2d+14)) then
        tmp = -2.0d0
    else if (z <= (-5.6d-248)) then
        tmp = t_0
    else if (z <= 2.5d-170) then
        tmp = (-4.0d0) * (y / z)
    else if (z <= 1.45d+91) then
        tmp = t_0
    else
        tmp = -2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x * 4.0) / z;
	double tmp;
	if (z <= -1.2e+14) {
		tmp = -2.0;
	} else if (z <= -5.6e-248) {
		tmp = t_0;
	} else if (z <= 2.5e-170) {
		tmp = -4.0 * (y / z);
	} else if (z <= 1.45e+91) {
		tmp = t_0;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x * 4.0) / z
	tmp = 0
	if z <= -1.2e+14:
		tmp = -2.0
	elif z <= -5.6e-248:
		tmp = t_0
	elif z <= 2.5e-170:
		tmp = -4.0 * (y / z)
	elif z <= 1.45e+91:
		tmp = t_0
	else:
		tmp = -2.0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x * 4.0) / z)
	tmp = 0.0
	if (z <= -1.2e+14)
		tmp = -2.0;
	elseif (z <= -5.6e-248)
		tmp = t_0;
	elseif (z <= 2.5e-170)
		tmp = Float64(-4.0 * Float64(y / z));
	elseif (z <= 1.45e+91)
		tmp = t_0;
	else
		tmp = -2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x * 4.0) / z;
	tmp = 0.0;
	if (z <= -1.2e+14)
		tmp = -2.0;
	elseif (z <= -5.6e-248)
		tmp = t_0;
	elseif (z <= 2.5e-170)
		tmp = -4.0 * (y / z);
	elseif (z <= 1.45e+91)
		tmp = t_0;
	else
		tmp = -2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -1.2e+14], -2.0, If[LessEqual[z, -5.6e-248], t$95$0, If[LessEqual[z, 2.5e-170], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e+91], t$95$0, -2.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+14}:\\
\;\;\;\;-2\\

\mathbf{elif}\;z \leq -5.6 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.5 \cdot 10^{-170}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq 1.45 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.2e14 or 1.45000000000000007e91 < z

    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 66.2%

      \[\leadsto \color{blue}{-2} \]

    if -1.2e14 < z < -5.6000000000000002e-248 or 2.50000000000000005e-170 < z < 1.45000000000000007e91

    1. Initial program 99.9%

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

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

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

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

        \[\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 53.5%

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

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

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

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

    if -5.6000000000000002e-248 < z < 2.50000000000000005e-170

    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 77.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{+14}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-248}:\\ \;\;\;\;\frac{x \cdot 4}{z}\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-170}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{+91}:\\ \;\;\;\;\frac{x \cdot 4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 53.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{4}{z}\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+16}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-248}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-169}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+91}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ 4.0 z))))
   (if (<= z -1.75e+16)
     -2.0
     (if (<= z -6.8e-248)
       t_0
       (if (<= z 4.6e-169) (* -4.0 (/ y z)) (if (<= z 1.65e+91) t_0 -2.0))))))
double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double tmp;
	if (z <= -1.75e+16) {
		tmp = -2.0;
	} else if (z <= -6.8e-248) {
		tmp = t_0;
	} else if (z <= 4.6e-169) {
		tmp = -4.0 * (y / z);
	} else if (z <= 1.65e+91) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = x * (4.0d0 / z)
    if (z <= (-1.75d+16)) then
        tmp = -2.0d0
    else if (z <= (-6.8d-248)) then
        tmp = t_0
    else if (z <= 4.6d-169) then
        tmp = (-4.0d0) * (y / z)
    else if (z <= 1.65d+91) then
        tmp = t_0
    else
        tmp = -2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double tmp;
	if (z <= -1.75e+16) {
		tmp = -2.0;
	} else if (z <= -6.8e-248) {
		tmp = t_0;
	} else if (z <= 4.6e-169) {
		tmp = -4.0 * (y / z);
	} else if (z <= 1.65e+91) {
		tmp = t_0;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (4.0 / z)
	tmp = 0
	if z <= -1.75e+16:
		tmp = -2.0
	elif z <= -6.8e-248:
		tmp = t_0
	elif z <= 4.6e-169:
		tmp = -4.0 * (y / z)
	elif z <= 1.65e+91:
		tmp = t_0
	else:
		tmp = -2.0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(4.0 / z))
	tmp = 0.0
	if (z <= -1.75e+16)
		tmp = -2.0;
	elseif (z <= -6.8e-248)
		tmp = t_0;
	elseif (z <= 4.6e-169)
		tmp = Float64(-4.0 * Float64(y / z));
	elseif (z <= 1.65e+91)
		tmp = t_0;
	else
		tmp = -2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (4.0 / z);
	tmp = 0.0;
	if (z <= -1.75e+16)
		tmp = -2.0;
	elseif (z <= -6.8e-248)
		tmp = t_0;
	elseif (z <= 4.6e-169)
		tmp = -4.0 * (y / z);
	elseif (z <= 1.65e+91)
		tmp = t_0;
	else
		tmp = -2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.75e+16], -2.0, If[LessEqual[z, -6.8e-248], t$95$0, If[LessEqual[z, 4.6e-169], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.65e+91], t$95$0, -2.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+16}:\\
\;\;\;\;-2\\

\mathbf{elif}\;z \leq -6.8 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.6 \cdot 10^{-169}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq 1.65 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.75e16 or 1.65000000000000009e91 < z

    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 66.2%

      \[\leadsto \color{blue}{-2} \]

    if -1.75e16 < z < -6.7999999999999996e-248 or 4.6000000000000002e-169 < z < 1.65000000000000009e91

    1. Initial program 99.9%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

    if -6.7999999999999996e-248 < z < 4.6000000000000002e-169

    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 77.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+16}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-248}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{-169}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{+91}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 53.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \frac{4}{z}\\ \mathbf{if}\;z \leq -1.05 \cdot 10^{+19}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -2.65 \cdot 10^{-248}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-169}:\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{+92}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ 4.0 z))))
   (if (<= z -1.05e+19)
     -2.0
     (if (<= z -2.65e-248)
       t_0
       (if (<= z 7.6e-169) (* y (/ -4.0 z)) (if (<= z 2.9e+92) t_0 -2.0))))))
double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double tmp;
	if (z <= -1.05e+19) {
		tmp = -2.0;
	} else if (z <= -2.65e-248) {
		tmp = t_0;
	} else if (z <= 7.6e-169) {
		tmp = y * (-4.0 / z);
	} else if (z <= 2.9e+92) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = x * (4.0d0 / z)
    if (z <= (-1.05d+19)) then
        tmp = -2.0d0
    else if (z <= (-2.65d-248)) then
        tmp = t_0
    else if (z <= 7.6d-169) then
        tmp = y * ((-4.0d0) / z)
    else if (z <= 2.9d+92) then
        tmp = t_0
    else
        tmp = -2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (4.0 / z);
	double tmp;
	if (z <= -1.05e+19) {
		tmp = -2.0;
	} else if (z <= -2.65e-248) {
		tmp = t_0;
	} else if (z <= 7.6e-169) {
		tmp = y * (-4.0 / z);
	} else if (z <= 2.9e+92) {
		tmp = t_0;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (4.0 / z)
	tmp = 0
	if z <= -1.05e+19:
		tmp = -2.0
	elif z <= -2.65e-248:
		tmp = t_0
	elif z <= 7.6e-169:
		tmp = y * (-4.0 / z)
	elif z <= 2.9e+92:
		tmp = t_0
	else:
		tmp = -2.0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(4.0 / z))
	tmp = 0.0
	if (z <= -1.05e+19)
		tmp = -2.0;
	elseif (z <= -2.65e-248)
		tmp = t_0;
	elseif (z <= 7.6e-169)
		tmp = Float64(y * Float64(-4.0 / z));
	elseif (z <= 2.9e+92)
		tmp = t_0;
	else
		tmp = -2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (4.0 / z);
	tmp = 0.0;
	if (z <= -1.05e+19)
		tmp = -2.0;
	elseif (z <= -2.65e-248)
		tmp = t_0;
	elseif (z <= 7.6e-169)
		tmp = y * (-4.0 / z);
	elseif (z <= 2.9e+92)
		tmp = t_0;
	else
		tmp = -2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.05e+19], -2.0, If[LessEqual[z, -2.65e-248], t$95$0, If[LessEqual[z, 7.6e-169], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.9e+92], t$95$0, -2.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
\mathbf{if}\;z \leq -1.05 \cdot 10^{+19}:\\
\;\;\;\;-2\\

\mathbf{elif}\;z \leq -2.65 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 7.6 \cdot 10^{-169}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\

\mathbf{elif}\;z \leq 2.9 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.05e19 or 2.9000000000000001e92 < z

    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 66.2%

      \[\leadsto \color{blue}{-2} \]

    if -1.05e19 < z < -2.65e-248 or 7.6000000000000001e-169 < z < 2.9000000000000001e92

    1. Initial program 99.9%

      \[\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z} \]
    2. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

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

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

    if -2.65e-248 < z < 7.6000000000000001e-169

    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 77.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{y \cdot \frac{-4}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 83.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+176} \lor \neg \left(x \leq 1.2 \cdot 10^{+24}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\

\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -9.19999999999999984e176 or 1.2e24 < 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. *-commutative100.0%

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

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

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

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

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

    if -9.19999999999999984e176 < x < 1.2e24

    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 85.8%

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

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

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

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

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

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

Alternative 6: 85.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.82 \cdot 10^{+62}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-25}:\\ \;\;\;\;\frac{x \cdot 4}{z} + -2\\ \mathbf{else}:\\ \;\;\;\;-2 + -4 \cdot \frac{y}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.82e+62)
   (* (- x y) (/ 4.0 z))
   (if (<= y 2e-25) (+ (/ (* x 4.0) z) -2.0) (+ -2.0 (* -4.0 (/ y z))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.82e+62) {
		tmp = (x - y) * (4.0 / z);
	} else if (y <= 2e-25) {
		tmp = ((x * 4.0) / z) + -2.0;
	} else {
		tmp = -2.0 + (-4.0 * (y / z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.82d+62)) then
        tmp = (x - y) * (4.0d0 / z)
    else if (y <= 2d-25) then
        tmp = ((x * 4.0d0) / z) + (-2.0d0)
    else
        tmp = (-2.0d0) + ((-4.0d0) * (y / z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.82e+62) {
		tmp = (x - y) * (4.0 / z);
	} else if (y <= 2e-25) {
		tmp = ((x * 4.0) / z) + -2.0;
	} else {
		tmp = -2.0 + (-4.0 * (y / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.82e+62:
		tmp = (x - y) * (4.0 / z)
	elif y <= 2e-25:
		tmp = ((x * 4.0) / z) + -2.0
	else:
		tmp = -2.0 + (-4.0 * (y / z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.82e+62)
		tmp = Float64(Float64(x - y) * Float64(4.0 / z));
	elseif (y <= 2e-25)
		tmp = Float64(Float64(Float64(x * 4.0) / z) + -2.0);
	else
		tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.82e+62)
		tmp = (x - y) * (4.0 / z);
	elseif (y <= 2e-25)
		tmp = ((x * 4.0) / z) + -2.0;
	else
		tmp = -2.0 + (-4.0 * (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.82e+62], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e-25], N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.82 \cdot 10^{+62}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\

\mathbf{elif}\;y \leq 2 \cdot 10^{-25}:\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\

\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.81999999999999998e62

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

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

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

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

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

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

    if -1.81999999999999998e62 < y < 2.00000000000000008e-25

    1. Initial program 99.9%

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

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

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

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

        \[\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.7%

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

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

        \[\leadsto -4 \cdot \color{blue}{\left(\left(-\frac{x}{z}\right) + 0.5\right)} \]
      3. distribute-rgt-in91.7%

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

        \[\leadsto \color{blue}{\frac{-x}{z}} \cdot -4 + 0.5 \cdot -4 \]
      5. neg-mul-191.7%

        \[\leadsto \frac{\color{blue}{-1 \cdot x}}{z} \cdot -4 + 0.5 \cdot -4 \]
      6. *-commutative91.7%

        \[\leadsto \frac{\color{blue}{x \cdot -1}}{z} \cdot -4 + 0.5 \cdot -4 \]
      7. associate-/l*91.6%

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

        \[\leadsto \left(x \cdot \frac{\color{blue}{-1}}{z}\right) \cdot -4 + 0.5 \cdot -4 \]
      9. distribute-neg-frac91.6%

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

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

        \[\leadsto x \cdot \color{blue}{\left(-4 \cdot \left(-\frac{1}{z}\right)\right)} + 0.5 \cdot -4 \]
      12. distribute-frac-neg291.6%

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

        \[\leadsto x \cdot \color{blue}{\frac{-4 \cdot 1}{-z}} + 0.5 \cdot -4 \]
      14. metadata-eval91.6%

        \[\leadsto x \cdot \frac{\color{blue}{-4}}{-z} + 0.5 \cdot -4 \]
      15. distribute-neg-frac291.6%

        \[\leadsto x \cdot \color{blue}{\left(-\frac{-4}{z}\right)} + 0.5 \cdot -4 \]
      16. distribute-neg-frac91.6%

        \[\leadsto x \cdot \color{blue}{\frac{--4}{z}} + 0.5 \cdot -4 \]
      17. metadata-eval91.6%

        \[\leadsto x \cdot \frac{\color{blue}{4}}{z} + 0.5 \cdot -4 \]
      18. associate-*r/91.7%

        \[\leadsto \color{blue}{\frac{x \cdot 4}{z}} + 0.5 \cdot -4 \]
      19. metadata-eval91.7%

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

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

    if 2.00000000000000008e-25 < 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 85.9%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.82 \cdot 10^{+62}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-25}:\\ \;\;\;\;\frac{x \cdot 4}{z} + -2\\ \mathbf{else}:\\ \;\;\;\;-2 + -4 \cdot \frac{y}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 79.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8.4 \cdot 10^{+182}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq 5.2 \cdot 10^{+98}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -8.4e+182) -2.0 (if (<= z 5.2e+98) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -8.4e+182) {
		tmp = -2.0;
	} else if (z <= 5.2e+98) {
		tmp = (x - 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 (z <= (-8.4d+182)) then
        tmp = -2.0d0
    else if (z <= 5.2d+98) then
        tmp = (x - 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 (z <= -8.4e+182) {
		tmp = -2.0;
	} else if (z <= 5.2e+98) {
		tmp = (x - y) * (4.0 / z);
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -8.4e+182:
		tmp = -2.0
	elif z <= 5.2e+98:
		tmp = (x - y) * (4.0 / z)
	else:
		tmp = -2.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -8.4e+182)
		tmp = -2.0;
	elseif (z <= 5.2e+98)
		tmp = Float64(Float64(x - y) * Float64(4.0 / z));
	else
		tmp = -2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -8.4e+182)
		tmp = -2.0;
	elseif (z <= 5.2e+98)
		tmp = (x - y) * (4.0 / z);
	else
		tmp = -2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -8.4e+182], -2.0, If[LessEqual[z, 5.2e+98], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+182}:\\
\;\;\;\;-2\\

\mathbf{elif}\;z \leq 5.2 \cdot 10^{+98}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.3999999999999996e182 or 5.1999999999999999e98 < z

    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 77.2%

      \[\leadsto \color{blue}{-2} \]

    if -8.3999999999999996e182 < z < 5.1999999999999999e98

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x - y\right)} \cdot \frac{4}{z} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 54.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+60} \lor \neg \left(x \leq 3.3 \cdot 10^{+35}\right):\\
\;\;\;\;x \cdot \frac{4}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.1000000000000001e60 or 3.3000000000000002e35 < 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. *-commutative100.0%

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

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

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

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

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

    if -3.1000000000000001e60 < x < 3.3000000000000002e35

    1. Initial program 99.9%

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

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

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

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

        \[\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.7%

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

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

Alternative 9: 34.5% 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 35.3%

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

Developer Target 1: 97.8% 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 2024139 
(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))