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

Percentage Accurate: 100.0% → 100.0%
Time: 6.8s
Alternatives: 8
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

    \[\frac{x - y}{z - y} \]
  2. Final simplification99.9%

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

Alternative 2: 75.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - z}\\ t_1 := \frac{x}{z - y}\\ \mathbf{if}\;y \leq -1.35 \cdot 10^{+33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.02 \cdot 10^{-23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.95 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{+37}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+80}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+90}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (- y z))) (t_1 (/ x (- z y))))
   (if (<= y -1.35e+33)
     t_0
     (if (<= y -2.02e-23)
       t_1
       (if (<= y -2.95e-61)
         t_0
         (if (<= y 5.8e-35)
           t_1
           (if (<= y 4.4e+37)
             t_0
             (if (<= y 1.05e+80) t_1 (if (<= y 5.4e+90) 1.0 t_0)))))))))
double code(double x, double y, double z) {
	double t_0 = y / (y - z);
	double t_1 = x / (z - y);
	double tmp;
	if (y <= -1.35e+33) {
		tmp = t_0;
	} else if (y <= -2.02e-23) {
		tmp = t_1;
	} else if (y <= -2.95e-61) {
		tmp = t_0;
	} else if (y <= 5.8e-35) {
		tmp = t_1;
	} else if (y <= 4.4e+37) {
		tmp = t_0;
	} else if (y <= 1.05e+80) {
		tmp = t_1;
	} else if (y <= 5.4e+90) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y / (y - z)
    t_1 = x / (z - y)
    if (y <= (-1.35d+33)) then
        tmp = t_0
    else if (y <= (-2.02d-23)) then
        tmp = t_1
    else if (y <= (-2.95d-61)) then
        tmp = t_0
    else if (y <= 5.8d-35) then
        tmp = t_1
    else if (y <= 4.4d+37) then
        tmp = t_0
    else if (y <= 1.05d+80) then
        tmp = t_1
    else if (y <= 5.4d+90) then
        tmp = 1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y / (y - z);
	double t_1 = x / (z - y);
	double tmp;
	if (y <= -1.35e+33) {
		tmp = t_0;
	} else if (y <= -2.02e-23) {
		tmp = t_1;
	} else if (y <= -2.95e-61) {
		tmp = t_0;
	} else if (y <= 5.8e-35) {
		tmp = t_1;
	} else if (y <= 4.4e+37) {
		tmp = t_0;
	} else if (y <= 1.05e+80) {
		tmp = t_1;
	} else if (y <= 5.4e+90) {
		tmp = 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y / (y - z)
	t_1 = x / (z - y)
	tmp = 0
	if y <= -1.35e+33:
		tmp = t_0
	elif y <= -2.02e-23:
		tmp = t_1
	elif y <= -2.95e-61:
		tmp = t_0
	elif y <= 5.8e-35:
		tmp = t_1
	elif y <= 4.4e+37:
		tmp = t_0
	elif y <= 1.05e+80:
		tmp = t_1
	elif y <= 5.4e+90:
		tmp = 1.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y / Float64(y - z))
	t_1 = Float64(x / Float64(z - y))
	tmp = 0.0
	if (y <= -1.35e+33)
		tmp = t_0;
	elseif (y <= -2.02e-23)
		tmp = t_1;
	elseif (y <= -2.95e-61)
		tmp = t_0;
	elseif (y <= 5.8e-35)
		tmp = t_1;
	elseif (y <= 4.4e+37)
		tmp = t_0;
	elseif (y <= 1.05e+80)
		tmp = t_1;
	elseif (y <= 5.4e+90)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y / (y - z);
	t_1 = x / (z - y);
	tmp = 0.0;
	if (y <= -1.35e+33)
		tmp = t_0;
	elseif (y <= -2.02e-23)
		tmp = t_1;
	elseif (y <= -2.95e-61)
		tmp = t_0;
	elseif (y <= 5.8e-35)
		tmp = t_1;
	elseif (y <= 4.4e+37)
		tmp = t_0;
	elseif (y <= 1.05e+80)
		tmp = t_1;
	elseif (y <= 5.4e+90)
		tmp = 1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.35e+33], t$95$0, If[LessEqual[y, -2.02e-23], t$95$1, If[LessEqual[y, -2.95e-61], t$95$0, If[LessEqual[y, 5.8e-35], t$95$1, If[LessEqual[y, 4.4e+37], t$95$0, If[LessEqual[y, 1.05e+80], t$95$1, If[LessEqual[y, 5.4e+90], 1.0, t$95$0]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2.02 \cdot 10^{-23}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -2.95 \cdot 10^{-61}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 5.8 \cdot 10^{-35}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 4.4 \cdot 10^{+37}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 5.4 \cdot 10^{+90}:\\
\;\;\;\;1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.34999999999999996e33 or -2.02000000000000001e-23 < y < -2.94999999999999986e-61 or 5.8000000000000004e-35 < y < 4.4000000000000001e37 or 5.4e90 < y

    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.5%

        \[\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*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 85.5%

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

    if -1.34999999999999996e33 < y < -2.02000000000000001e-23 or -2.94999999999999986e-61 < y < 5.8000000000000004e-35 or 4.4000000000000001e37 < y < 1.05000000000000001e80

    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.4%

        \[\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 x around inf 82.5%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y - z}} \]
    8. Step-by-step derivation
      1. *-commutative82.5%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 1}{-\left(y - z\right)}} \]
      8. *-rgt-identity82.5%

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

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

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

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

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

        \[\leadsto \frac{x}{\color{blue}{\left(-\left(-z\right)\right)} - y} \]
      14. remove-double-neg82.5%

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

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

    if 1.05000000000000001e80 < y < 5.4e90

    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.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification83.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+33}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq -2.02 \cdot 10^{-23}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{elif}\;y \leq -2.95 \cdot 10^{-61}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-35}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{+37}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+80}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{+90}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]

Alternative 3: 69.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -2.3 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-62}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-64} \lor \neg \left(y \leq 1.35 \cdot 10^{-42}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -2.3e-9)
     t_0
     (if (<= y -9.5e-62)
       (/ (- y) z)
       (if (or (<= y -5.5e-64) (not (<= y 1.35e-42))) t_0 (/ x z))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.3e-9) {
		tmp = t_0;
	} else if (y <= -9.5e-62) {
		tmp = -y / z;
	} else if ((y <= -5.5e-64) || !(y <= 1.35e-42)) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-2.3d-9)) then
        tmp = t_0
    else if (y <= (-9.5d-62)) then
        tmp = -y / z
    else if ((y <= (-5.5d-64)) .or. (.not. (y <= 1.35d-42))) then
        tmp = t_0
    else
        tmp = x / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -2.3e-9) {
		tmp = t_0;
	} else if (y <= -9.5e-62) {
		tmp = -y / z;
	} else if ((y <= -5.5e-64) || !(y <= 1.35e-42)) {
		tmp = t_0;
	} else {
		tmp = x / z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -2.3e-9:
		tmp = t_0
	elif y <= -9.5e-62:
		tmp = -y / z
	elif (y <= -5.5e-64) or not (y <= 1.35e-42):
		tmp = t_0
	else:
		tmp = x / z
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -2.3e-9)
		tmp = t_0;
	elseif (y <= -9.5e-62)
		tmp = Float64(Float64(-y) / z);
	elseif ((y <= -5.5e-64) || !(y <= 1.35e-42))
		tmp = t_0;
	else
		tmp = Float64(x / z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -2.3e-9)
		tmp = t_0;
	elseif (y <= -9.5e-62)
		tmp = -y / z;
	elseif ((y <= -5.5e-64) || ~((y <= 1.35e-42)))
		tmp = t_0;
	else
		tmp = x / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.3e-9], t$95$0, If[LessEqual[y, -9.5e-62], N[((-y) / z), $MachinePrecision], If[Or[LessEqual[y, -5.5e-64], N[Not[LessEqual[y, 1.35e-42]], $MachinePrecision]], t$95$0, N[(x / z), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -9.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{-y}{z}\\

\mathbf{elif}\;y \leq -5.5 \cdot 10^{-64} \lor \neg \left(y \leq 1.35 \cdot 10^{-42}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.2999999999999999e-9 or -9.49999999999999951e-62 < y < -5.4999999999999999e-64 or 1.35e-42 < y

    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.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*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 z around 0 70.9%

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

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

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

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

    if -2.2999999999999999e-9 < y < -9.49999999999999951e-62

    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/96.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{-y}}{z} \]
    7. Simplified58.7%

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

    if -5.4999999999999999e-64 < y < 1.35e-42

    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.3%

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

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

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

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

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

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

        \[\leadsto \frac{-1}{\frac{\color{blue}{y} + \left(-z\right)}{x - y}} \]
      10. sub-neg99.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 y around 0 78.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{-9}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{-62}:\\ \;\;\;\;\frac{-y}{z}\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-64} \lor \neg \left(y \leq 1.35 \cdot 10^{-42}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z}\\ \end{array} \]

Alternative 4: 75.0% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq -1.75 \cdot 10^{-9}:\\
\;\;\;\;1 - \frac{x}{y}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.99999999999999978e110 or 1.15e79 < y

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

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

    if -4.99999999999999978e110 < y < -1.75e-9

    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.6%

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

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

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

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

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

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

        \[\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 z around 0 70.8%

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

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

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

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

    if -1.75e-9 < y < 1.15e79

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

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

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

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

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

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

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

        \[\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 inf 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+110}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-9}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+79}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]

Alternative 5: 75.0% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.6000000000000004e109 or 1.19999999999999993e79 < y

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

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

    if -5.6000000000000004e109 < y < -1.41999999999999998e-8

    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.6%

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

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

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

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

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

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

        \[\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 y around inf 73.8%

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

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

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

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

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

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

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

    if -1.41999999999999998e-8 < y < 1.19999999999999993e79

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

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

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

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

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

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

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

        \[\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 inf 80.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.6 \cdot 10^{+109}:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-8}:\\ \;\;\;\;1 + \frac{z - x}{y}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+79}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]

Alternative 6: 75.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+53} \lor \neg \left(y \leq 1.65 \cdot 10^{+85}\right):\\
\;\;\;\;1 - \frac{x}{y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.8e53 or 1.65e85 < y

    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 z around 0 77.4%

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

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

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

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

    if -1.8e53 < y < 1.65e85

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{y - z}} \]
    8. Step-by-step derivation
      1. *-commutative74.0%

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

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

        \[\leadsto \color{blue}{x \cdot \frac{-1}{y - z}} \]
      4. metadata-eval73.7%

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot 1}{-\left(y - z\right)}} \]
      8. *-rgt-identity74.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+53} \lor \neg \left(y \leq 1.65 \cdot 10^{+85}\right):\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z - y}\\ \end{array} \]

Alternative 7: 60.6% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.6500000000000001e53 or 1.34999999999999991e80 < y

    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 y around inf 68.9%

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

    if -1.6500000000000001e53 < y < 1.34999999999999991e80

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{+53}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+80}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]

Alternative 8: 34.7% accurate, 7.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 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.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*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 y around inf 36.7%

    \[\leadsto \color{blue}{1} \]
  5. Final simplification36.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 2023290 
(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)))