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

Percentage Accurate: 100.0% → 100.0%
Time: 8.5s
Alternatives: 8
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 8 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. Final simplification100.0%

    \[\leadsto \frac{x - y}{z - y} \]
  4. Add Preprocessing

Alternative 2: 58.3% accurate, 0.2× speedup?

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

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

\mathbf{elif}\;y \leq -1.12 \cdot 10^{+18}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq -5.5 \cdot 10^{-37}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+42}:\\
\;\;\;\;t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.19999999999999936e62 or -1.12e18 < y < -5.4999999999999998e-37 or 1.6499999999999999e49 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    if -9.19999999999999936e62 < y < -1.12e18 or 2.10000000000000004e-153 < y < 1.04999999999999998e42

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Taylor expanded in y around 0 43.9%

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

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

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

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

    if -5.4999999999999998e-37 < y < 2.10000000000000004e-153 or 1.04999999999999998e42 < y < 1.6499999999999999e49

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+62}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{+18}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-37}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+42}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+49}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 68.3% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;y \leq 9.8 \cdot 10^{-80}:\\
\;\;\;\;\frac{-x}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.55000000000000008e-65 or 2.8499999999999999e-52 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    if -1.55000000000000008e-65 < y < 2.10000000000000004e-153 or 9.79999999999999981e-80 < y < 2.8499999999999999e-52

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    if 2.10000000000000004e-153 < y < 9.79999999999999981e-80

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Taylor expanded in y around 0 59.2%

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

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

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    8. Simplified59.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-80}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 2.85 \cdot 10^{-52}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 72.4% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := \frac{x - y}{z}\\
\mathbf{if}\;y \leq -3.8 \cdot 10^{-35}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;y \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -3.8000000000000001e-35 or 4.1e49 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    if -3.8000000000000001e-35 < y < 2.10000000000000004e-153 or 3.30000000000000022e-82 < y < 4.1e49

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.10000000000000004e-153 < y < 3.30000000000000022e-82

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - x}{y}} \]
    6. Taylor expanded in y around 0 59.2%

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

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

        \[\leadsto \color{blue}{\frac{-x}{y}} \]
    8. Simplified59.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{-35}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{-82}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+49}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-35}:\\
\;\;\;\;\frac{y - x}{y}\\

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

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


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

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    if -4.3000000000000002e-35 < y < 2.79999999999999998e94

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

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

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

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

    if 2.79999999999999998e94 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{-35}:\\ \;\;\;\;\frac{y - x}{y}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+94}:\\ \;\;\;\;\frac{-x}{y - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 74.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-61} \lor \neg \left(z \leq 7.6 \cdot 10^{+74}\right):\\
\;\;\;\;\frac{x - y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.50000000000000016e-61 or 7.5999999999999997e74 < z

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -8.50000000000000016e-61 < z < 7.5999999999999997e74

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{-61} \lor \neg \left(z \leq 7.6 \cdot 10^{+74}\right):\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y - x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.0% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.8999999999999999e-38 or 1.45e52 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    if -3.8999999999999999e-38 < y < 1.45e52

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
      8. div-sub100.0%

        \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
      9. remove-double-neg100.0%

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

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

        \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
      12. associate-/r/100.0%

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

        \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
      14. *-lft-identity100.0%

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

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

        \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
      17. associate-/l*99.9%

        \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
      18. associate-/r/100.0%

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

        \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
      20. *-lft-identity100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.9 \cdot 10^{-38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 34.4% 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-neg100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{x - y}{-1}}{y - z}} \]
    8. div-sub100.0%

      \[\leadsto \frac{\color{blue}{\frac{x}{-1} - \frac{y}{-1}}}{y - z} \]
    9. remove-double-neg100.0%

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

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

      \[\leadsto \frac{\color{blue}{\frac{-1}{\frac{-1}{-x}}} - \frac{y}{-1}}{y - z} \]
    12. associate-/r/100.0%

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

      \[\leadsto \frac{\color{blue}{1} \cdot \left(-x\right) - \frac{y}{-1}}{y - z} \]
    14. *-lft-identity100.0%

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

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

      \[\leadsto \frac{\left(-x\right) - \frac{\color{blue}{-1 \cdot \left(-y\right)}}{-1}}{y - z} \]
    17. associate-/l*99.9%

      \[\leadsto \frac{\left(-x\right) - \color{blue}{\frac{-1}{\frac{-1}{-y}}}}{y - z} \]
    18. associate-/r/100.0%

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

      \[\leadsto \frac{\left(-x\right) - \color{blue}{1} \cdot \left(-y\right)}{y - z} \]
    20. *-lft-identity100.0%

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

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

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

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

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

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

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

    \[\leadsto 1 \]
  7. Add Preprocessing

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 2024019 
(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)))