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

Percentage Accurate: 100.0% → 100.0%
Time: 12.1s
Alternatives: 11
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 11 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. *-lft-identity100.0%

      \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
    2. metadata-eval100.0%

      \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
    3. associate-/r/99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 60.4% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq -3.2 \cdot 10^{-49}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;y \leq 2.15 \cdot 10^{-17}:\\
\;\;\;\;t_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.2000000000000002e51 or 2.3000000000000001e27 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{y}{y - z}} \]
    5. Taylor expanded in y around inf 71.3%

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

    if -9.2000000000000002e51 < y < -3.20000000000000002e-49 or 8e-107 < y < 2.15000000000000012e-17

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/98.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.20000000000000002e-49 < y < 8e-107 or 2.15000000000000012e-17 < y < 2.3000000000000001e27

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+51}:\\ \;\;\;\;1 + \frac{z}{y}\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{-49}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{-17}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+27}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{z}{y}\\ \end{array} \]

Alternative 3: 60.3% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-17}:\\
\;\;\;\;\frac{-x}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.55e-49 or 5.39999999999999983e51 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55e-49 < y < 9.79999999999999959e-107 or 3.2000000000000002e-17 < y < 5.39999999999999983e51

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 9.79999999999999959e-107 < y < 3.2000000000000002e-17

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/97.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.55 \cdot 10^{-49}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-17}:\\ \;\;\;\;\frac{-x}{y}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+51}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 4: 76.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6000000000000:\\
\;\;\;\;\frac{y}{y - z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6e12

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6e12 < y < 7.39999999999999994e56

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.39999999999999994e56 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6000000000000:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 7.4 \cdot 10^{+56}:\\ \;\;\;\;\frac{-x}{y - z}\\ \mathbf{else}:\\ \;\;\;\;1 + \frac{z - x}{y}\\ \end{array} \]

Alternative 5: 76.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -520000000:\\
\;\;\;\;\frac{y}{y - z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.2e8

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.2e8 < y < 6.99999999999999999e56

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.99999999999999999e56 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -520000000:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+56}:\\ \;\;\;\;\frac{-x}{y - z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 6: 72.2% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{-49} \lor \neg \left(y \leq 1.16 \cdot 10^{-107}\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.60000000000000001e-49 or 1.16e-107 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.60000000000000001e-49 < y < 1.16e-107

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-49} \lor \neg \left(y \leq 1.16 \cdot 10^{-107}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]

Alternative 7: 71.3% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 99.9%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity99.9%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval99.9%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.6000000000000001e-51 < y < 3.90000000000000023e-109

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.90000000000000023e-109 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.6 \cdot 10^{-51}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-109}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 8: 74.8% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.09999999999999987e-56 < y < 1.20000000000000009e38

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-1 \cdot y - -1 \cdot x}{z}} \]
    10. Step-by-step derivation
      1. cancel-sign-sub-inv83.2%

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

        \[\leadsto \frac{-1 \cdot y + \color{blue}{1} \cdot x}{z} \]
      3. *-lft-identity83.2%

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

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

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

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

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

    if 1.20000000000000009e38 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{-56}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+38}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]

Alternative 9: 61.1% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.3e-49 or 1.02000000000000002e52 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.3e-49 < y < 1.02000000000000002e52

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Step-by-step derivation
      1. *-lft-identity100.0%

        \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
      2. metadata-eval100.0%

        \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
      3. associate-/r/99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-49}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+52}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 10: 100.0% accurate, 1.0× speedup?

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

\\
\frac{x - y}{z - y}
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{z - y} \]
  2. Final simplification100.0%

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

Alternative 11: 35.0% accurate, 7.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
	return 1.0;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = 1.0d0
end function
public static double code(double x, double y, double z) {
	return 1.0;
}
def code(x, y, z):
	return 1.0
function code(x, y, z)
	return 1.0
end
function tmp = code(x, y, z)
	tmp = 1.0;
end
code[x_, y_, z_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

    \[\frac{x - y}{z - y} \]
  2. Step-by-step derivation
    1. *-lft-identity100.0%

      \[\leadsto \color{blue}{1 \cdot \frac{x - y}{z - y}} \]
    2. metadata-eval100.0%

      \[\leadsto \color{blue}{\frac{-1}{-1}} \cdot \frac{x - y}{z - y} \]
    3. associate-/r/99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto 1 \]

Developer target: 100.0% accurate, 0.6× speedup?

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

\\
\frac{x}{z - y} - \frac{y}{z - y}
\end{array}

Reproduce

?
herbie shell --seed 2023275 
(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)))