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

Percentage Accurate: 99.8% → 100.0%
Time: 8.8s
Alternatives: 10
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 10 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 99.6%

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

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

      \[\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.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}\;z \leq -5.5 \cdot 10^{+50}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-102}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-214}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-216}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x 4.0) z)) (t_1 (* -4.0 (/ y z))))
   (if (<= z -5.5e+50)
     -2.0
     (if (<= z -6.8e-102)
       t_1
       (if (<= z -3.1e-214)
         t_0
         (if (<= z 6.5e-216) t_1 (if (<= z 4.4e+96) t_0 -2.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 (z <= -5.5e+50) {
		tmp = -2.0;
	} else if (z <= -6.8e-102) {
		tmp = t_1;
	} else if (z <= -3.1e-214) {
		tmp = t_0;
	} else if (z <= 6.5e-216) {
		tmp = t_1;
	} else if (z <= 4.4e+96) {
		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) :: t_1
    real(8) :: tmp
    t_0 = (x * 4.0d0) / z
    t_1 = (-4.0d0) * (y / z)
    if (z <= (-5.5d+50)) then
        tmp = -2.0d0
    else if (z <= (-6.8d-102)) then
        tmp = t_1
    else if (z <= (-3.1d-214)) then
        tmp = t_0
    else if (z <= 6.5d-216) then
        tmp = t_1
    else if (z <= 4.4d+96) 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 t_1 = -4.0 * (y / z);
	double tmp;
	if (z <= -5.5e+50) {
		tmp = -2.0;
	} else if (z <= -6.8e-102) {
		tmp = t_1;
	} else if (z <= -3.1e-214) {
		tmp = t_0;
	} else if (z <= 6.5e-216) {
		tmp = t_1;
	} else if (z <= 4.4e+96) {
		tmp = t_0;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x * 4.0) / z
	t_1 = -4.0 * (y / z)
	tmp = 0
	if z <= -5.5e+50:
		tmp = -2.0
	elif z <= -6.8e-102:
		tmp = t_1
	elif z <= -3.1e-214:
		tmp = t_0
	elif z <= 6.5e-216:
		tmp = t_1
	elif z <= 4.4e+96:
		tmp = t_0
	else:
		tmp = -2.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 (z <= -5.5e+50)
		tmp = -2.0;
	elseif (z <= -6.8e-102)
		tmp = t_1;
	elseif (z <= -3.1e-214)
		tmp = t_0;
	elseif (z <= 6.5e-216)
		tmp = t_1;
	elseif (z <= 4.4e+96)
		tmp = t_0;
	else
		tmp = -2.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 (z <= -5.5e+50)
		tmp = -2.0;
	elseif (z <= -6.8e-102)
		tmp = t_1;
	elseif (z <= -3.1e-214)
		tmp = t_0;
	elseif (z <= 6.5e-216)
		tmp = t_1;
	elseif (z <= 4.4e+96)
		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]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.5e+50], -2.0, If[LessEqual[z, -6.8e-102], t$95$1, If[LessEqual[z, -3.1e-214], t$95$0, If[LessEqual[z, 6.5e-216], t$95$1, If[LessEqual[z, 4.4e+96], t$95$0, -2.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -6.8 \cdot 10^{-102}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -3.1 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{-216}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.4999999999999998e50 or 4.3999999999999998e96 < z

    1. Initial program 99.1%

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

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

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

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

    if -5.4999999999999998e50 < z < -6.80000000000000026e-102 or -3.10000000000000004e-214 < z < 6.4999999999999999e-216

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

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

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

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

    if -6.80000000000000026e-102 < z < -3.10000000000000004e-214 or 6.4999999999999999e-216 < z < 4.3999999999999998e96

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+50}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -6.8 \cdot 10^{-102}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-214}:\\ \;\;\;\;\frac{x \cdot 4}{z}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-216}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;\frac{x \cdot 4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 53.1% 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}\;z \leq -1.8 \cdot 10^{+48}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-98}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-214}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-209}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{+96}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ 4.0 z))) (t_1 (* -4.0 (/ y z))))
   (if (<= z -1.8e+48)
     -2.0
     (if (<= z -3.8e-98)
       t_1
       (if (<= z -6e-214)
         t_0
         (if (<= z 4.4e-209) t_1 (if (<= z 6.6e+96) t_0 -2.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 (z <= -1.8e+48) {
		tmp = -2.0;
	} else if (z <= -3.8e-98) {
		tmp = t_1;
	} else if (z <= -6e-214) {
		tmp = t_0;
	} else if (z <= 4.4e-209) {
		tmp = t_1;
	} else if (z <= 6.6e+96) {
		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) :: t_1
    real(8) :: tmp
    t_0 = x * (4.0d0 / z)
    t_1 = (-4.0d0) * (y / z)
    if (z <= (-1.8d+48)) then
        tmp = -2.0d0
    else if (z <= (-3.8d-98)) then
        tmp = t_1
    else if (z <= (-6d-214)) then
        tmp = t_0
    else if (z <= 4.4d-209) then
        tmp = t_1
    else if (z <= 6.6d+96) 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 t_1 = -4.0 * (y / z);
	double tmp;
	if (z <= -1.8e+48) {
		tmp = -2.0;
	} else if (z <= -3.8e-98) {
		tmp = t_1;
	} else if (z <= -6e-214) {
		tmp = t_0;
	} else if (z <= 4.4e-209) {
		tmp = t_1;
	} else if (z <= 6.6e+96) {
		tmp = t_0;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (4.0 / z)
	t_1 = -4.0 * (y / z)
	tmp = 0
	if z <= -1.8e+48:
		tmp = -2.0
	elif z <= -3.8e-98:
		tmp = t_1
	elif z <= -6e-214:
		tmp = t_0
	elif z <= 4.4e-209:
		tmp = t_1
	elif z <= 6.6e+96:
		tmp = t_0
	else:
		tmp = -2.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 (z <= -1.8e+48)
		tmp = -2.0;
	elseif (z <= -3.8e-98)
		tmp = t_1;
	elseif (z <= -6e-214)
		tmp = t_0;
	elseif (z <= 4.4e-209)
		tmp = t_1;
	elseif (z <= 6.6e+96)
		tmp = t_0;
	else
		tmp = -2.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 (z <= -1.8e+48)
		tmp = -2.0;
	elseif (z <= -3.8e-98)
		tmp = t_1;
	elseif (z <= -6e-214)
		tmp = t_0;
	elseif (z <= 4.4e-209)
		tmp = t_1;
	elseif (z <= 6.6e+96)
		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]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.8e+48], -2.0, If[LessEqual[z, -3.8e-98], t$95$1, If[LessEqual[z, -6e-214], t$95$0, If[LessEqual[z, 4.4e-209], t$95$1, If[LessEqual[z, 6.6e+96], t$95$0, -2.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -3.8 \cdot 10^{-98}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -6 \cdot 10^{-214}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{-209}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 6.6 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.79999999999999992e48 or 6.59999999999999969e96 < z

    1. Initial program 99.1%

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

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

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

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

    if -1.79999999999999992e48 < z < -3.8000000000000003e-98 or -5.99999999999999989e-214 < z < 4.40000000000000019e-209

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

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

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

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

    if -3.8000000000000003e-98 < z < -5.99999999999999989e-214 or 4.40000000000000019e-209 < z < 6.59999999999999969e96

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{4}{z} \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.8 \cdot 10^{+48}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-98}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-214}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-209}:\\ \;\;\;\;-4 \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 6.6 \cdot 10^{+96}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 53.1% 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}\;z \leq -1.36 \cdot 10^{+48}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-100}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-212}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-221}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ 4.0 z))) (t_1 (* y (/ -4.0 z))))
   (if (<= z -1.36e+48)
     -2.0
     (if (<= z -5e-100)
       t_1
       (if (<= z -2.7e-212)
         t_0
         (if (<= z 2.8e-221) t_1 (if (<= z 4.4e+96) t_0 -2.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 (z <= -1.36e+48) {
		tmp = -2.0;
	} else if (z <= -5e-100) {
		tmp = t_1;
	} else if (z <= -2.7e-212) {
		tmp = t_0;
	} else if (z <= 2.8e-221) {
		tmp = t_1;
	} else if (z <= 4.4e+96) {
		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) :: t_1
    real(8) :: tmp
    t_0 = x * (4.0d0 / z)
    t_1 = y * ((-4.0d0) / z)
    if (z <= (-1.36d+48)) then
        tmp = -2.0d0
    else if (z <= (-5d-100)) then
        tmp = t_1
    else if (z <= (-2.7d-212)) then
        tmp = t_0
    else if (z <= 2.8d-221) then
        tmp = t_1
    else if (z <= 4.4d+96) 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 t_1 = y * (-4.0 / z);
	double tmp;
	if (z <= -1.36e+48) {
		tmp = -2.0;
	} else if (z <= -5e-100) {
		tmp = t_1;
	} else if (z <= -2.7e-212) {
		tmp = t_0;
	} else if (z <= 2.8e-221) {
		tmp = t_1;
	} else if (z <= 4.4e+96) {
		tmp = t_0;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (4.0 / z)
	t_1 = y * (-4.0 / z)
	tmp = 0
	if z <= -1.36e+48:
		tmp = -2.0
	elif z <= -5e-100:
		tmp = t_1
	elif z <= -2.7e-212:
		tmp = t_0
	elif z <= 2.8e-221:
		tmp = t_1
	elif z <= 4.4e+96:
		tmp = t_0
	else:
		tmp = -2.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 (z <= -1.36e+48)
		tmp = -2.0;
	elseif (z <= -5e-100)
		tmp = t_1;
	elseif (z <= -2.7e-212)
		tmp = t_0;
	elseif (z <= 2.8e-221)
		tmp = t_1;
	elseif (z <= 4.4e+96)
		tmp = t_0;
	else
		tmp = -2.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 (z <= -1.36e+48)
		tmp = -2.0;
	elseif (z <= -5e-100)
		tmp = t_1;
	elseif (z <= -2.7e-212)
		tmp = t_0;
	elseif (z <= 2.8e-221)
		tmp = t_1;
	elseif (z <= 4.4e+96)
		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]}, Block[{t$95$1 = N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.36e+48], -2.0, If[LessEqual[z, -5e-100], t$95$1, If[LessEqual[z, -2.7e-212], t$95$0, If[LessEqual[z, 2.8e-221], t$95$1, If[LessEqual[z, 4.4e+96], t$95$0, -2.0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -5 \cdot 10^{-100}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -2.7 \cdot 10^{-212}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.8 \cdot 10^{-221}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 4.4 \cdot 10^{+96}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.3599999999999999e48 or 4.3999999999999998e96 < z

    1. Initial program 99.1%

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

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

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

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

    if -1.3599999999999999e48 < z < -5.0000000000000001e-100 or -2.69999999999999981e-212 < z < 2.80000000000000019e-221

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

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

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

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

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

        \[\leadsto -4 \cdot \color{blue}{\frac{1}{\frac{z}{y}}} \]
      3. un-div-inv62.6%

        \[\leadsto \color{blue}{\frac{-4}{\frac{z}{y}}} \]
    9. Applied egg-rr62.6%

      \[\leadsto \color{blue}{\frac{-4}{\frac{z}{y}}} \]
    10. Step-by-step derivation
      1. associate-/r/62.6%

        \[\leadsto \color{blue}{\frac{-4}{z} \cdot y} \]
    11. Applied egg-rr62.6%

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

    if -5.0000000000000001e-100 < z < -2.69999999999999981e-212 or 2.80000000000000019e-221 < z < 4.3999999999999998e96

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{4}{z} \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification64.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.36 \cdot 10^{+48}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-100}:\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-212}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{elif}\;z \leq 2.8 \cdot 10^{-221}:\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{+96}:\\ \;\;\;\;x \cdot \frac{4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 86.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+50} \lor \neg \left(y \leq 3.1 \cdot 10^{-19}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.7999999999999997e50 or 3.0999999999999999e-19 < y

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

    if -6.7999999999999997e50 < y < 3.0999999999999999e-19

    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. Step-by-step derivation
      1. expm1-log1p-u68.5%

        \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - x}{z} - -0.5\right)\right)} \]
      2. sub-neg68.5%

        \[\leadsto -4 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\color{blue}{\frac{y - x}{z} + \left(--0.5\right)}\right)\right) \]
      3. metadata-eval68.5%

        \[\leadsto -4 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - x}{z} + \color{blue}{0.5}\right)\right) \]
    6. Applied egg-rr68.5%

      \[\leadsto -4 \cdot \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{y - x}{z} + 0.5\right)\right)} \]
    7. Step-by-step derivation
      1. expm1-undefine68.5%

        \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{y - x}{z} + 0.5\right)} - 1\right)} \]
      2. sub-neg68.5%

        \[\leadsto -4 \cdot \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{y - x}{z} + 0.5\right)} + \left(-1\right)\right)} \]
      3. log1p-undefine68.5%

        \[\leadsto -4 \cdot \left(e^{\color{blue}{\log \left(1 + \left(\frac{y - x}{z} + 0.5\right)\right)}} + \left(-1\right)\right) \]
      4. rem-exp-log100.0%

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

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

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

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

        \[\leadsto -4 \cdot \left(\left(1.5 + \frac{y - x}{z}\right) + \color{blue}{-1}\right) \]
    8. Simplified100.0%

      \[\leadsto -4 \cdot \color{blue}{\left(\left(1.5 + \frac{y - x}{z}\right) + -1\right)} \]
    9. Taylor expanded in y around 0 92.9%

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

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

Alternative 6: 86.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+49} \lor \neg \left(y \leq 2.2 \cdot 10^{-18}\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 -1.55e+49) (not (<= y 2.2e-18)))
   (+ (* -4.0 (/ y z)) -2.0)
   (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.55e+49) || !(y <= 2.2e-18)) {
		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 <= (-1.55d+49)) .or. (.not. (y <= 2.2d-18))) 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 <= -1.55e+49) || !(y <= 2.2e-18)) {
		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 <= -1.55e+49) or not (y <= 2.2e-18):
		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 <= -1.55e+49) || !(y <= 2.2e-18))
		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 <= -1.55e+49) || ~((y <= 2.2e-18)))
		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, -1.55e+49], N[Not[LessEqual[y, 2.2e-18]], $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 -1.55 \cdot 10^{+49} \lor \neg \left(y \leq 2.2 \cdot 10^{-18}\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 < -1.54999999999999996e49 or 2.1999999999999998e-18 < y

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

    if -1.54999999999999996e49 < y < 2.1999999999999998e-18

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{+49} \lor \neg \left(y \leq 2.2 \cdot 10^{-18}\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.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+72} \lor \neg \left(y \leq 8.2 \cdot 10^{+129}\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 -5.2e+72) (not (<= y 8.2e+129)))
   (* -4.0 (/ (- y x) z))
   (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.2e+72) || !(y <= 8.2e+129)) {
		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 <= (-5.2d+72)) .or. (.not. (y <= 8.2d+129))) 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 <= -5.2e+72) || !(y <= 8.2e+129)) {
		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 <= -5.2e+72) or not (y <= 8.2e+129):
		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 <= -5.2e+72) || !(y <= 8.2e+129))
		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 <= -5.2e+72) || ~((y <= 8.2e+129)))
		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, -5.2e+72], N[Not[LessEqual[y, 8.2e+129]], $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 -5.2 \cdot 10^{+72} \lor \neg \left(y \leq 8.2 \cdot 10^{+129}\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 < -5.19999999999999963e72 or 8.2000000000000005e129 < y

    1. Initial program 98.7%

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

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

        \[\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 0 85.8%

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

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

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

    if -5.19999999999999963e72 < y < 8.2000000000000005e129

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+72} \lor \neg \left(y \leq 8.2 \cdot 10^{+129}\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: 80.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{+72} \lor \neg \left(y \leq 1.55 \cdot 10^{+165}\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 -6.8e+72) (not (<= y 1.55e+165)))
   (* -4.0 (/ y z))
   (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -6.8e+72) || !(y <= 1.55e+165)) {
		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 <= (-6.8d+72)) .or. (.not. (y <= 1.55d+165))) 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 <= -6.8e+72) || !(y <= 1.55e+165)) {
		tmp = -4.0 * (y / z);
	} else {
		tmp = 4.0 * (-0.5 + (x / z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -6.8e+72) or not (y <= 1.55e+165):
		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 <= -6.8e+72) || !(y <= 1.55e+165))
		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 <= -6.8e+72) || ~((y <= 1.55e+165)))
		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, -6.8e+72], N[Not[LessEqual[y, 1.55e+165]], $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 -6.8 \cdot 10^{+72} \lor \neg \left(y \leq 1.55 \cdot 10^{+165}\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 < -6.7999999999999997e72 or 1.5500000000000001e165 < y

    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 inf 74.7%

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

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

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

    if -6.7999999999999997e72 < y < 1.5500000000000001e165

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 52.8% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;z \leq 1.15 \cdot 10^{+122}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.2999999999999997e51 or 1.15e122 < z

    1. Initial program 99.0%

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

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

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

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

    if -4.2999999999999997e51 < z < 1.15e122

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

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

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

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

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

        \[\leadsto -4 \cdot \color{blue}{\frac{1}{\frac{z}{y}}} \]
      3. un-div-inv44.3%

        \[\leadsto \color{blue}{\frac{-4}{\frac{z}{y}}} \]
    9. Applied egg-rr44.3%

      \[\leadsto \color{blue}{\frac{-4}{\frac{z}{y}}} \]
    10. Step-by-step derivation
      1. associate-/r/44.3%

        \[\leadsto \color{blue}{\frac{-4}{z} \cdot y} \]
    11. Applied egg-rr44.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+51}:\\ \;\;\;\;-2\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+122}:\\ \;\;\;\;y \cdot \frac{-4}{z}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 34.4% 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 99.6%

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

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

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

    \[\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 2024180 
(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))