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

Percentage Accurate: 100.0% → 100.0%
Time: 7.0s
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, 0.6× speedup?

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

\\
\frac{y}{y - z} - \frac{x}{y - z}
\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. +-commutative100.0%

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

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

      \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
    5. sub0-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. Step-by-step derivation
    1. div-sub100.0%

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

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

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

Alternative 2: 61.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+87}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-56}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 8500:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.7e+87)
   1.0
   (if (<= y -4e-56) (/ (- x) y) (if (<= y 8500.0) (/ x z) 1.0))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.7e+87) {
		tmp = 1.0;
	} else if (y <= -4e-56) {
		tmp = -x / y;
	} else if (y <= 8500.0) {
		tmp = x / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-2.7d+87)) then
        tmp = 1.0d0
    else if (y <= (-4d-56)) then
        tmp = -x / y
    else if (y <= 8500.0d0) then
        tmp = x / z
    else
        tmp = 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -2.7e+87) {
		tmp = 1.0;
	} else if (y <= -4e-56) {
		tmp = -x / y;
	} else if (y <= 8500.0) {
		tmp = x / z;
	} else {
		tmp = 1.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -2.7e+87:
		tmp = 1.0
	elif y <= -4e-56:
		tmp = -x / y
	elif y <= 8500.0:
		tmp = x / z
	else:
		tmp = 1.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -2.7e+87)
		tmp = 1.0;
	elseif (y <= -4e-56)
		tmp = Float64(Float64(-x) / y);
	elseif (y <= 8500.0)
		tmp = Float64(x / z);
	else
		tmp = 1.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -2.7e+87)
		tmp = 1.0;
	elseif (y <= -4e-56)
		tmp = -x / y;
	elseif (y <= 8500.0)
		tmp = x / z;
	else
		tmp = 1.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+87], 1.0, If[LessEqual[y, -4e-56], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 8500.0], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 8500:\\
\;\;\;\;\frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.70000000000000007e87 or 8500 < 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. +-commutative100.0%

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

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

        \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
      5. sub0-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.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 63.2%

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

    if -2.70000000000000007e87 < y < -4.0000000000000002e-56

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\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/99.9%

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

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

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

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

        \[\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/99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.0000000000000002e-56 < y < 8500

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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/99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+87}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-56}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 8500:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 71.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-62} \lor \neg \left(y \leq 0.0155\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.1999999999999998e-62 or 0.0155 < 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. +-commutative100.0%

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

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

        \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
      5. sub0-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.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 75.6%

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

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

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

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

    if -4.1999999999999998e-62 < y < 0.0155

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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/99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{-62} \lor \neg \left(y \leq 0.0155\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.0% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6e61 or 3.1999999999999999e25 < 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. +-commutative100.0%

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

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

        \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
      5. sub0-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 inf 85.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6e61 < z < 3.1999999999999999e25

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\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/99.9%

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

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

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

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

        \[\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/99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 70.8% accurate, 0.8× speedup?

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

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

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

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


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

    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. +-commutative100.0%

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

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

        \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
      5. sub0-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 75.1%

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

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

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

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

    if -3.59999999999999978e-56 < y < 6.39999999999999991e-117

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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/99.9%

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

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

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

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

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

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

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

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

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

    if 6.39999999999999991e-117 < 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. +-commutative100.0%

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

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

        \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
      5. sub0-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.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 74.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{-56}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 6.4 \cdot 10^{-117}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 62.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;y \leq 3.5:\\
\;\;\;\;\frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.59999999999999978e-56 or 3.5 < 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. +-commutative100.0%

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

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

        \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
      5. sub0-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.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 55.4%

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

    if -3.59999999999999978e-56 < y < 3.5

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\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/99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{-56}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3.5:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 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 8: 34.9% 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. +-commutative100.0%

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

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

      \[\leadsto \frac{x - y}{\color{blue}{0 - \left(y - z\right)}} \]
    5. sub0-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 32.2%

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

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