Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A

Percentage Accurate: 87.8% → 99.8%
Time: 6.1s
Alternatives: 10
Speedup: 0.3×

Specification

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

\\
\frac{x + y}{1 - \frac{y}{z}}
\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 10 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: 87.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-305} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-287}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{z \cdot \left(x + z\right)}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999985e-305 or 2.00000000000000004e-287 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z)))

    1. Initial program 99.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing

    if -4.99999999999999985e-305 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 2.00000000000000004e-287

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-z\right)} - \frac{x \cdot z - -1 \cdot {z}^{2}}{y} \]
      12. cancel-sign-sub-inv99.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-z\right) - \frac{z \cdot \left(z + x\right)}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 2: 99.8% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-305} \lor \neg \left(t\_0 \leq 2 \cdot 10^{-287}\right):\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{x \cdot z}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.99999999999999985e-305 or 2.00000000000000004e-287 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z)))

    1. Initial program 99.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]
    2. Add Preprocessing

    if -4.99999999999999985e-305 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 2.00000000000000004e-287

    1. Initial program 8.6%

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

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

      \[\leadsto -1 \cdot \color{blue}{\left(z + \frac{x \cdot z}{y}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

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

Alternative 3: 67.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{y}{z}\\ t_1 := \frac{y}{t\_0}\\ t_2 := \frac{x}{t\_0}\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{+15}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -7.5 \cdot 10^{-262}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-183}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-8}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+219}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ y t_0)) (t_2 (/ x t_0)))
   (if (<= y -1.75e+15)
     t_1
     (if (<= y -7.5e-262)
       t_2
       (if (<= y 7.5e-183)
         (+ x y)
         (if (<= y 4.5e-8) t_2 (if (<= y 1.9e+219) t_1 (- z))))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 - (y / z);
	double t_1 = y / t_0;
	double t_2 = x / t_0;
	double tmp;
	if (y <= -1.75e+15) {
		tmp = t_1;
	} else if (y <= -7.5e-262) {
		tmp = t_2;
	} else if (y <= 7.5e-183) {
		tmp = x + y;
	} else if (y <= 4.5e-8) {
		tmp = t_2;
	} else if (y <= 1.9e+219) {
		tmp = t_1;
	} else {
		tmp = -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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = 1.0d0 - (y / z)
    t_1 = y / t_0
    t_2 = x / t_0
    if (y <= (-1.75d+15)) then
        tmp = t_1
    else if (y <= (-7.5d-262)) then
        tmp = t_2
    else if (y <= 7.5d-183) then
        tmp = x + y
    else if (y <= 4.5d-8) then
        tmp = t_2
    else if (y <= 1.9d+219) then
        tmp = t_1
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 1.0 - (y / z);
	double t_1 = y / t_0;
	double t_2 = x / t_0;
	double tmp;
	if (y <= -1.75e+15) {
		tmp = t_1;
	} else if (y <= -7.5e-262) {
		tmp = t_2;
	} else if (y <= 7.5e-183) {
		tmp = x + y;
	} else if (y <= 4.5e-8) {
		tmp = t_2;
	} else if (y <= 1.9e+219) {
		tmp = t_1;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 - (y / z)
	t_1 = y / t_0
	t_2 = x / t_0
	tmp = 0
	if y <= -1.75e+15:
		tmp = t_1
	elif y <= -7.5e-262:
		tmp = t_2
	elif y <= 7.5e-183:
		tmp = x + y
	elif y <= 4.5e-8:
		tmp = t_2
	elif y <= 1.9e+219:
		tmp = t_1
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 - Float64(y / z))
	t_1 = Float64(y / t_0)
	t_2 = Float64(x / t_0)
	tmp = 0.0
	if (y <= -1.75e+15)
		tmp = t_1;
	elseif (y <= -7.5e-262)
		tmp = t_2;
	elseif (y <= 7.5e-183)
		tmp = Float64(x + y);
	elseif (y <= 4.5e-8)
		tmp = t_2;
	elseif (y <= 1.9e+219)
		tmp = t_1;
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 - (y / z);
	t_1 = y / t_0;
	t_2 = x / t_0;
	tmp = 0.0;
	if (y <= -1.75e+15)
		tmp = t_1;
	elseif (y <= -7.5e-262)
		tmp = t_2;
	elseif (y <= 7.5e-183)
		tmp = x + y;
	elseif (y <= 4.5e-8)
		tmp = t_2;
	elseif (y <= 1.9e+219)
		tmp = t_1;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(x / t$95$0), $MachinePrecision]}, If[LessEqual[y, -1.75e+15], t$95$1, If[LessEqual[y, -7.5e-262], t$95$2, If[LessEqual[y, 7.5e-183], N[(x + y), $MachinePrecision], If[LessEqual[y, 4.5e-8], t$95$2, If[LessEqual[y, 1.9e+219], t$95$1, (-z)]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -7.5 \cdot 10^{-262}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 7.5 \cdot 10^{-183}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 4.5 \cdot 10^{-8}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 1.9 \cdot 10^{+219}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.75e15 or 4.49999999999999993e-8 < y < 1.89999999999999998e219

    1. Initial program 79.0%

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

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

    if -1.75e15 < y < -7.5000000000000002e-262 or 7.5000000000000004e-183 < y < 4.49999999999999993e-8

    1. Initial program 99.9%

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

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

    if -7.5000000000000002e-262 < y < 7.5000000000000004e-183

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x + y} \]
    4. Step-by-step derivation
      1. +-commutative97.8%

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified97.8%

      \[\leadsto \color{blue}{y + x} \]

    if 1.89999999999999998e219 < y

    1. Initial program 47.3%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-neg94.5%

        \[\leadsto \color{blue}{-z} \]
    5. Simplified94.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+15}:\\ \;\;\;\;\frac{y}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq -7.5 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-183}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+219}:\\ \;\;\;\;\frac{y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 67.3% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;y \leq -2.5 \cdot 10^{-262}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 1.85 \cdot 10^{-183}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 0.00015:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.02000000000000003e71 or 1.49999999999999987e-4 < y

    1. Initial program 71.2%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-neg65.0%

        \[\leadsto \color{blue}{-z} \]
    5. Simplified65.0%

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

    if -1.02000000000000003e71 < y < -2.49999999999999996e-262 or 1.8499999999999999e-183 < y < 1.49999999999999987e-4

    1. Initial program 99.1%

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

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

    if -2.49999999999999996e-262 < y < 1.8499999999999999e-183

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x + y} \]
    4. Step-by-step derivation
      1. +-commutative97.8%

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified97.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{+71}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-262}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-183}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 0.00015:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 57.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.12 \cdot 10^{-20}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{-119}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-66}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.12e-20)
   (- z)
   (if (<= y 1.35e-119) x (if (<= y 2.2e-66) y (if (<= y 1.5e-11) x (- z))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.12e-20) {
		tmp = -z;
	} else if (y <= 1.35e-119) {
		tmp = x;
	} else if (y <= 2.2e-66) {
		tmp = y;
	} else if (y <= 1.5e-11) {
		tmp = x;
	} else {
		tmp = -z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.12d-20)) then
        tmp = -z
    else if (y <= 1.35d-119) then
        tmp = x
    else if (y <= 2.2d-66) then
        tmp = y
    else if (y <= 1.5d-11) then
        tmp = x
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.12e-20) {
		tmp = -z;
	} else if (y <= 1.35e-119) {
		tmp = x;
	} else if (y <= 2.2e-66) {
		tmp = y;
	} else if (y <= 1.5e-11) {
		tmp = x;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.12e-20:
		tmp = -z
	elif y <= 1.35e-119:
		tmp = x
	elif y <= 2.2e-66:
		tmp = y
	elif y <= 1.5e-11:
		tmp = x
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.12e-20)
		tmp = Float64(-z);
	elseif (y <= 1.35e-119)
		tmp = x;
	elseif (y <= 2.2e-66)
		tmp = y;
	elseif (y <= 1.5e-11)
		tmp = x;
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.12e-20)
		tmp = -z;
	elseif (y <= 1.35e-119)
		tmp = x;
	elseif (y <= 2.2e-66)
		tmp = y;
	elseif (y <= 1.5e-11)
		tmp = x;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.12e-20], (-z), If[LessEqual[y, 1.35e-119], x, If[LessEqual[y, 2.2e-66], y, If[LessEqual[y, 1.5e-11], x, (-z)]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{-20}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 1.35 \cdot 10^{-119}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 2.2 \cdot 10^{-66}:\\
\;\;\;\;y\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{-11}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.12000000000000002e-20 or 1.5e-11 < y

    1. Initial program 75.3%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-neg59.2%

        \[\leadsto \color{blue}{-z} \]
    5. Simplified59.2%

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

    if -1.12000000000000002e-20 < y < 1.35000000000000013e-119 or 2.2000000000000001e-66 < y < 1.5e-11

    1. Initial program 99.9%

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

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

    if 1.35000000000000013e-119 < y < 2.2000000000000001e-66

    1. Initial program 99.9%

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

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 73.1% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+25} \lor \neg \left(z \leq 1.2 \cdot 10^{-52}\right):\\
\;\;\;\;x + y\\

\mathbf{else}:\\
\;\;\;\;\left(-z\right) - \frac{x \cdot z}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.2999999999999998e25 or 1.2000000000000001e-52 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified77.7%

      \[\leadsto \color{blue}{y + x} \]

    if -2.2999999999999998e25 < z < 1.2000000000000001e-52

    1. Initial program 74.9%

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

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

      \[\leadsto -1 \cdot \color{blue}{\left(z + \frac{x \cdot z}{y}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.5%

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

Alternative 7: 72.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+25} \lor \neg \left(z \leq 2.15 \cdot 10^{-51}\right):\\
\;\;\;\;x + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.50000000000000012e25 or 2.1499999999999999e-51 < z

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified77.7%

      \[\leadsto \color{blue}{y + x} \]

    if -2.50000000000000012e25 < z < 2.1499999999999999e-51

    1. Initial program 74.9%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{z \cdot \left(x + y\right)}{y}} \]
    4. Step-by-step derivation
      1. *-commutative76.0%

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

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

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

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

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

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

        \[\leadsto z \cdot \frac{\color{blue}{\left(-x\right) + \left(-y\right)}}{y} \]
      8. unsub-neg83.0%

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

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

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

Alternative 8: 68.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+73} \lor \neg \left(y \leq 2.1 \cdot 10^{+28}\right):\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;x + y\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.1999999999999996e73 or 2.09999999999999989e28 < y

    1. Initial program 68.7%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    4. Step-by-step derivation
      1. mul-1-neg66.9%

        \[\leadsto \color{blue}{-z} \]
    5. Simplified66.9%

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

    if -8.1999999999999996e73 < y < 2.09999999999999989e28

    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{x + y} \]
    4. Step-by-step derivation
      1. +-commutative67.7%

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified67.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+73} \lor \neg \left(y \leq 2.1 \cdot 10^{+28}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 41.6% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-165}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-159}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -1.6e-165) x (if (<= x 7.5e-159) y x)))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.6e-165) {
		tmp = x;
	} else if (x <= 7.5e-159) {
		tmp = y;
	} else {
		tmp = x;
	}
	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 (x <= (-1.6d-165)) then
        tmp = x
    else if (x <= 7.5d-159) then
        tmp = y
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -1.6e-165) {
		tmp = x;
	} else if (x <= 7.5e-159) {
		tmp = y;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -1.6e-165:
		tmp = x
	elif x <= 7.5e-159:
		tmp = y
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -1.6e-165)
		tmp = x;
	elseif (x <= 7.5e-159)
		tmp = y;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -1.6e-165)
		tmp = x;
	elseif (x <= 7.5e-159)
		tmp = y;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -1.6e-165], x, If[LessEqual[x, 7.5e-159], y, x]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-165}:\\
\;\;\;\;x\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{-159}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.60000000000000006e-165 or 7.5e-159 < x

    1. Initial program 88.3%

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

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

    if -1.60000000000000006e-165 < x < 7.5e-159

    1. Initial program 87.5%

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

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

      \[\leadsto \color{blue}{y} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 35.2% accurate, 9.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 88.1%

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

    \[\leadsto \color{blue}{x} \]
  4. Add Preprocessing

Developer target: 93.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\

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


\end{array}
\end{array}

Reproduce

?
herbie shell --seed 2024103 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :alt
  (if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))

  (/ (+ x y) (- 1.0 (/ y z))))