Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1

Percentage Accurate: 100.0% → 100.0%
Time: 6.5s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
\frac{x - y}{z - y}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x - y}{z - y}
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x - y}{z - y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{z - y} \]
  2. Final simplification100.0%

    \[\leadsto \frac{x - y}{z - y} \]

Alternative 2: 74.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-x}{y - z}\\ \mathbf{if}\;x \leq -5.4 \cdot 10^{+208}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4 \cdot 10^{+162}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-9} \lor \neg \left(x \leq -6.5 \cdot 10^{-86} \lor \neg \left(x \leq -3.8 \cdot 10^{-121}\right) \land x \leq 3 \cdot 10^{+79}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (- x) (- y z))))
   (if (<= x -5.4e+208)
     t_0
     (if (<= x -4e+162)
       (- 1.0 (/ x y))
       (if (or (<= x -5.8e-9)
               (not
                (or (<= x -6.5e-86)
                    (and (not (<= x -3.8e-121)) (<= x 3e+79)))))
         t_0
         (/ y (- y z)))))))
double code(double x, double y, double z) {
	double t_0 = -x / (y - z);
	double tmp;
	if (x <= -5.4e+208) {
		tmp = t_0;
	} else if (x <= -4e+162) {
		tmp = 1.0 - (x / y);
	} else if ((x <= -5.8e-9) || !((x <= -6.5e-86) || (!(x <= -3.8e-121) && (x <= 3e+79)))) {
		tmp = t_0;
	} else {
		tmp = y / (y - z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -x / (y - z)
    if (x <= (-5.4d+208)) then
        tmp = t_0
    else if (x <= (-4d+162)) then
        tmp = 1.0d0 - (x / y)
    else if ((x <= (-5.8d-9)) .or. (.not. (x <= (-6.5d-86)) .or. (.not. (x <= (-3.8d-121))) .and. (x <= 3d+79))) then
        tmp = t_0
    else
        tmp = y / (y - z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -x / (y - z);
	double tmp;
	if (x <= -5.4e+208) {
		tmp = t_0;
	} else if (x <= -4e+162) {
		tmp = 1.0 - (x / y);
	} else if ((x <= -5.8e-9) || !((x <= -6.5e-86) || (!(x <= -3.8e-121) && (x <= 3e+79)))) {
		tmp = t_0;
	} else {
		tmp = y / (y - z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -x / (y - z)
	tmp = 0
	if x <= -5.4e+208:
		tmp = t_0
	elif x <= -4e+162:
		tmp = 1.0 - (x / y)
	elif (x <= -5.8e-9) or not ((x <= -6.5e-86) or (not (x <= -3.8e-121) and (x <= 3e+79))):
		tmp = t_0
	else:
		tmp = y / (y - z)
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-x) / Float64(y - z))
	tmp = 0.0
	if (x <= -5.4e+208)
		tmp = t_0;
	elseif (x <= -4e+162)
		tmp = Float64(1.0 - Float64(x / y));
	elseif ((x <= -5.8e-9) || !((x <= -6.5e-86) || (!(x <= -3.8e-121) && (x <= 3e+79))))
		tmp = t_0;
	else
		tmp = Float64(y / Float64(y - z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -x / (y - z);
	tmp = 0.0;
	if (x <= -5.4e+208)
		tmp = t_0;
	elseif (x <= -4e+162)
		tmp = 1.0 - (x / y);
	elseif ((x <= -5.8e-9) || ~(((x <= -6.5e-86) || (~((x <= -3.8e-121)) && (x <= 3e+79)))))
		tmp = t_0;
	else
		tmp = y / (y - z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.4e+208], t$95$0, If[LessEqual[x, -4e+162], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -5.8e-9], N[Not[Or[LessEqual[x, -6.5e-86], And[N[Not[LessEqual[x, -3.8e-121]], $MachinePrecision], LessEqual[x, 3e+79]]]], $MachinePrecision]], t$95$0, N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-x}{y - z}\\
\mathbf{if}\;x \leq -5.4 \cdot 10^{+208}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -4 \cdot 10^{+162}:\\
\;\;\;\;1 - \frac{x}{y}\\

\mathbf{elif}\;x \leq -5.8 \cdot 10^{-9} \lor \neg \left(x \leq -6.5 \cdot 10^{-86} \lor \neg \left(x \leq -3.8 \cdot 10^{-121}\right) \land x \leq 3 \cdot 10^{+79}\right):\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -5.4e208 or -3.9999999999999998e162 < x < -5.79999999999999982e-9 or -6.50000000000000028e-86 < x < -3.8000000000000001e-121 or 2.99999999999999974e79 < x

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.6%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y - z}} \]
    5. Step-by-step derivation
      1. neg-mul-188.0%

        \[\leadsto \color{blue}{-\frac{x}{y - z}} \]
      2. distribute-neg-frac88.0%

        \[\leadsto \color{blue}{\frac{-x}{y - z}} \]
    6. Simplified88.0%

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

    if -5.4e208 < x < -3.9999999999999998e162

    1. Initial program 99.8%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity99.8%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval99.8%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.7%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*99.8%

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

        \[\leadsto \frac{\color{blue}{-\left(x - y\right)}}{y - z} \]
      13. sub-neg99.8%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{y - z} \]
      14. distribute-neg-out99.8%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{y - z} \]
      15. remove-double-neg99.8%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{y - z} \]
      16. +-commutative99.8%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{y - z} \]
      17. sub-neg99.8%

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified99.8%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    5. Step-by-step derivation
      1. div-sub80.2%

        \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
      2. *-inverses80.2%

        \[\leadsto \color{blue}{1} - \frac{x}{y} \]
    6. Simplified80.2%

      \[\leadsto \color{blue}{1 - \frac{x}{y}} \]

    if -5.79999999999999982e-9 < x < -6.50000000000000028e-86 or -3.8000000000000001e-121 < x < 2.99999999999999974e79

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.7%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.7%

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

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.4 \cdot 10^{+208}:\\ \;\;\;\;\frac{-x}{y - z}\\ \mathbf{elif}\;x \leq -4 \cdot 10^{+162}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;x \leq -5.8 \cdot 10^{-9} \lor \neg \left(x \leq -6.5 \cdot 10^{-86} \lor \neg \left(x \leq -3.8 \cdot 10^{-121}\right) \land x \leq 3 \cdot 10^{+79}\right):\\ \;\;\;\;\frac{-x}{y - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]

Alternative 3: 64.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - z}\\ \mathbf{if}\;z \leq -3.6 \cdot 10^{+196}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{+93}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -1.26 \cdot 10^{+67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -0.0135:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+40}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{+200}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (- y z))))
   (if (<= z -3.6e+196)
     t_0
     (if (<= z -4.8e+93)
       (/ x z)
       (if (<= z -1.26e+67)
         t_0
         (if (<= z -0.0135)
           (/ x z)
           (if (<= z 1.05e+40)
             (- 1.0 (/ x y))
             (if (<= z 4.9e+200) t_0 (/ x z)))))))))
double code(double x, double y, double z) {
	double t_0 = y / (y - z);
	double tmp;
	if (z <= -3.6e+196) {
		tmp = t_0;
	} else if (z <= -4.8e+93) {
		tmp = x / z;
	} else if (z <= -1.26e+67) {
		tmp = t_0;
	} else if (z <= -0.0135) {
		tmp = x / z;
	} else if (z <= 1.05e+40) {
		tmp = 1.0 - (x / y);
	} else if (z <= 4.9e+200) {
		tmp = t_0;
	} else {
		tmp = 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) :: t_0
    real(8) :: tmp
    t_0 = y / (y - z)
    if (z <= (-3.6d+196)) then
        tmp = t_0
    else if (z <= (-4.8d+93)) then
        tmp = x / z
    else if (z <= (-1.26d+67)) then
        tmp = t_0
    else if (z <= (-0.0135d0)) then
        tmp = x / z
    else if (z <= 1.05d+40) then
        tmp = 1.0d0 - (x / y)
    else if (z <= 4.9d+200) then
        tmp = t_0
    else
        tmp = x / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y / (y - z);
	double tmp;
	if (z <= -3.6e+196) {
		tmp = t_0;
	} else if (z <= -4.8e+93) {
		tmp = x / z;
	} else if (z <= -1.26e+67) {
		tmp = t_0;
	} else if (z <= -0.0135) {
		tmp = x / z;
	} else if (z <= 1.05e+40) {
		tmp = 1.0 - (x / y);
	} else if (z <= 4.9e+200) {
		tmp = t_0;
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y / (y - z)
	tmp = 0
	if z <= -3.6e+196:
		tmp = t_0
	elif z <= -4.8e+93:
		tmp = x / z
	elif z <= -1.26e+67:
		tmp = t_0
	elif z <= -0.0135:
		tmp = x / z
	elif z <= 1.05e+40:
		tmp = 1.0 - (x / y)
	elif z <= 4.9e+200:
		tmp = t_0
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	t_0 = Float64(y / Float64(y - z))
	tmp = 0.0
	if (z <= -3.6e+196)
		tmp = t_0;
	elseif (z <= -4.8e+93)
		tmp = Float64(x / z);
	elseif (z <= -1.26e+67)
		tmp = t_0;
	elseif (z <= -0.0135)
		tmp = Float64(x / z);
	elseif (z <= 1.05e+40)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (z <= 4.9e+200)
		tmp = t_0;
	else
		tmp = Float64(x / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y / (y - z);
	tmp = 0.0;
	if (z <= -3.6e+196)
		tmp = t_0;
	elseif (z <= -4.8e+93)
		tmp = x / z;
	elseif (z <= -1.26e+67)
		tmp = t_0;
	elseif (z <= -0.0135)
		tmp = x / z;
	elseif (z <= 1.05e+40)
		tmp = 1.0 - (x / y);
	elseif (z <= 4.9e+200)
		tmp = t_0;
	else
		tmp = x / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.6e+196], t$95$0, If[LessEqual[z, -4.8e+93], N[(x / z), $MachinePrecision], If[LessEqual[z, -1.26e+67], t$95$0, If[LessEqual[z, -0.0135], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.05e+40], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.9e+200], t$95$0, N[(x / z), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+196}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -4.8 \cdot 10^{+93}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq -1.26 \cdot 10^{+67}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -0.0135:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;z \leq 1.05 \cdot 10^{+40}:\\
\;\;\;\;1 - \frac{x}{y}\\

\mathbf{elif}\;z \leq 4.9 \cdot 10^{+200}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.60000000000000007e196 or -4.80000000000000021e93 < z < -1.26e67 or 1.05000000000000005e40 < z < 4.89999999999999982e200

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.7%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.6%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    if -3.60000000000000007e196 < z < -4.80000000000000021e93 or -1.26e67 < z < -0.0134999999999999998 or 4.89999999999999982e200 < z

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.6%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    if -0.0134999999999999998 < z < 1.05000000000000005e40

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.7%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.7%

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

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    5. Step-by-step derivation
      1. div-sub78.3%

        \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
      2. *-inverses78.3%

        \[\leadsto \color{blue}{1} - \frac{x}{y} \]
    6. Simplified78.3%

      \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification77.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{+196}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{+93}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq -1.26 \cdot 10^{+67}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;z \leq -0.0135:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;z \leq 1.05 \cdot 10^{+40}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{+200}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]

Alternative 4: 55.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+226}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1350:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-90}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{-45}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 2.55 \cdot 10^{+30}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.05e+226)
   1.0
   (if (<= y -1350.0)
     (/ (- x) y)
     (if (<= y 7.8e-90)
       (/ x z)
       (if (<= y 1.16e-45) (/ y (- z)) (if (<= y 2.55e+30) (/ x z) 1.0))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.05e+226) {
		tmp = 1.0;
	} else if (y <= -1350.0) {
		tmp = -x / y;
	} else if (y <= 7.8e-90) {
		tmp = x / z;
	} else if (y <= 1.16e-45) {
		tmp = y / -z;
	} else if (y <= 2.55e+30) {
		tmp = x / z;
	} else {
		tmp = 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 <= (-1.05d+226)) then
        tmp = 1.0d0
    else if (y <= (-1350.0d0)) then
        tmp = -x / y
    else if (y <= 7.8d-90) then
        tmp = x / z
    else if (y <= 1.16d-45) then
        tmp = y / -z
    else if (y <= 2.55d+30) then
        tmp = x / z
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.05e+226) {
		tmp = 1.0;
	} else if (y <= -1350.0) {
		tmp = -x / y;
	} else if (y <= 7.8e-90) {
		tmp = x / z;
	} else if (y <= 1.16e-45) {
		tmp = y / -z;
	} else if (y <= 2.55e+30) {
		tmp = x / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.05e+226:
		tmp = 1.0
	elif y <= -1350.0:
		tmp = -x / y
	elif y <= 7.8e-90:
		tmp = x / z
	elif y <= 1.16e-45:
		tmp = y / -z
	elif y <= 2.55e+30:
		tmp = x / z
	else:
		tmp = 1.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.05e+226)
		tmp = 1.0;
	elseif (y <= -1350.0)
		tmp = Float64(Float64(-x) / y);
	elseif (y <= 7.8e-90)
		tmp = Float64(x / z);
	elseif (y <= 1.16e-45)
		tmp = Float64(y / Float64(-z));
	elseif (y <= 2.55e+30)
		tmp = Float64(x / z);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.05e+226)
		tmp = 1.0;
	elseif (y <= -1350.0)
		tmp = -x / y;
	elseif (y <= 7.8e-90)
		tmp = x / z;
	elseif (y <= 1.16e-45)
		tmp = y / -z;
	elseif (y <= 2.55e+30)
		tmp = x / z;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+226], 1.0, If[LessEqual[y, -1350.0], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 7.8e-90], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.16e-45], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 2.55e+30], N[(x / z), $MachinePrecision], 1.0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+226}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq -1350:\\
\;\;\;\;\frac{-x}{y}\\

\mathbf{elif}\;y \leq 7.8 \cdot 10^{-90}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;y \leq 1.16 \cdot 10^{-45}:\\
\;\;\;\;\frac{y}{-z}\\

\mathbf{elif}\;y \leq 2.55 \cdot 10^{+30}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.04999999999999997e226 or 2.55000000000000018e30 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval99.9%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.8%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*99.9%

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

        \[\leadsto \frac{\color{blue}{-\left(x - y\right)}}{y - z} \]
      13. sub-neg99.9%

        \[\leadsto \frac{-\color{blue}{\left(x + \left(-y\right)\right)}}{y - z} \]
      14. distribute-neg-out99.9%

        \[\leadsto \frac{\color{blue}{\left(-x\right) + \left(-\left(-y\right)\right)}}{y - z} \]
      15. remove-double-neg99.9%

        \[\leadsto \frac{\left(-x\right) + \color{blue}{y}}{y - z} \]
      16. +-commutative99.9%

        \[\leadsto \frac{\color{blue}{y + \left(-x\right)}}{y - z} \]
      17. sub-neg99.9%

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified99.9%

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

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

    if -1.04999999999999997e226 < y < -1350

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.7%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.7%

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

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    5. Step-by-step derivation
      1. div-sub70.2%

        \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
      2. *-inverses70.2%

        \[\leadsto \color{blue}{1} - \frac{x}{y} \]
    6. Simplified70.2%

      \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    7. Taylor expanded in x around inf 44.8%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y}} \]
    8. Step-by-step derivation
      1. associate-*r/44.8%

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{y}} \]
      2. mul-1-neg44.8%

        \[\leadsto \frac{\color{blue}{-x}}{y} \]
    9. Simplified44.8%

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

    if -1350 < y < 7.80000000000000009e-90 or 1.16000000000000002e-45 < y < 2.55000000000000018e30

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.7%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    if 7.80000000000000009e-90 < y < 1.16000000000000002e-45

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.8%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(y - x\right)}}{z} \]
      3. neg-sub060.7%

        \[\leadsto \frac{\color{blue}{0 - \left(y - x\right)}}{z} \]
      4. associate--r-60.7%

        \[\leadsto \frac{\color{blue}{\left(0 - y\right) + x}}{z} \]
      5. neg-sub060.7%

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

      \[\leadsto \color{blue}{\frac{\left(-y\right) + x}{z}} \]
    7. Taylor expanded in y around inf 48.8%

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

        \[\leadsto \color{blue}{\frac{-1 \cdot y}{z}} \]
      2. associate-*l/48.5%

        \[\leadsto \color{blue}{\frac{-1}{z} \cdot y} \]
      3. metadata-eval48.5%

        \[\leadsto \frac{\color{blue}{\frac{1}{-1}}}{z} \cdot y \]
      4. associate-/r*48.5%

        \[\leadsto \color{blue}{\frac{1}{-1 \cdot z}} \cdot y \]
      5. neg-mul-148.5%

        \[\leadsto \frac{1}{\color{blue}{-z}} \cdot y \]
      6. associate-*l/48.8%

        \[\leadsto \color{blue}{\frac{1 \cdot y}{-z}} \]
      7. *-lft-identity48.8%

        \[\leadsto \frac{\color{blue}{y}}{-z} \]
    9. Simplified48.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+226}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1350:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-90}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.16 \cdot 10^{-45}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 2.55 \cdot 10^{+30}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 5: 70.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7200 \lor \neg \left(y \leq -7.5 \cdot 10^{-33}\right) \land \left(y \leq -3.2 \cdot 10^{-83} \lor \neg \left(y \leq 1.8 \cdot 10^{-84}\right)\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -7200.0)
         (and (not (<= y -7.5e-33)) (or (<= y -3.2e-83) (not (<= y 1.8e-84)))))
   (- 1.0 (/ x y))
   (/ x z)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -7200.0) || (!(y <= -7.5e-33) && ((y <= -3.2e-83) || !(y <= 1.8e-84)))) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = 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 <= (-7200.0d0)) .or. (.not. (y <= (-7.5d-33))) .and. (y <= (-3.2d-83)) .or. (.not. (y <= 1.8d-84))) then
        tmp = 1.0d0 - (x / y)
    else
        tmp = x / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -7200.0) || (!(y <= -7.5e-33) && ((y <= -3.2e-83) || !(y <= 1.8e-84)))) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -7200.0) or (not (y <= -7.5e-33) and ((y <= -3.2e-83) or not (y <= 1.8e-84))):
		tmp = 1.0 - (x / y)
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -7200.0) || (!(y <= -7.5e-33) && ((y <= -3.2e-83) || !(y <= 1.8e-84))))
		tmp = Float64(1.0 - Float64(x / y));
	else
		tmp = Float64(x / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -7200.0) || (~((y <= -7.5e-33)) && ((y <= -3.2e-83) || ~((y <= 1.8e-84)))))
		tmp = 1.0 - (x / y);
	else
		tmp = x / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -7200.0], And[N[Not[LessEqual[y, -7.5e-33]], $MachinePrecision], Or[LessEqual[y, -3.2e-83], N[Not[LessEqual[y, 1.8e-84]], $MachinePrecision]]]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7200 \lor \neg \left(y \leq -7.5 \cdot 10^{-33}\right) \land \left(y \leq -3.2 \cdot 10^{-83} \lor \neg \left(y \leq 1.8 \cdot 10^{-84}\right)\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7200 or -7.5000000000000001e-33 < y < -3.2000000000000001e-83 or 1.80000000000000002e-84 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.8%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    5. Step-by-step derivation
      1. div-sub73.9%

        \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
      2. *-inverses73.9%

        \[\leadsto \color{blue}{1} - \frac{x}{y} \]
    6. Simplified73.9%

      \[\leadsto \color{blue}{1 - \frac{x}{y}} \]

    if -7200 < y < -7.5000000000000001e-33 or -3.2000000000000001e-83 < y < 1.80000000000000002e-84

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.7%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7200 \lor \neg \left(y \leq -7.5 \cdot 10^{-33}\right) \land \left(y \leq -3.2 \cdot 10^{-83} \lor \neg \left(y \leq 1.8 \cdot 10^{-84}\right)\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]

Alternative 6: 60.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-15}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-91}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-47}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.6e-15)
   1.0
   (if (<= y 4.2e-91)
     (/ x z)
     (if (<= y 5.6e-47) (/ y (- z)) (if (<= y 4.3e+28) (/ x z) 1.0)))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.6e-15) {
		tmp = 1.0;
	} else if (y <= 4.2e-91) {
		tmp = x / z;
	} else if (y <= 5.6e-47) {
		tmp = y / -z;
	} else if (y <= 4.3e+28) {
		tmp = x / z;
	} else {
		tmp = 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 <= (-2.6d-15)) then
        tmp = 1.0d0
    else if (y <= 4.2d-91) then
        tmp = x / z
    else if (y <= 5.6d-47) then
        tmp = y / -z
    else if (y <= 4.3d+28) then
        tmp = x / z
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.6e-15) {
		tmp = 1.0;
	} else if (y <= 4.2e-91) {
		tmp = x / z;
	} else if (y <= 5.6e-47) {
		tmp = y / -z;
	} else if (y <= 4.3e+28) {
		tmp = x / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2.6e-15:
		tmp = 1.0
	elif y <= 4.2e-91:
		tmp = x / z
	elif y <= 5.6e-47:
		tmp = y / -z
	elif y <= 4.3e+28:
		tmp = x / z
	else:
		tmp = 1.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2.6e-15)
		tmp = 1.0;
	elseif (y <= 4.2e-91)
		tmp = Float64(x / z);
	elseif (y <= 5.6e-47)
		tmp = Float64(y / Float64(-z));
	elseif (y <= 4.3e+28)
		tmp = Float64(x / z);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2.6e-15)
		tmp = 1.0;
	elseif (y <= 4.2e-91)
		tmp = x / z;
	elseif (y <= 5.6e-47)
		tmp = y / -z;
	elseif (y <= 4.3e+28)
		tmp = x / z;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2.6e-15], 1.0, If[LessEqual[y, 4.2e-91], N[(x / z), $MachinePrecision], If[LessEqual[y, 5.6e-47], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 4.3e+28], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{-15}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-91}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{elif}\;y \leq 5.6 \cdot 10^{-47}:\\
\;\;\;\;\frac{y}{-z}\\

\mathbf{elif}\;y \leq 4.3 \cdot 10^{+28}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.60000000000000004e-15 or 4.29999999999999975e28 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.8%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    if -2.60000000000000004e-15 < y < 4.1999999999999998e-91 or 5.59999999999999986e-47 < y < 4.29999999999999975e28

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.5%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.5%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.5%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    if 4.1999999999999998e-91 < y < 5.59999999999999986e-47

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.8%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(y - x\right)}}{z} \]
      3. neg-sub060.7%

        \[\leadsto \frac{\color{blue}{0 - \left(y - x\right)}}{z} \]
      4. associate--r-60.7%

        \[\leadsto \frac{\color{blue}{\left(0 - y\right) + x}}{z} \]
      5. neg-sub060.7%

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

      \[\leadsto \color{blue}{\frac{\left(-y\right) + x}{z}} \]
    7. Taylor expanded in y around inf 48.8%

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

        \[\leadsto \color{blue}{\frac{-1 \cdot y}{z}} \]
      2. associate-*l/48.5%

        \[\leadsto \color{blue}{\frac{-1}{z} \cdot y} \]
      3. metadata-eval48.5%

        \[\leadsto \frac{\color{blue}{\frac{1}{-1}}}{z} \cdot y \]
      4. associate-/r*48.5%

        \[\leadsto \color{blue}{\frac{1}{-1 \cdot z}} \cdot y \]
      5. neg-mul-148.5%

        \[\leadsto \frac{1}{\color{blue}{-z}} \cdot y \]
      6. associate-*l/48.8%

        \[\leadsto \color{blue}{\frac{1 \cdot y}{-z}} \]
      7. *-lft-identity48.8%

        \[\leadsto \frac{\color{blue}{y}}{-z} \]
    9. Simplified48.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-15}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-91}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-47}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 7: 76.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-9} \lor \neg \left(z \leq 5.2 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{x - y}{z}\\

\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.3999999999999998e-9 or 5.2e-47 < z

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.6%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

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

        \[\leadsto \frac{\color{blue}{-\left(y - x\right)}}{z} \]
      3. neg-sub075.7%

        \[\leadsto \frac{\color{blue}{0 - \left(y - x\right)}}{z} \]
      4. associate--r-75.7%

        \[\leadsto \frac{\color{blue}{\left(0 - y\right) + x}}{z} \]
      5. neg-sub075.7%

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

      \[\leadsto \color{blue}{\frac{\left(-y\right) + x}{z}} \]
    7. Taylor expanded in y around 0 75.7%

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{z} + \frac{x}{z}} \]
    8. Step-by-step derivation
      1. +-commutative75.7%

        \[\leadsto \color{blue}{\frac{x}{z} + -1 \cdot \frac{y}{z}} \]
      2. mul-1-neg75.7%

        \[\leadsto \frac{x}{z} + \color{blue}{\left(-\frac{y}{z}\right)} \]
      3. sub-neg75.7%

        \[\leadsto \color{blue}{\frac{x}{z} - \frac{y}{z}} \]
      4. div-sub75.7%

        \[\leadsto \color{blue}{\frac{x - y}{z}} \]
    9. Simplified75.7%

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

    if -3.3999999999999998e-9 < z < 5.2e-47

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.7%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.7%

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

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.7%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    5. Step-by-step derivation
      1. div-sub83.2%

        \[\leadsto \color{blue}{\frac{y}{y} - \frac{x}{y}} \]
      2. *-inverses83.2%

        \[\leadsto \color{blue}{1} - \frac{x}{y} \]
    6. Simplified83.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-9} \lor \neg \left(z \leq 5.2 \cdot 10^{-47}\right):\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 8: 60.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.36 \cdot 10^{-15}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.36e-15) 1.0 (if (<= y 4.6e+28) (/ x z) 1.0)))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.36e-15) {
		tmp = 1.0;
	} else if (y <= 4.6e+28) {
		tmp = x / z;
	} else {
		tmp = 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 <= (-1.36d-15)) then
        tmp = 1.0d0
    else if (y <= 4.6d+28) then
        tmp = x / z
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.36e-15) {
		tmp = 1.0;
	} else if (y <= 4.6e+28) {
		tmp = x / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.36e-15:
		tmp = 1.0
	elif y <= 4.6e+28:
		tmp = x / z
	else:
		tmp = 1.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.36e-15)
		tmp = 1.0;
	elseif (y <= 4.6e+28)
		tmp = Float64(x / z);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.36e-15)
		tmp = 1.0;
	elseif (y <= 4.6e+28)
		tmp = x / z;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.36e-15], 1.0, If[LessEqual[y, 4.6e+28], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.36 \cdot 10^{-15}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 4.6 \cdot 10^{+28}:\\
\;\;\;\;\frac{x}{z}\\

\mathbf{else}:\\
\;\;\;\;1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.36e-15 or 4.59999999999999968e28 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.9%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.8%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.8%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.8%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    if -1.36e-15 < y < 4.59999999999999968e28

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

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

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

        \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
      4. associate-/l*99.6%

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
      6. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(z + \left(-y\right)\right)}}{x - y}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
      8. distribute-neg-out99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
      9. remove-double-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.6%

        \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
      11. associate-/l*100.0%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
    3. Simplified100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.36 \cdot 10^{-15}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 34.8% accurate, 7.0× speedup?

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

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

    \[\frac{x - y}{z - y} \]
  2. Step-by-step derivation
    1. *-lft-identity100.0%

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

      \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
    3. associate-/r/99.8%

      \[\leadsto \color{blue}{\frac{-1}{\frac{-1}{\frac{x - y}{z - y}}}} \]
    4. associate-/l*99.7%

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

      \[\leadsto \frac{-1}{\frac{\color{blue}{-\left(z - y\right)}}{x - y}} \]
    6. sub-neg99.7%

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

      \[\leadsto \frac{-1}{\frac{-\color{blue}{\left(\left(-y\right) + z\right)}}{x - y}} \]
    8. distribute-neg-out99.7%

      \[\leadsto \frac{-1}{\frac{\color{blue}{\left(-\left(-y\right)\right) + \left(-z\right)}}{x - y}} \]
    9. remove-double-neg99.7%

      \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
    10. sub-neg99.7%

      \[\leadsto \frac{-1}{\frac{\color{blue}{y - z}}{x - y}} \]
    11. associate-/l*100.0%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{y - x}}{y - z} \]
  3. Simplified100.0%

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

    \[\leadsto \color{blue}{1} \]
  5. Final simplification35.0%

    \[\leadsto 1 \]

Developer target: 100.0% accurate, 0.6× speedup?

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

\\
\frac{x}{z - y} - \frac{y}{z - y}
\end{array}

Reproduce

?
herbie shell --seed 2023293 
(FPCore (x y z)
  :name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
  :precision binary64

  :herbie-target
  (- (/ x (- z y)) (/ y (- z y)))

  (/ (- x y) (- z y)))