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

Percentage Accurate: 100.0% → 100.0%
Time: 9.5s
Alternatives: 7
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 7 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. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 73.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-34}:\\
\;\;\;\;1 - \frac{x}{y}\\

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

\mathbf{elif}\;y \leq 5.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{x}{z - y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.70000000000000017e-34

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \frac{y}{y} - \color{blue}{\frac{x}{y}} \]
      2. *-inversesN/A

        \[\leadsto 1 - \frac{\color{blue}{x}}{y} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      4. /-lowering-/.f6477.4%

        \[\leadsto \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Simplified77.4%

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

    if -2.70000000000000017e-34 < y < -2.2e-225

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

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

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

        \[\leadsto \frac{-1 \cdot \left(y - x\right)}{\color{blue}{z}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(-1 \cdot \left(y - x\right)\right), \color{blue}{z}\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(y - x\right)\right)\right), z\right) \]
      4. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right), z\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + y\right)\right)\right), z\right) \]
      6. distribute-neg-inN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right), z\right) \]
      7. unsub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) - y\right), z\right) \]
      8. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x - y\right), z\right) \]
      9. --lowering--.f6482.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(x, y\right), z\right) \]
    7. Simplified82.9%

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

    if -2.2e-225 < y < 5.1999999999999998e143

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{y - z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. div-invN/A

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{1}{y - z}} \]
      2. flip--N/A

        \[\leadsto \frac{y \cdot y - x \cdot x}{y + x} \cdot \frac{\color{blue}{1}}{y - z} \]
      3. clear-numN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{\color{blue}{1}}{y - z} \]
      4. frac-2negN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{\mathsf{neg}\left(1\right)}{\color{blue}{\mathsf{neg}\left(\left(y - z\right)\right)}} \]
      5. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)} \]
      6. frac-timesN/A

        \[\leadsto \frac{1 \cdot -1}{\color{blue}{\frac{y + x}{y \cdot y - x \cdot x} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \color{blue}{\left(\frac{y + x}{y \cdot y - x \cdot x} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)\right)}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{y + x}{y \cdot y - x \cdot x}\right), \color{blue}{\left(\mathsf{neg}\left(\left(y - z\right)\right)\right)}\right)\right) \]
      10. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{1}{\frac{y \cdot y - x \cdot x}{y + x}}\right), \left(\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)\right)\right)\right) \]
      11. flip--N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{1}{y - x}\right), \left(\mathsf{neg}\left(\left(y - \color{blue}{z}\right)\right)\right)\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(y - x\right)\right), \left(\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)\right)\right)\right) \]
      13. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\mathsf{neg}\left(\left(y - \color{blue}{z}\right)\right)\right)\right)\right) \]
      14. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \color{blue}{\left(y - z\right)}\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right)\right)\right)\right) \]
      16. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{y}\right)\right)\right)\right) \]
      17. associate--r+N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\left(0 - \left(\mathsf{neg}\left(z\right)\right)\right) - \color{blue}{y}\right)\right)\right) \]
      18. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) - y\right)\right)\right) \]
      19. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(z - y\right)\right)\right) \]
      20. --lowering--.f6499.6%

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \mathsf{\_.f64}\left(z, \color{blue}{y}\right)\right)\right) \]
    6. Applied egg-rr99.6%

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

      \[\leadsto \color{blue}{\frac{x}{z - y}} \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(z - y\right)}\right) \]
      2. --lowering--.f6484.4%

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{\_.f64}\left(z, \color{blue}{y}\right)\right) \]
    9. Simplified84.4%

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

    if 5.1999999999999998e143 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{y}{y - z}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(y, \color{blue}{\left(y - z\right)}\right) \]
      2. --lowering--.f6496.1%

        \[\leadsto \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    7. Simplified96.1%

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

Alternative 3: 73.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-11}:\\
\;\;\;\;1 - \frac{x}{y}\\

\mathbf{elif}\;y \leq 5.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{x}{z - y}\\

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


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

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \frac{y}{y} - \color{blue}{\frac{x}{y}} \]
      2. *-inversesN/A

        \[\leadsto 1 - \frac{\color{blue}{x}}{y} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      4. /-lowering-/.f6478.4%

        \[\leadsto \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Simplified78.4%

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

    if -7.5e-11 < y < 5.1999999999999998e143

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{y - z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. div-invN/A

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{1}{y - z}} \]
      2. flip--N/A

        \[\leadsto \frac{y \cdot y - x \cdot x}{y + x} \cdot \frac{\color{blue}{1}}{y - z} \]
      3. clear-numN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{\color{blue}{1}}{y - z} \]
      4. frac-2negN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{\mathsf{neg}\left(1\right)}{\color{blue}{\mathsf{neg}\left(\left(y - z\right)\right)}} \]
      5. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)} \]
      6. frac-timesN/A

        \[\leadsto \frac{1 \cdot -1}{\color{blue}{\frac{y + x}{y \cdot y - x \cdot x} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \color{blue}{\left(\frac{y + x}{y \cdot y - x \cdot x} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)\right)}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{y + x}{y \cdot y - x \cdot x}\right), \color{blue}{\left(\mathsf{neg}\left(\left(y - z\right)\right)\right)}\right)\right) \]
      10. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{1}{\frac{y \cdot y - x \cdot x}{y + x}}\right), \left(\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)\right)\right)\right) \]
      11. flip--N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{1}{y - x}\right), \left(\mathsf{neg}\left(\left(y - \color{blue}{z}\right)\right)\right)\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(y - x\right)\right), \left(\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)\right)\right)\right) \]
      13. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\mathsf{neg}\left(\left(y - \color{blue}{z}\right)\right)\right)\right)\right) \]
      14. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \color{blue}{\left(y - z\right)}\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right)\right)\right)\right) \]
      16. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{y}\right)\right)\right)\right) \]
      17. associate--r+N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\left(0 - \left(\mathsf{neg}\left(z\right)\right)\right) - \color{blue}{y}\right)\right)\right) \]
      18. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) - y\right)\right)\right) \]
      19. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(z - y\right)\right)\right) \]
      20. --lowering--.f6499.6%

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \mathsf{\_.f64}\left(z, \color{blue}{y}\right)\right)\right) \]
    6. Applied egg-rr99.6%

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

      \[\leadsto \color{blue}{\frac{x}{z - y}} \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(z - y\right)}\right) \]
      2. --lowering--.f6480.2%

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{\_.f64}\left(z, \color{blue}{y}\right)\right) \]
    9. Simplified80.2%

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

    if 5.1999999999999998e143 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{y}{y - z}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(y, \color{blue}{\left(y - z\right)}\right) \]
      2. --lowering--.f6496.1%

        \[\leadsto \mathsf{/.f64}\left(y, \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    7. Simplified96.1%

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

Alternative 4: 74.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.0999999999999999e-11 or 1.15000000000000011e130 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \frac{y}{y} - \color{blue}{\frac{x}{y}} \]
      2. *-inversesN/A

        \[\leadsto 1 - \frac{\color{blue}{x}}{y} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      4. /-lowering-/.f6479.0%

        \[\leadsto \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Simplified79.0%

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

    if -2.0999999999999999e-11 < y < 1.15000000000000011e130

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{y - x}{y - z}} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. div-invN/A

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\frac{1}{y - z}} \]
      2. flip--N/A

        \[\leadsto \frac{y \cdot y - x \cdot x}{y + x} \cdot \frac{\color{blue}{1}}{y - z} \]
      3. clear-numN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{\color{blue}{1}}{y - z} \]
      4. frac-2negN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{\mathsf{neg}\left(1\right)}{\color{blue}{\mathsf{neg}\left(\left(y - z\right)\right)}} \]
      5. metadata-evalN/A

        \[\leadsto \frac{1}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \frac{-1}{\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)} \]
      6. frac-timesN/A

        \[\leadsto \frac{1 \cdot -1}{\color{blue}{\frac{y + x}{y \cdot y - x \cdot x} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{-1}{\color{blue}{\frac{y + x}{y \cdot y - x \cdot x}} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)} \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \color{blue}{\left(\frac{y + x}{y \cdot y - x \cdot x} \cdot \left(\mathsf{neg}\left(\left(y - z\right)\right)\right)\right)}\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{y + x}{y \cdot y - x \cdot x}\right), \color{blue}{\left(\mathsf{neg}\left(\left(y - z\right)\right)\right)}\right)\right) \]
      10. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{1}{\frac{y \cdot y - x \cdot x}{y + x}}\right), \left(\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)\right)\right)\right) \]
      11. flip--N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\left(\frac{1}{y - x}\right), \left(\mathsf{neg}\left(\left(y - \color{blue}{z}\right)\right)\right)\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \left(y - x\right)\right), \left(\mathsf{neg}\left(\color{blue}{\left(y - z\right)}\right)\right)\right)\right) \]
      13. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\mathsf{neg}\left(\left(y - \color{blue}{z}\right)\right)\right)\right)\right) \]
      14. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \color{blue}{\left(y - z\right)}\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \left(y + \color{blue}{\left(\mathsf{neg}\left(z\right)\right)}\right)\right)\right)\right) \]
      16. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(0 - \left(\left(\mathsf{neg}\left(z\right)\right) + \color{blue}{y}\right)\right)\right)\right) \]
      17. associate--r+N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\left(0 - \left(\mathsf{neg}\left(z\right)\right)\right) - \color{blue}{y}\right)\right)\right) \]
      18. neg-sub0N/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) - y\right)\right)\right) \]
      19. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \left(z - y\right)\right)\right) \]
      20. --lowering--.f6499.6%

        \[\leadsto \mathsf{/.f64}\left(-1, \mathsf{*.f64}\left(\mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(y, x\right)\right), \mathsf{\_.f64}\left(z, \color{blue}{y}\right)\right)\right) \]
    6. Applied egg-rr99.6%

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

      \[\leadsto \color{blue}{\frac{x}{z - y}} \]
    8. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{\left(z - y\right)}\right) \]
      2. --lowering--.f6481.0%

        \[\leadsto \mathsf{/.f64}\left(x, \mathsf{\_.f64}\left(z, \color{blue}{y}\right)\right) \]
    9. Simplified81.0%

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

Alternative 5: 71.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.2999999999999999e-35 or 1.35e-19 < y

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f6499.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified99.9%

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \frac{y}{y} - \color{blue}{\frac{x}{y}} \]
      2. *-inversesN/A

        \[\leadsto 1 - \frac{\color{blue}{x}}{y} \]
      3. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{\left(\frac{x}{y}\right)}\right) \]
      4. /-lowering-/.f6473.2%

        \[\leadsto \mathsf{\_.f64}\left(1, \mathsf{/.f64}\left(x, \color{blue}{y}\right)\right) \]
    7. Simplified73.2%

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

    if -2.2999999999999999e-35 < y < 1.35e-19

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{\frac{x}{z}} \]
    6. Step-by-step derivation
      1. /-lowering-/.f6477.4%

        \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{z}\right) \]
    7. Simplified77.4%

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

Alternative 6: 60.7% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.2999999999999998e-11 or 1.6999999999999999e71 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{1} \]
    6. Step-by-step derivation
      1. Simplified61.4%

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

      if -5.2999999999999998e-11 < y < 1.6999999999999999e71

      1. Initial program 100.0%

        \[\frac{x - y}{z - y} \]
      2. Step-by-step derivation
        1. sub-negN/A

          \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
        2. +-commutativeN/A

          \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
        3. neg-sub0N/A

          \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
        4. associate-+l-N/A

          \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
        5. sub0-negN/A

          \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
        6. distribute-frac-neg2N/A

          \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
        7. distribute-neg-fracN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
        8. sub-negN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
        9. +-commutativeN/A

          \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
        10. distribute-neg-outN/A

          \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
        11. remove-double-negN/A

          \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
        12. sub-negN/A

          \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
        13. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
        14. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
        15. --lowering--.f64100.0%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
      3. Simplified100.0%

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

        \[\leadsto \color{blue}{\frac{x}{z}} \]
      6. Step-by-step derivation
        1. /-lowering-/.f6469.0%

          \[\leadsto \mathsf{/.f64}\left(x, \color{blue}{z}\right) \]
      7. Simplified69.0%

        \[\leadsto \color{blue}{\frac{x}{z}} \]
    7. Recombined 2 regimes into one program.
    8. Add Preprocessing

    Alternative 7: 35.7% 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. sub-negN/A

        \[\leadsto \frac{x - y}{z + \color{blue}{\left(\mathsf{neg}\left(y\right)\right)}} \]
      2. +-commutativeN/A

        \[\leadsto \frac{x - y}{\left(\mathsf{neg}\left(y\right)\right) + \color{blue}{z}} \]
      3. neg-sub0N/A

        \[\leadsto \frac{x - y}{\left(0 - y\right) + z} \]
      4. associate-+l-N/A

        \[\leadsto \frac{x - y}{0 - \color{blue}{\left(y - z\right)}} \]
      5. sub0-negN/A

        \[\leadsto \frac{x - y}{\mathsf{neg}\left(\left(y - z\right)\right)} \]
      6. distribute-frac-neg2N/A

        \[\leadsto \mathsf{neg}\left(\frac{x - y}{y - z}\right) \]
      7. distribute-neg-fracN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x - y\right)\right)}{\color{blue}{y - z}} \]
      8. sub-negN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)\right)}{y - z} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)\right)}{y - z} \]
      10. distribute-neg-outN/A

        \[\leadsto \frac{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(y\right)\right)\right)\right) + \left(\mathsf{neg}\left(x\right)\right)}{\color{blue}{y} - z} \]
      11. remove-double-negN/A

        \[\leadsto \frac{y + \left(\mathsf{neg}\left(x\right)\right)}{y - z} \]
      12. sub-negN/A

        \[\leadsto \frac{y - x}{\color{blue}{y} - z} \]
      13. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(y - x\right), \color{blue}{\left(y - z\right)}\right) \]
      14. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \left(\color{blue}{y} - z\right)\right) \]
      15. --lowering--.f64100.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(y, x\right), \mathsf{\_.f64}\left(y, \color{blue}{z}\right)\right) \]
    3. Simplified100.0%

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

      \[\leadsto \color{blue}{1} \]
    6. Step-by-step derivation
      1. Simplified34.4%

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

      Developer Target 1: 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 2024149 
      (FPCore (x y z)
        :name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
        :precision binary64
      
        :alt
        (! :herbie-platform default (- (/ x (- z y)) (/ y (- z y))))
      
        (/ (- x y) (- z y)))