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

Percentage Accurate: 100.0% → 100.0%
Time: 7.2s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 60.4% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;y \leq 1.28 \cdot 10^{-104}:\\
\;\;\;\;\frac{y}{-z}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.4e13 or 3.3000000000000002e35 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 66.7%

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

    if -4.4e13 < y < 1.3999999999999999e-134 or 1.27999999999999992e-104 < y < 2.8500000000000001e-68

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 76.9%

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

    if 1.3999999999999999e-134 < y < 1.27999999999999992e-104

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 100.0%

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

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

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

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

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

    if 2.8500000000000001e-68 < y < 3.3000000000000002e35

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 62.7%

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

        \[\leadsto -1 \cdot \color{blue}{\left(\frac{x}{y} - \frac{y}{y}\right)} \]
      2. sub-neg62.7%

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

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

        \[\leadsto -1 \cdot \left(\frac{x}{y} + \color{blue}{-1}\right) \]
      5. distribute-lft-in62.7%

        \[\leadsto \color{blue}{-1 \cdot \frac{x}{y} + -1 \cdot -1} \]
      6. metadata-eval62.7%

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

        \[\leadsto \color{blue}{1 + -1 \cdot \frac{x}{y}} \]
      8. mul-1-neg62.7%

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

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

      \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    6. Taylor expanded in x around inf 51.0%

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

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

        \[\leadsto \color{blue}{\frac{x}{-y}} \]
    8. Simplified51.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -44000000000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-134}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{-104}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 2.85 \cdot 10^{-68}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+35}:\\ \;\;\;\;\frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 74.9% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.0008 \lor \neg \left(y \leq 1.8 \cdot 10^{-142}\right) \land \left(y \leq 1.9 \cdot 10^{-77} \lor \neg \left(y \leq 3.4 \cdot 10^{+33}\right)\right):\\
\;\;\;\;\frac{y}{y - z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.00000000000000038e-4 or 1.8e-142 < y < 1.8999999999999999e-77 or 3.3999999999999999e33 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 85.1%

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

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

        \[\leadsto \color{blue}{\frac{-y}{z - y}} \]
    5. Simplified85.1%

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

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

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

        \[\leadsto \color{blue}{y} \cdot \frac{1}{-\left(z - y\right)} \]
      4. sub-neg84.9%

        \[\leadsto y \cdot \frac{1}{-\color{blue}{\left(z + \left(-y\right)\right)}} \]
      5. distribute-neg-in84.9%

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

        \[\leadsto y \cdot \frac{1}{\left(-z\right) + \color{blue}{y}} \]
    7. Applied egg-rr84.9%

      \[\leadsto \color{blue}{y \cdot \frac{1}{\left(-z\right) + y}} \]
    8. Step-by-step derivation
      1. associate-*r/85.1%

        \[\leadsto \color{blue}{\frac{y \cdot 1}{\left(-z\right) + y}} \]
      2. *-rgt-identity85.1%

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

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

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

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

    if -8.00000000000000038e-4 < y < 1.8e-142 or 1.8999999999999999e-77 < y < 3.3999999999999999e33

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 85.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.0008 \lor \neg \left(y \leq 1.8 \cdot 10^{-142}\right) \land \left(y \leq 1.9 \cdot 10^{-77} \lor \neg \left(y \leq 3.4 \cdot 10^{+33}\right)\right):\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{z - y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 70.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{x}{y}\\ \mathbf{if}\;y \leq -1.46 \cdot 10^{-67}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-134}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-104}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-69}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ x y))))
   (if (<= y -1.46e-67)
     t_0
     (if (<= y 1.4e-134)
       (/ x z)
       (if (<= y 1.3e-104) (/ y (- z)) (if (<= y 1.25e-69) (/ x z) t_0))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 - (x / y);
	double tmp;
	if (y <= -1.46e-67) {
		tmp = t_0;
	} else if (y <= 1.4e-134) {
		tmp = x / z;
	} else if (y <= 1.3e-104) {
		tmp = y / -z;
	} else if (y <= 1.25e-69) {
		tmp = x / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x / y)
    if (y <= (-1.46d-67)) then
        tmp = t_0
    else if (y <= 1.4d-134) then
        tmp = x / z
    else if (y <= 1.3d-104) then
        tmp = y / -z
    else if (y <= 1.25d-69) 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 - (x / y);
	double tmp;
	if (y <= -1.46e-67) {
		tmp = t_0;
	} else if (y <= 1.4e-134) {
		tmp = x / z;
	} else if (y <= 1.3e-104) {
		tmp = y / -z;
	} else if (y <= 1.25e-69) {
		tmp = x / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 - (x / y)
	tmp = 0
	if y <= -1.46e-67:
		tmp = t_0
	elif y <= 1.4e-134:
		tmp = x / z
	elif y <= 1.3e-104:
		tmp = y / -z
	elif y <= 1.25e-69:
		tmp = x / z
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 - Float64(x / y))
	tmp = 0.0
	if (y <= -1.46e-67)
		tmp = t_0;
	elseif (y <= 1.4e-134)
		tmp = Float64(x / z);
	elseif (y <= 1.3e-104)
		tmp = Float64(y / Float64(-z));
	elseif (y <= 1.25e-69)
		tmp = Float64(x / z);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 - (x / y);
	tmp = 0.0;
	if (y <= -1.46e-67)
		tmp = t_0;
	elseif (y <= 1.4e-134)
		tmp = x / z;
	elseif (y <= 1.3e-104)
		tmp = y / -z;
	elseif (y <= 1.25e-69)
		tmp = x / z;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.46e-67], t$95$0, If[LessEqual[y, 1.4e-134], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.3e-104], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 1.25e-69], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-104}:\\
\;\;\;\;\frac{y}{-z}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.46000000000000002e-67 or 1.25000000000000008e-69 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 71.2%

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

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

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

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

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

        \[\leadsto \color{blue}{-1 \cdot \frac{x}{y} + -1 \cdot -1} \]
      6. metadata-eval71.2%

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

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

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

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

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

    if -1.46000000000000002e-67 < y < 1.3999999999999999e-134 or 1.30000000000000001e-104 < y < 1.25000000000000008e-69

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 79.9%

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

    if 1.3999999999999999e-134 < y < 1.30000000000000001e-104

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.46 \cdot 10^{-67}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-134}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-104}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-69}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 75.2% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-134}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 1.75 \cdot 10^{-104}:\\
\;\;\;\;\frac{y}{-z}\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.9e17 or 2.6000000000000001e-8 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 74.2%

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

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

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

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

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

        \[\leadsto \color{blue}{-1 \cdot \frac{x}{y} + -1 \cdot -1} \]
      6. metadata-eval74.2%

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

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

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

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

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

    if -1.9e17 < y < 1.30000000000000011e-134 or 1.75000000000000014e-104 < y < 2.6000000000000001e-8

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 85.8%

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

    if 1.30000000000000011e-134 < y < 1.75000000000000014e-104

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+17}:\\ \;\;\;\;1 - \frac{x}{y}\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-134}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{-104}:\\ \;\;\;\;\frac{y}{-z}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-8}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{x}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 75.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y}{y - z}\\ \mathbf{if}\;y \leq -0.04:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-70}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{+33}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (- y z))))
   (if (<= y -0.04)
     t_0
     (if (<= y 3.7e-70)
       (/ (- x y) z)
       (if (<= y 1.28e+33) (/ x (- z y)) t_0)))))
double code(double x, double y, double z) {
	double t_0 = y / (y - z);
	double tmp;
	if (y <= -0.04) {
		tmp = t_0;
	} else if (y <= 3.7e-70) {
		tmp = (x - y) / z;
	} else if (y <= 1.28e+33) {
		tmp = x / (z - y);
	} 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 <= (-0.04d0)) then
        tmp = t_0
    else if (y <= 3.7d-70) then
        tmp = (x - y) / z
    else if (y <= 1.28d+33) then
        tmp = x / (z - y)
    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 <= -0.04) {
		tmp = t_0;
	} else if (y <= 3.7e-70) {
		tmp = (x - y) / z;
	} else if (y <= 1.28e+33) {
		tmp = x / (z - y);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y / (y - z)
	tmp = 0
	if y <= -0.04:
		tmp = t_0
	elif y <= 3.7e-70:
		tmp = (x - y) / z
	elif y <= 1.28e+33:
		tmp = x / (z - y)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y / Float64(y - z))
	tmp = 0.0
	if (y <= -0.04)
		tmp = t_0;
	elseif (y <= 3.7e-70)
		tmp = Float64(Float64(x - y) / z);
	elseif (y <= 1.28e+33)
		tmp = Float64(x / Float64(z - y));
	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 <= -0.04)
		tmp = t_0;
	elseif (y <= 3.7e-70)
		tmp = (x - y) / z;
	elseif (y <= 1.28e+33)
		tmp = x / (z - y);
	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, -0.04], t$95$0, If[LessEqual[y, 3.7e-70], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.28e+33], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -0.04:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -0.0400000000000000008 or 1.28e33 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 85.0%

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

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

        \[\leadsto \color{blue}{\frac{-y}{z - y}} \]
    5. Simplified85.0%

      \[\leadsto \color{blue}{\frac{-y}{z - y}} \]
    6. Step-by-step derivation
      1. frac-2neg85.0%

        \[\leadsto \color{blue}{\frac{-\left(-y\right)}{-\left(z - y\right)}} \]
      2. div-inv84.8%

        \[\leadsto \color{blue}{\left(-\left(-y\right)\right) \cdot \frac{1}{-\left(z - y\right)}} \]
      3. remove-double-neg84.8%

        \[\leadsto \color{blue}{y} \cdot \frac{1}{-\left(z - y\right)} \]
      4. sub-neg84.8%

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

        \[\leadsto y \cdot \frac{1}{\color{blue}{\left(-z\right) + \left(-\left(-y\right)\right)}} \]
      6. remove-double-neg84.8%

        \[\leadsto y \cdot \frac{1}{\left(-z\right) + \color{blue}{y}} \]
    7. Applied egg-rr84.8%

      \[\leadsto \color{blue}{y \cdot \frac{1}{\left(-z\right) + y}} \]
    8. Step-by-step derivation
      1. associate-*r/85.0%

        \[\leadsto \color{blue}{\frac{y \cdot 1}{\left(-z\right) + y}} \]
      2. *-rgt-identity85.0%

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

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

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

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

    if -0.0400000000000000008 < y < 3.7e-70

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around inf 88.6%

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

    if 3.7e-70 < y < 1.28e33

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 70.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.04:\\ \;\;\;\;\frac{y}{y - z}\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-70}:\\ \;\;\;\;\frac{x - y}{z}\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{+33}:\\ \;\;\;\;\frac{x}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{y - z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.0% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;y \leq 4.9 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{-y}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.6e8 or 4.90000000000000025e35 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 66.7%

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

    if -1.6e8 < y < 3.1000000000000003e-67

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 73.9%

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

    if 3.1000000000000003e-67 < y < 4.90000000000000025e35

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 62.7%

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

        \[\leadsto -1 \cdot \color{blue}{\left(\frac{x}{y} - \frac{y}{y}\right)} \]
      2. sub-neg62.7%

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

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

        \[\leadsto -1 \cdot \left(\frac{x}{y} + \color{blue}{-1}\right) \]
      5. distribute-lft-in62.7%

        \[\leadsto \color{blue}{-1 \cdot \frac{x}{y} + -1 \cdot -1} \]
      6. metadata-eval62.7%

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

        \[\leadsto \color{blue}{1 + -1 \cdot \frac{x}{y}} \]
      8. mul-1-neg62.7%

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

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

      \[\leadsto \color{blue}{1 - \frac{x}{y}} \]
    6. Taylor expanded in x around inf 51.0%

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

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

        \[\leadsto \color{blue}{\frac{x}{-y}} \]
    8. Simplified51.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -160000000:\\ \;\;\;\;1\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{-67}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{+35}:\\ \;\;\;\;\frac{x}{-y}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 61.5% accurate, 0.5× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -225000 or 1.90000000000000014e-8 < y

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 62.4%

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

    if -225000 < y < 1.90000000000000014e-8

    1. Initial program 100.0%

      \[\frac{x - y}{z - y} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 69.5%

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

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

Alternative 9: 34.9% accurate, 7.0× speedup?

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

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

    \[\frac{x - y}{z - y} \]
  2. Add Preprocessing
  3. Taylor expanded in y around inf 34.5%

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

    \[\leadsto 1 \]
  5. Add Preprocessing

Developer target: 100.0% accurate, 0.6× speedup?

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

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

Reproduce

?
herbie shell --seed 2024057 
(FPCore (x y z)
  :name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
  :precision binary64

  :alt
  (- (/ x (- z y)) (/ y (- z y)))

  (/ (- x y) (- z y)))