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

Percentage Accurate: 88.3% → 99.8%
Time: 6.9s
Alternatives: 12
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 12 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: 88.3% 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.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{if}\;t\_0 \leq -1 \cdot 10^{-283} \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{\left(-x\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 -1e-283) (not (<= t_0 0.0))) t_0 (/ z (/ y (- (- x) y))))))
double code(double x, double y, double z) {
	double t_0 = (x + y) / (1.0 - (y / z));
	double tmp;
	if ((t_0 <= -1e-283) || !(t_0 <= 0.0)) {
		tmp = t_0;
	} else {
		tmp = z / (y / (-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) :: t_0
    real(8) :: tmp
    t_0 = (x + y) / (1.0d0 - (y / z))
    if ((t_0 <= (-1d-283)) .or. (.not. (t_0 <= 0.0d0))) then
        tmp = t_0
    else
        tmp = z / (y / (-x - 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 <= -1e-283) || !(t_0 <= 0.0)) {
		tmp = t_0;
	} else {
		tmp = z / (y / (-x - y));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (x + y) / (1.0 - (y / z))
	tmp = 0
	if (t_0 <= -1e-283) or not (t_0 <= 0.0):
		tmp = t_0
	else:
		tmp = z / (y / (-x - 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 <= -1e-283) || !(t_0 <= 0.0))
		tmp = t_0;
	else
		tmp = Float64(z / Float64(y / Float64(Float64(-x) - 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 <= -1e-283) || ~((t_0 <= 0.0)))
		tmp = t_0;
	else
		tmp = z / (y / (-x - 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, -1e-283], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(z / N[(y / N[((-x) - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -9.99999999999999947e-284 or 0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z)))

    1. Initial program 99.9%

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

    if -9.99999999999999947e-284 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 0.0

    1. Initial program 12.4%

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

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

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

        \[\leadsto -\color{blue}{z \cdot \frac{x + y}{y}} \]
      3. distribute-rgt-neg-in99.9%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{z \cdot \left(y + x\right)}{y}} \]
      3. add-sqr-sqrt42.3%

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

        \[\leadsto -\frac{z \cdot \left(y + x\right)}{\color{blue}{\sqrt{y \cdot y}}} \]
      5. sqr-neg30.4%

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

        \[\leadsto -\frac{z \cdot \left(y + x\right)}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}} \]
      7. add-sqr-sqrt5.8%

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

        \[\leadsto -\color{blue}{z \cdot \frac{y + x}{-y}} \]
      9. clear-num5.7%

        \[\leadsto -z \cdot \color{blue}{\frac{1}{\frac{-y}{y + x}}} \]
      10. un-div-inv5.7%

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{y + x}}} \]
      11. add-sqr-sqrt3.0%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{y + x}} \]
      12. sqrt-unprod30.4%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{y + x}} \]
      13. sqr-neg30.4%

        \[\leadsto -\frac{z}{\frac{\sqrt{\color{blue}{y \cdot y}}}{y + x}} \]
      14. sqrt-unprod42.3%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{y + x}} \]
      15. add-sqr-sqrt100.0%

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

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

      \[\leadsto \color{blue}{-\frac{z}{\frac{y}{x + 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 -1 \cdot 10^{-283} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \leq 0\right):\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 67.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{1 - \frac{y}{z}}\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{+56}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{+67}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+103}:\\ \;\;\;\;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 -5.5e+56)
     (- z)
     (if (<= y 5.2e-107)
       (+ x y)
       (if (<= y 2.4e+45)
         t_0
         (if (<= y 2.05e+67)
           (* y (+ 1.0 (/ y z)))
           (if (<= y 1.8e+103) t_0 (- z))))))))
double code(double x, double y, double z) {
	double t_0 = x / (1.0 - (y / z));
	double tmp;
	if (y <= -5.5e+56) {
		tmp = -z;
	} else if (y <= 5.2e-107) {
		tmp = x + y;
	} else if (y <= 2.4e+45) {
		tmp = t_0;
	} else if (y <= 2.05e+67) {
		tmp = y * (1.0 + (y / z));
	} else if (y <= 1.8e+103) {
		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 <= (-5.5d+56)) then
        tmp = -z
    else if (y <= 5.2d-107) then
        tmp = x + y
    else if (y <= 2.4d+45) then
        tmp = t_0
    else if (y <= 2.05d+67) then
        tmp = y * (1.0d0 + (y / z))
    else if (y <= 1.8d+103) 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 <= -5.5e+56) {
		tmp = -z;
	} else if (y <= 5.2e-107) {
		tmp = x + y;
	} else if (y <= 2.4e+45) {
		tmp = t_0;
	} else if (y <= 2.05e+67) {
		tmp = y * (1.0 + (y / z));
	} else if (y <= 1.8e+103) {
		tmp = t_0;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x / (1.0 - (y / z))
	tmp = 0
	if y <= -5.5e+56:
		tmp = -z
	elif y <= 5.2e-107:
		tmp = x + y
	elif y <= 2.4e+45:
		tmp = t_0
	elif y <= 2.05e+67:
		tmp = y * (1.0 + (y / z))
	elif y <= 1.8e+103:
		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 <= -5.5e+56)
		tmp = Float64(-z);
	elseif (y <= 5.2e-107)
		tmp = Float64(x + y);
	elseif (y <= 2.4e+45)
		tmp = t_0;
	elseif (y <= 2.05e+67)
		tmp = Float64(y * Float64(1.0 + Float64(y / z)));
	elseif (y <= 1.8e+103)
		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 <= -5.5e+56)
		tmp = -z;
	elseif (y <= 5.2e-107)
		tmp = x + y;
	elseif (y <= 2.4e+45)
		tmp = t_0;
	elseif (y <= 2.05e+67)
		tmp = y * (1.0 + (y / z));
	elseif (y <= 1.8e+103)
		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, -5.5e+56], (-z), If[LessEqual[y, 5.2e-107], N[(x + y), $MachinePrecision], If[LessEqual[y, 2.4e+45], t$95$0, If[LessEqual[y, 2.05e+67], N[(y * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.8e+103], t$95$0, (-z)]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 5.2 \cdot 10^{-107}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 2.05 \cdot 10^{+67}:\\
\;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\

\mathbf{elif}\;y \leq 1.8 \cdot 10^{+103}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -5.5000000000000002e56 or 1.80000000000000008e103 < y

    1. Initial program 68.5%

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

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

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

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

    if -5.5000000000000002e56 < y < 5.2000000000000001e-107

    1. Initial program 98.4%

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

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

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified75.6%

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

    if 5.2000000000000001e-107 < y < 2.39999999999999989e45 or 2.0499999999999999e67 < y < 1.80000000000000008e103

    1. Initial program 93.6%

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

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

    if 2.39999999999999989e45 < y < 2.0499999999999999e67

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+56}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-107}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{+67}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+103}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 68.7% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;y \leq 3.6 \cdot 10^{-107}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 1.05 \cdot 10^{+31}:\\
\;\;\;\;\frac{x}{t\_0}\\

\mathbf{elif}\;y \leq 7 \cdot 10^{+75}:\\
\;\;\;\;\frac{y}{t\_0}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.79999999999999987e63 or 6.9999999999999997e75 < y

    1. Initial program 69.6%

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

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

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

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

    if -2.79999999999999987e63 < y < 3.59999999999999976e-107

    1. Initial program 98.4%

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

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

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified75.6%

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

    if 3.59999999999999976e-107 < y < 1.04999999999999989e31

    1. Initial program 99.8%

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

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

    if 1.04999999999999989e31 < y < 6.9999999999999997e75

    1. Initial program 79.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{+63}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-107}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+31}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+75}:\\ \;\;\;\;\frac{y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 74.7% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;y \leq 4.5 \cdot 10^{-107}:\\
\;\;\;\;x + y\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.00000000000000004e42 or 2.29999999999999984e28 < y

    1. Initial program 71.4%

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

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

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

        \[\leadsto -\color{blue}{z \cdot \frac{x + y}{y}} \]
      3. distribute-rgt-neg-in82.4%

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

        \[\leadsto z \cdot \color{blue}{\frac{x + y}{-y}} \]
      5. +-commutative82.4%

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

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

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

        \[\leadsto \color{blue}{-\frac{z \cdot \left(y + x\right)}{y}} \]
      3. add-sqr-sqrt31.0%

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

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

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

        \[\leadsto -\frac{z \cdot \left(y + x\right)}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}} \]
      7. add-sqr-sqrt2.9%

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

        \[\leadsto -\color{blue}{z \cdot \frac{y + x}{-y}} \]
      9. clear-num3.0%

        \[\leadsto -z \cdot \color{blue}{\frac{1}{\frac{-y}{y + x}}} \]
      10. un-div-inv3.0%

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{y + x}}} \]
      11. add-sqr-sqrt1.3%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{y + x}} \]
      12. sqrt-unprod20.0%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{y + x}} \]
      13. sqr-neg20.0%

        \[\leadsto -\frac{z}{\frac{\sqrt{\color{blue}{y \cdot y}}}{y + x}} \]
      14. sqrt-unprod36.7%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{y + x}} \]
      15. add-sqr-sqrt82.4%

        \[\leadsto -\frac{z}{\frac{\color{blue}{y}}{y + x}} \]
      16. +-commutative82.4%

        \[\leadsto -\frac{z}{\frac{y}{\color{blue}{x + y}}} \]
    7. Applied egg-rr82.4%

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

    if -1.00000000000000004e42 < y < 4.50000000000000016e-107

    1. Initial program 99.1%

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

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

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

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

    if 4.50000000000000016e-107 < y < 2.29999999999999984e28

    1. Initial program 99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{+42}:\\ \;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-107}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+28}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 74.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{z}{\frac{y}{\left(-x\right) - y}}\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq 3.9 \cdot 10^{-107}:\\
\;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -6.2e41 or 2.4999999999999999e27 < y

    1. Initial program 71.4%

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

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

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

        \[\leadsto -\color{blue}{z \cdot \frac{x + y}{y}} \]
      3. distribute-rgt-neg-in82.4%

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

        \[\leadsto z \cdot \color{blue}{\frac{x + y}{-y}} \]
      5. +-commutative82.4%

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

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

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

        \[\leadsto \color{blue}{-\frac{z \cdot \left(y + x\right)}{y}} \]
      3. add-sqr-sqrt31.0%

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

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

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

        \[\leadsto -\frac{z \cdot \left(y + x\right)}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}} \]
      7. add-sqr-sqrt2.9%

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

        \[\leadsto -\color{blue}{z \cdot \frac{y + x}{-y}} \]
      9. clear-num3.0%

        \[\leadsto -z \cdot \color{blue}{\frac{1}{\frac{-y}{y + x}}} \]
      10. un-div-inv3.0%

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{y + x}}} \]
      11. add-sqr-sqrt1.3%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{y + x}} \]
      12. sqrt-unprod20.0%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{y + x}} \]
      13. sqr-neg20.0%

        \[\leadsto -\frac{z}{\frac{\sqrt{\color{blue}{y \cdot y}}}{y + x}} \]
      14. sqrt-unprod36.7%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{y + x}} \]
      15. add-sqr-sqrt82.4%

        \[\leadsto -\frac{z}{\frac{\color{blue}{y}}{y + x}} \]
      16. +-commutative82.4%

        \[\leadsto -\frac{z}{\frac{y}{\color{blue}{x + y}}} \]
    7. Applied egg-rr82.4%

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

    if -6.2e41 < y < 3.9000000000000001e-107

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(y + x\right) \cdot \left(1 + \frac{y}{z}\right)} \]

    if 3.9000000000000001e-107 < y < 2.4999999999999999e27

    1. Initial program 99.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+41}:\\ \;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-107}:\\ \;\;\;\;\left(x + y\right) \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{+27}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{\frac{y}{\left(-x\right) - y}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 67.2% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+62}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 3.2 \cdot 10^{-13}:\\
\;\;\;\;x + y\\

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

\mathbf{elif}\;y \leq 4.1 \cdot 10^{+51}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -7.49999999999999998e62 or 4.10000000000000011e51 < y

    1. Initial program 70.9%

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

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

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

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

    if -7.49999999999999998e62 < y < 3.2e-13

    1. Initial program 98.7%

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

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

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

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

    if 3.2e-13 < y < 8.4999999999999996e45

    1. Initial program 81.5%

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

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

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

        \[\leadsto -\color{blue}{z \cdot \frac{x + y}{y}} \]
      3. distribute-rgt-neg-in71.2%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{z \cdot \left(y + x\right)}{y}} \]
      3. add-sqr-sqrt70.9%

        \[\leadsto -\frac{z \cdot \left(y + x\right)}{\color{blue}{\sqrt{y} \cdot \sqrt{y}}} \]
      4. sqrt-unprod71.0%

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

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

        \[\leadsto -\frac{z \cdot \left(y + x\right)}{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}} \]
      7. add-sqr-sqrt3.0%

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

        \[\leadsto -\color{blue}{z \cdot \frac{y + x}{-y}} \]
      9. clear-num3.0%

        \[\leadsto -z \cdot \color{blue}{\frac{1}{\frac{-y}{y + x}}} \]
      10. un-div-inv3.0%

        \[\leadsto -\color{blue}{\frac{z}{\frac{-y}{y + x}}} \]
      11. add-sqr-sqrt0.0%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{-y} \cdot \sqrt{-y}}}{y + x}} \]
      12. sqrt-unprod71.0%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{\left(-y\right) \cdot \left(-y\right)}}}{y + x}} \]
      13. sqr-neg71.0%

        \[\leadsto -\frac{z}{\frac{\sqrt{\color{blue}{y \cdot y}}}{y + x}} \]
      14. sqrt-unprod70.9%

        \[\leadsto -\frac{z}{\frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{y + x}} \]
      15. add-sqr-sqrt71.0%

        \[\leadsto -\frac{z}{\frac{\color{blue}{y}}{y + x}} \]
      16. +-commutative71.0%

        \[\leadsto -\frac{z}{\frac{y}{\color{blue}{x + y}}} \]
    7. Applied egg-rr71.0%

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

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

        \[\leadsto -\color{blue}{x \cdot \frac{z}{y}} \]
      2. *-commutative52.3%

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

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

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

    if 8.4999999999999996e45 < y < 4.10000000000000011e51

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+62}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-13}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+45}:\\ \;\;\;\;\frac{z}{-\frac{y}{x}}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+51}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 67.3% accurate, 0.4× speedup?

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

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

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

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

\mathbf{elif}\;y \leq 2 \cdot 10^{+48}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.10000000000000014e62 or 2.00000000000000009e48 < y

    1. Initial program 70.9%

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

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

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

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

    if -3.10000000000000014e62 < y < 1.2000000000000001e-11

    1. Initial program 98.7%

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

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

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

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

    if 1.2000000000000001e-11 < y < 5.8000000000000004e44

    1. Initial program 81.5%

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

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

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

        \[\leadsto -\color{blue}{z \cdot \frac{x + y}{y}} \]
      3. distribute-rgt-neg-in71.2%

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

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

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

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

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

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

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

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

    if 5.8000000000000004e44 < y < 2.00000000000000009e48

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{+62}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-11}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{+44}:\\ \;\;\;\;z \cdot \frac{x}{-y}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+48}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 66.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+61}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-54}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+45}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+48}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -9.2e+61)
   (- z)
   (if (<= y 1.6e-54)
     (+ x y)
     (if (<= y 1.2e+45) (/ (* x (- z)) y) (if (<= y 1.2e+48) y (- z))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -9.2e+61) {
		tmp = -z;
	} else if (y <= 1.6e-54) {
		tmp = x + y;
	} else if (y <= 1.2e+45) {
		tmp = (x * -z) / y;
	} else if (y <= 1.2e+48) {
		tmp = y;
	} 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 <= (-9.2d+61)) then
        tmp = -z
    else if (y <= 1.6d-54) then
        tmp = x + y
    else if (y <= 1.2d+45) then
        tmp = (x * -z) / y
    else if (y <= 1.2d+48) then
        tmp = y
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -9.2e+61) {
		tmp = -z;
	} else if (y <= 1.6e-54) {
		tmp = x + y;
	} else if (y <= 1.2e+45) {
		tmp = (x * -z) / y;
	} else if (y <= 1.2e+48) {
		tmp = y;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -9.2e+61:
		tmp = -z
	elif y <= 1.6e-54:
		tmp = x + y
	elif y <= 1.2e+45:
		tmp = (x * -z) / y
	elif y <= 1.2e+48:
		tmp = y
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -9.2e+61)
		tmp = Float64(-z);
	elseif (y <= 1.6e-54)
		tmp = Float64(x + y);
	elseif (y <= 1.2e+45)
		tmp = Float64(Float64(x * Float64(-z)) / y);
	elseif (y <= 1.2e+48)
		tmp = y;
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -9.2e+61)
		tmp = -z;
	elseif (y <= 1.6e-54)
		tmp = x + y;
	elseif (y <= 1.2e+45)
		tmp = (x * -z) / y;
	elseif (y <= 1.2e+48)
		tmp = y;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -9.2e+61], (-z), If[LessEqual[y, 1.6e-54], N[(x + y), $MachinePrecision], If[LessEqual[y, 1.2e+45], N[(N[(x * (-z)), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.2e+48], y, (-z)]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+61}:\\
\;\;\;\;-z\\

\mathbf{elif}\;y \leq 1.6 \cdot 10^{-54}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{+45}:\\
\;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{+48}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -9.1999999999999998e61 or 1.2000000000000001e48 < y

    1. Initial program 70.9%

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

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

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

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

    if -9.1999999999999998e61 < y < 1.59999999999999999e-54

    1. Initial program 98.6%

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

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

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified74.0%

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

    if 1.59999999999999999e-54 < y < 1.19999999999999995e45

    1. Initial program 91.5%

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

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

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

        \[\leadsto -\color{blue}{z \cdot \frac{x + y}{y}} \]
      3. distribute-rgt-neg-in57.0%

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

        \[\leadsto z \cdot \color{blue}{\frac{x + y}{-y}} \]
      5. +-commutative57.0%

        \[\leadsto z \cdot \frac{\color{blue}{y + x}}{-y} \]
    5. Simplified57.0%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(-x\right) \cdot z}{y}} \]

    if 1.19999999999999995e45 < y < 1.2000000000000001e48

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+61}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-54}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+45}:\\ \;\;\;\;\frac{x \cdot \left(-z\right)}{y}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+48}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 68.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.6 \cdot 10^{+57} \lor \neg \left(y \leq 2.5 \cdot 10^{+49}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.59999999999999999e57 or 2.5000000000000002e49 < y

    1. Initial program 70.9%

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

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

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

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

    if -5.59999999999999999e57 < y < 2.5000000000000002e49

    1. Initial program 97.6%

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

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

        \[\leadsto \color{blue}{y + x} \]
    5. Simplified69.3%

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

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

Alternative 10: 58.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+41} \lor \neg \left(y \leq 2.9 \cdot 10^{+27}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2e41 or 2.9000000000000001e27 < y

    1. Initial program 71.4%

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

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

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

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

    if -6.2e41 < y < 2.9000000000000001e27

    1. Initial program 99.3%

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

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

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

Alternative 11: 41.6% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;x \leq 3.3 \cdot 10^{-199}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.14999999999999998e-168 or 3.3000000000000002e-199 < x

    1. Initial program 88.8%

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

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

    if -2.14999999999999998e-168 < x < 3.3000000000000002e-199

    1. Initial program 84.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.15 \cdot 10^{-168}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-199}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 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 87.9%

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

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

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 93.4% 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 2024096 
(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))))