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

Percentage Accurate: 100.0% → 100.0%
Time: 6.6s
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: 59.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 + \frac{z}{y}\\ t_1 := \frac{-y}{z}\\ \mathbf{if}\;y \leq -5 \cdot 10^{+93}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-51}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 0.0002:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ 1.0 (/ z y))) (t_1 (/ (- y) z)))
   (if (<= y -5e+93)
     t_0
     (if (<= y -6.5e-69)
       t_1
       (if (<= y 3.3e-51)
         (/ x z)
         (if (<= y 0.0002) 1.0 (if (<= y 2.4e+73) t_1 t_0)))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 + (z / y);
	double t_1 = -y / z;
	double tmp;
	if (y <= -5e+93) {
		tmp = t_0;
	} else if (y <= -6.5e-69) {
		tmp = t_1;
	} else if (y <= 3.3e-51) {
		tmp = x / z;
	} else if (y <= 0.0002) {
		tmp = 1.0;
	} else if (y <= 2.4e+73) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 + (z / y)
    t_1 = -y / z
    if (y <= (-5d+93)) then
        tmp = t_0
    else if (y <= (-6.5d-69)) then
        tmp = t_1
    else if (y <= 3.3d-51) then
        tmp = x / z
    else if (y <= 0.0002d0) then
        tmp = 1.0d0
    else if (y <= 2.4d+73) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 + (z / y);
	double t_1 = -y / z;
	double tmp;
	if (y <= -5e+93) {
		tmp = t_0;
	} else if (y <= -6.5e-69) {
		tmp = t_1;
	} else if (y <= 3.3e-51) {
		tmp = x / z;
	} else if (y <= 0.0002) {
		tmp = 1.0;
	} else if (y <= 2.4e+73) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 + (z / y)
	t_1 = -y / z
	tmp = 0
	if y <= -5e+93:
		tmp = t_0
	elif y <= -6.5e-69:
		tmp = t_1
	elif y <= 3.3e-51:
		tmp = x / z
	elif y <= 0.0002:
		tmp = 1.0
	elif y <= 2.4e+73:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 + Float64(z / y))
	t_1 = Float64(Float64(-y) / z)
	tmp = 0.0
	if (y <= -5e+93)
		tmp = t_0;
	elseif (y <= -6.5e-69)
		tmp = t_1;
	elseif (y <= 3.3e-51)
		tmp = Float64(x / z);
	elseif (y <= 0.0002)
		tmp = 1.0;
	elseif (y <= 2.4e+73)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 + (z / y);
	t_1 = -y / z;
	tmp = 0.0;
	if (y <= -5e+93)
		tmp = t_0;
	elseif (y <= -6.5e-69)
		tmp = t_1;
	elseif (y <= 3.3e-51)
		tmp = x / z;
	elseif (y <= 0.0002)
		tmp = 1.0;
	elseif (y <= 2.4e+73)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) / z), $MachinePrecision]}, If[LessEqual[y, -5e+93], t$95$0, If[LessEqual[y, -6.5e-69], t$95$1, If[LessEqual[y, 3.3e-51], N[(x / z), $MachinePrecision], If[LessEqual[y, 0.0002], 1.0, If[LessEqual[y, 2.4e+73], t$95$1, t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y}\\
t_1 := \frac{-y}{z}\\
\mathbf{if}\;y \leq -5 \cdot 10^{+93}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;y \leq 0.0002:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 2.4 \cdot 10^{+73}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -5.0000000000000001e93 or 2.40000000000000002e73 < 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.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 y around inf 86.7%

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{x}{y}\right) - -1 \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. associate--l+86.7%

        \[\leadsto \color{blue}{1 + \left(-1 \cdot \frac{x}{y} - -1 \cdot \frac{z}{y}\right)} \]
      2. distribute-lft-out--86.7%

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

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

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

        \[\leadsto \color{blue}{1 - \frac{x - z}{y}} \]
    6. Simplified86.7%

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

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

        \[\leadsto 1 - \color{blue}{\left(-\frac{z}{y}\right)} \]
      2. distribute-neg-frac66.7%

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

      \[\leadsto 1 - \color{blue}{\frac{-z}{y}} \]
    10. Step-by-step derivation
      1. div-inv66.7%

        \[\leadsto 1 - \color{blue}{\left(-z\right) \cdot \frac{1}{y}} \]
      2. cancel-sign-sub66.7%

        \[\leadsto \color{blue}{1 + z \cdot \frac{1}{y}} \]
      3. div-inv66.7%

        \[\leadsto 1 + \color{blue}{\frac{z}{y}} \]
      4. +-commutative66.7%

        \[\leadsto \color{blue}{\frac{z}{y} + 1} \]
    11. Applied egg-rr66.7%

      \[\leadsto \color{blue}{\frac{z}{y} + 1} \]

    if -5.0000000000000001e93 < y < -6.49999999999999951e-69 or 2.0000000000000001e-4 < y < 2.40000000000000002e73

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

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

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

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

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

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

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

      \[\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. mul-1-neg48.8%

        \[\leadsto \color{blue}{-\frac{y}{z}} \]
      2. distribute-neg-frac48.8%

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

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

    if -6.49999999999999951e-69 < y < 3.29999999999999973e-51

    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/98.6%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 84.4%

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

    if 3.29999999999999973e-51 < y < 2.0000000000000001e-4

    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.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 60.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+93}:\\ \;\;\;\;1 + \frac{z}{y}\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-51}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 0.0002:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+73}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{z}{y}\\ \end{array} \]

Alternative 3: 74.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x - y}{z}\\ t_1 := 1 + \frac{z - x}{y}\\ \mathbf{if}\;y \leq -20000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-50}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 12200:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+71}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (- x y) z)) (t_1 (+ 1.0 (/ (- z x) y))))
   (if (<= y -20000.0)
     t_1
     (if (<= y 1.1e-50)
       t_0
       (if (<= y 12200.0) (- 1.0 (/ x y)) (if (<= y 2.2e+71) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = (x - y) / z;
	double t_1 = 1.0 + ((z - x) / y);
	double tmp;
	if (y <= -20000.0) {
		tmp = t_1;
	} else if (y <= 1.1e-50) {
		tmp = t_0;
	} else if (y <= 12200.0) {
		tmp = 1.0 - (x / y);
	} else if (y <= 2.2e+71) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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 - y) / z
    t_1 = 1.0d0 + ((z - x) / y)
    if (y <= (-20000.0d0)) then
        tmp = t_1
    else if (y <= 1.1d-50) then
        tmp = t_0
    else if (y <= 12200.0d0) then
        tmp = 1.0d0 - (x / y)
    else if (y <= 2.2d+71) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (x - y) / z;
	double t_1 = 1.0 + ((z - x) / y);
	double tmp;
	if (y <= -20000.0) {
		tmp = t_1;
	} else if (y <= 1.1e-50) {
		tmp = t_0;
	} else if (y <= 12200.0) {
		tmp = 1.0 - (x / y);
	} else if (y <= 2.2e+71) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x - y) / z
	t_1 = 1.0 + ((z - x) / y)
	tmp = 0
	if y <= -20000.0:
		tmp = t_1
	elif y <= 1.1e-50:
		tmp = t_0
	elif y <= 12200.0:
		tmp = 1.0 - (x / y)
	elif y <= 2.2e+71:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(x - y) / z)
	t_1 = Float64(1.0 + Float64(Float64(z - x) / y))
	tmp = 0.0
	if (y <= -20000.0)
		tmp = t_1;
	elseif (y <= 1.1e-50)
		tmp = t_0;
	elseif (y <= 12200.0)
		tmp = Float64(1.0 - Float64(x / y));
	elseif (y <= 2.2e+71)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (x - y) / z;
	t_1 = 1.0 + ((z - x) / y);
	tmp = 0.0;
	if (y <= -20000.0)
		tmp = t_1;
	elseif (y <= 1.1e-50)
		tmp = t_0;
	elseif (y <= 12200.0)
		tmp = 1.0 - (x / y);
	elseif (y <= 2.2e+71)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -20000.0], t$95$1, If[LessEqual[y, 1.1e-50], t$95$0, If[LessEqual[y, 12200.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+71], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
t_1 := 1 + \frac{z - x}{y}\\
\mathbf{if}\;y \leq -20000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.1 \cdot 10^{-50}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 2.2 \cdot 10^{+71}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2e4 or 2.19999999999999995e71 < 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 82.8%

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \frac{x}{y}\right) - -1 \cdot \frac{z}{y}} \]
    5. Step-by-step derivation
      1. associate--l+82.8%

        \[\leadsto \color{blue}{1 + \left(-1 \cdot \frac{x}{y} - -1 \cdot \frac{z}{y}\right)} \]
      2. distribute-lft-out--82.8%

        \[\leadsto 1 + \color{blue}{-1 \cdot \left(\frac{x}{y} - \frac{z}{y}\right)} \]
      3. div-sub82.8%

        \[\leadsto 1 + -1 \cdot \color{blue}{\frac{x - z}{y}} \]
      4. mul-1-neg82.8%

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

        \[\leadsto \color{blue}{1 - \frac{x - z}{y}} \]
    6. Simplified82.8%

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

    if -2e4 < y < 1.0999999999999999e-50 or 12200 < y < 2.19999999999999995e71

    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/98.9%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 86.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0999999999999999e-50 < y < 12200

    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.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 87.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -20000:\\ \;\;\;\;1 + \frac{z - x}{y}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{-50}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;y \leq 12200:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+71}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{z - x}{y}\\ \end{array} \]

Alternative 4: 59.6% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 9 \cdot 10^{-5}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \leq 5.2 \cdot 10^{+54}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.34999999999999983e93 or 4.25000000000000006e-50 < y < 9.00000000000000057e-5 or 5.20000000000000013e54 < 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.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 y around inf 63.6%

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

    if -3.34999999999999983e93 < y < -6.49999999999999951e-69 or 9.00000000000000057e-5 < y < 5.20000000000000013e54

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{y}{z}} \]
    8. Step-by-step derivation
      1. mul-1-neg51.9%

        \[\leadsto \color{blue}{-\frac{y}{z}} \]
      2. distribute-neg-frac51.9%

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

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

    if -6.49999999999999951e-69 < y < 4.25000000000000006e-50

    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/98.6%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 84.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.35 \cdot 10^{+93}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{elif}\;y \leq 4.25 \cdot 10^{-50}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-5}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+54}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 5: 75.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -92000 \lor \neg \left(y \leq 9 \cdot 10^{-52} \lor \neg \left(y \leq 0.000155\right) \land y \leq 1.45 \cdot 10^{+52}\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -92000 or 9.0000000000000001e-52 < y < 1.55e-4 or 1.45e52 < 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.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 0 81.7%

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

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

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

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

    if -92000 < y < 9.0000000000000001e-52 or 1.55e-4 < y < 1.45e52

    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/98.8%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 inf 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -92000 \lor \neg \left(y \leq 9 \cdot 10^{-52} \lor \neg \left(y \leq 0.000155\right) \land y \leq 1.45 \cdot 10^{+52}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{z}\\ \end{array} \]

Alternative 6: 70.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -3.2 \cdot 10^{-49}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-50}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+23} \lor \neg \left(y \leq 1.4 \cdot 10^{+51}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -3.2e-49)
     t_0
     (if (<= y 1.45e-50)
       (/ x z)
       (if (or (<= y 6.5e+23) (not (<= y 1.4e+51))) t_0 (/ (- y) z))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -3.2e-49) {
		tmp = t_0;
	} else if (y <= 1.45e-50) {
		tmp = x / z;
	} else if ((y <= 6.5e+23) || !(y <= 1.4e+51)) {
		tmp = t_0;
	} else {
		tmp = -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 = 1.0d0 - (x / y)
    if (y <= (-3.2d-49)) then
        tmp = t_0
    else if (y <= 1.45d-50) then
        tmp = x / z
    else if ((y <= 6.5d+23) .or. (.not. (y <= 1.4d+51))) then
        tmp = t_0
    else
        tmp = -y / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -3.2e-49) {
		tmp = t_0;
	} else if (y <= 1.45e-50) {
		tmp = x / z;
	} else if ((y <= 6.5e+23) || !(y <= 1.4e+51)) {
		tmp = t_0;
	} else {
		tmp = -y / z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -3.2e-49:
		tmp = t_0
	elif y <= 1.45e-50:
		tmp = x / z
	elif (y <= 6.5e+23) or not (y <= 1.4e+51):
		tmp = t_0
	else:
		tmp = -y / z
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -3.2e-49)
		tmp = t_0;
	elseif (y <= 1.45e-50)
		tmp = Float64(x / z);
	elseif ((y <= 6.5e+23) || !(y <= 1.4e+51))
		tmp = t_0;
	else
		tmp = Float64(Float64(-y) / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -3.2e-49)
		tmp = t_0;
	elseif (y <= 1.45e-50)
		tmp = x / z;
	elseif ((y <= 6.5e+23) || ~((y <= 1.4e+51)))
		tmp = t_0;
	else
		tmp = -y / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.2e-49], t$95$0, If[LessEqual[y, 1.45e-50], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 6.5e+23], N[Not[LessEqual[y, 1.4e+51]], $MachinePrecision]], t$95$0, N[((-y) / z), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{-49}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+23} \lor \neg \left(y \leq 1.4 \cdot 10^{+51}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.20000000000000002e-49 or 1.45000000000000004e-50 < y < 6.4999999999999996e23 or 1.40000000000000002e51 < 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.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 0 79.1%

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

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

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

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

    if -3.20000000000000002e-49 < y < 1.45000000000000004e-50

    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/98.7%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 81.0%

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

    if 6.4999999999999996e23 < y < 1.40000000000000002e51

    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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{y}{z}} \]
      2. distribute-neg-frac61.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.2 \cdot 10^{-49}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-50}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+23} \lor \neg \left(y \leq 1.4 \cdot 10^{+51}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{-y}{z}\\ \end{array} \]

Alternative 7: 70.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-71}:\\
\;\;\;\;\frac{y}{y - z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.0000000000000003e-71

    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.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*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 x around 0 76.8%

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

    if -6.0000000000000003e-71 < y < 1.85e-50

    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/98.6%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 84.4%

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

    if 1.85e-50 < 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.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 z around 0 74.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{-71}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-50}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 8: 60.9% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.32e-48 or 1.0499999999999999e-49 < 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.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 y around inf 52.9%

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

    if -1.32e-48 < y < 1.0499999999999999e-49

    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/98.7%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg98.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 81.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.32 \cdot 10^{-48}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-49}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 9: 35.2% 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.4%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{1} \]
  5. Final simplification33.6%

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