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

Percentage Accurate: 100.0% → 100.0%
Time: 7.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, 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. 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.8%

      \[\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: 70.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-55}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+18}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+108} \lor \neg \left(y \leq 6.5 \cdot 10^{+231}\right):\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -1.8e-55)
     t_0
     (if (<= y 6.6e+18)
       (/ x z)
       (if (or (<= y 2.1e+108) (not (<= y 6.5e+231))) (/ y (- y z)) t_0)))))
double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -1.8e-55) {
		tmp = t_0;
	} else if (y <= 6.6e+18) {
		tmp = x / z;
	} else if ((y <= 2.1e+108) || !(y <= 6.5e+231)) {
		tmp = y / (y - z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-1.8d-55)) then
        tmp = t_0
    else if (y <= 6.6d+18) then
        tmp = x / z
    else if ((y <= 2.1d+108) .or. (.not. (y <= 6.5d+231))) then
        tmp = y / (y - z)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -1.8e-55) {
		tmp = t_0;
	} else if (y <= 6.6e+18) {
		tmp = x / z;
	} else if ((y <= 2.1e+108) || !(y <= 6.5e+231)) {
		tmp = y / (y - z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -1.8e-55:
		tmp = t_0
	elif y <= 6.6e+18:
		tmp = x / z
	elif (y <= 2.1e+108) or not (y <= 6.5e+231):
		tmp = y / (y - z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -1.8e-55)
		tmp = t_0;
	elseif (y <= 6.6e+18)
		tmp = Float64(x / z);
	elseif ((y <= 2.1e+108) || !(y <= 6.5e+231))
		tmp = Float64(y / Float64(y - z));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -1.8e-55)
		tmp = t_0;
	elseif (y <= 6.6e+18)
		tmp = x / z;
	elseif ((y <= 2.1e+108) || ~((y <= 6.5e+231)))
		tmp = y / (y - z);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e-55], t$95$0, If[LessEqual[y, 6.6e+18], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 2.1e+108], N[Not[LessEqual[y, 6.5e+231]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 2.1 \cdot 10^{+108} \lor \neg \left(y \leq 6.5 \cdot 10^{+231}\right):\\
\;\;\;\;\frac{y}{y - z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.8e-55 or 2.1000000000000001e108 < y < 6.49999999999999933e231

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

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

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

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

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

    if -1.8e-55 < y < 6.6e18

    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. remove-double-neg99.9%

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

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

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

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

    if 6.6e18 < y < 2.1000000000000001e108 or 6.49999999999999933e231 < 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.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 87.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-55}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+18}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{+108} \lor \neg \left(y \leq 6.5 \cdot 10^{+231}\right):\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.8% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+50}:\\
\;\;\;\;\frac{x - y}{z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.79999999999999987e50

    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. remove-double-neg99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.79999999999999987e50 < z < 1.4e44

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

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

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

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

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

    if 1.4e44 < z

    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. remove-double-neg99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{z} - \frac{y}{z}} \]
    12. Applied egg-rr77.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+50}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+44}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z} - \frac{y}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 71.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.3 \cdot 10^{-55} \lor \neg \left(y \leq 155000000\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -4.3e-55) (not (<= y 155000000.0))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -4.3e-55) || !(y <= 155000000.0)) {
		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.3d-55)) .or. (.not. (y <= 155000000.0d0))) 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.3e-55) || !(y <= 155000000.0)) {
		tmp = 1.0 - (x / y);
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -4.3e-55) or not (y <= 155000000.0):
		tmp = 1.0 - (x / y)
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -4.3e-55) || !(y <= 155000000.0))
		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.3e-55) || ~((y <= 155000000.0)))
		tmp = 1.0 - (x / y);
	else
		tmp = x / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.3e-55], N[Not[LessEqual[y, 155000000.0]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-55} \lor \neg \left(y \leq 155000000\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.3000000000000001e-55 or 1.55e8 < 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 z around 0 73.2%

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

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

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

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

    if -4.3000000000000001e-55 < y < 1.55e8

    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. remove-double-neg99.9%

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

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

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

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

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

Alternative 5: 74.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -9.6 \cdot 10^{+48} \lor \neg \left(z \leq 1.9 \cdot 10^{+44}\right):\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -9.6e+48) (not (<= z 1.9e+44))) (/ (- x y) z) (- 1.0 (/ x y))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -9.6e+48) || !(z <= 1.9e+44)) {
		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 <= (-9.6d+48)) .or. (.not. (z <= 1.9d+44))) 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 <= -9.6e+48) || !(z <= 1.9e+44)) {
		tmp = (x - y) / z;
	} else {
		tmp = 1.0 - (x / y);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -9.6e+48) or not (z <= 1.9e+44):
		tmp = (x - y) / z
	else:
		tmp = 1.0 - (x / y)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -9.6e+48) || !(z <= 1.9e+44))
		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 <= -9.6e+48) || ~((z <= 1.9e+44)))
		tmp = (x - y) / z;
	else
		tmp = 1.0 - (x / y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.6e+48], N[Not[LessEqual[z, 1.9e+44]], $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 -9.6 \cdot 10^{+48} \lor \neg \left(z \leq 1.9 \cdot 10^{+44}\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 < -9.6000000000000004e48 or 1.9000000000000001e44 < z

    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. remove-double-neg99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.6000000000000004e48 < z < 1.9000000000000001e44

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

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

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

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

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

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

Alternative 6: 62.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -26.5:\\
\;\;\;\;1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -26.5 or 1.9999999999999999e45 < 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 58.9%

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

    if -26.5 < y < 1.9999999999999999e45

    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. remove-double-neg99.9%

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

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

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

      \[\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 -26.5:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+45}:\\ \;\;\;\;\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: 35.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. 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.8%

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

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

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