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

Percentage Accurate: 88.1% → 99.8%
Time: 6.3s
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: 88.1% 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 -5 \cdot 10^{-299} \lor \neg \left(t_0 \leq 0\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \left(\left(-y\right) - 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 -5e-299) (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 <= -5e-299) || !(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 <= (-5d-299)) .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 <= -5e-299) || !(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 <= -5e-299) 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 <= -5e-299) || !(t_0 <= 0.0))
		tmp = t_0;
	else
		tmp = Float64(Float64(z * Float64(Float64(-y) - 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 <= -5e-299) || ~((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, -5e-299], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(z * N[((-y) - x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(\left(-y\right) - 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))) < -4.99999999999999956e-299 or 0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z)))

    1. Initial program 99.9%

      \[\frac{x + y}{1 - \frac{y}{z}} \]

    if -4.99999999999999956e-299 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < 0.0

    1. Initial program 6.3%

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

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

Alternative 2: 66.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+147}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq -1 \cdot 10^{+102}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{+48}:\\ \;\;\;\;z \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{+41}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+120}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.9e+147)
   (- z)
   (if (<= y -1e+102)
     (+ x y)
     (if (<= y -1.15e+48)
       (* z (- 1.0 (/ x y)))
       (if (<= y -8.5e+41)
         (* y (+ 1.0 (/ y z)))
         (if (<= y 1.1e+120) (/ x (- 1.0 (/ y z))) (- z)))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.9e+147) {
		tmp = -z;
	} else if (y <= -1e+102) {
		tmp = x + y;
	} else if (y <= -1.15e+48) {
		tmp = z * (1.0 - (x / y));
	} else if (y <= -8.5e+41) {
		tmp = y * (1.0 + (y / z));
	} else if (y <= 1.1e+120) {
		tmp = x / (1.0 - (y / z));
	} 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.9d+147)) then
        tmp = -z
    else if (y <= (-1d+102)) then
        tmp = x + y
    else if (y <= (-1.15d+48)) then
        tmp = z * (1.0d0 - (x / y))
    else if (y <= (-8.5d+41)) then
        tmp = y * (1.0d0 + (y / z))
    else if (y <= 1.1d+120) then
        tmp = x / (1.0d0 - (y / z))
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.9e+147) {
		tmp = -z;
	} else if (y <= -1e+102) {
		tmp = x + y;
	} else if (y <= -1.15e+48) {
		tmp = z * (1.0 - (x / y));
	} else if (y <= -8.5e+41) {
		tmp = y * (1.0 + (y / z));
	} else if (y <= 1.1e+120) {
		tmp = x / (1.0 - (y / z));
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.9e+147:
		tmp = -z
	elif y <= -1e+102:
		tmp = x + y
	elif y <= -1.15e+48:
		tmp = z * (1.0 - (x / y))
	elif y <= -8.5e+41:
		tmp = y * (1.0 + (y / z))
	elif y <= 1.1e+120:
		tmp = x / (1.0 - (y / z))
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.9e+147)
		tmp = Float64(-z);
	elseif (y <= -1e+102)
		tmp = Float64(x + y);
	elseif (y <= -1.15e+48)
		tmp = Float64(z * Float64(1.0 - Float64(x / y)));
	elseif (y <= -8.5e+41)
		tmp = Float64(y * Float64(1.0 + Float64(y / z)));
	elseif (y <= 1.1e+120)
		tmp = Float64(x / Float64(1.0 - Float64(y / z)));
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.9e+147)
		tmp = -z;
	elseif (y <= -1e+102)
		tmp = x + y;
	elseif (y <= -1.15e+48)
		tmp = z * (1.0 - (x / y));
	elseif (y <= -8.5e+41)
		tmp = y * (1.0 + (y / z));
	elseif (y <= 1.1e+120)
		tmp = x / (1.0 - (y / z));
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+147], (-z), If[LessEqual[y, -1e+102], N[(x + y), $MachinePrecision], If[LessEqual[y, -1.15e+48], N[(z * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -8.5e+41], N[(y * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+120], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-z)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -1 \cdot 10^{+102}:\\
\;\;\;\;x + y\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if y < -1.89999999999999985e147 or 1.1000000000000001e120 < y

    1. Initial program 69.0%

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

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

        \[\leadsto \color{blue}{-z} \]
    4. Simplified75.0%

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

    if -1.89999999999999985e147 < y < -9.99999999999999977e101

    1. Initial program 99.9%

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

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

        \[\leadsto \color{blue}{y + x} \]
    4. Simplified61.7%

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

    if -9.99999999999999977e101 < y < -1.15e48

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z}{y} \cdot \left(\left(-y\right) - x\right)} \]
    5. Step-by-step derivation
      1. sub-neg57.3%

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

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

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

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

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

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

        \[\leadsto \frac{z}{y} \cdot \color{blue}{y} + \frac{z}{y} \cdot \left(-x\right) \]
    6. Applied egg-rr39.8%

      \[\leadsto \color{blue}{\frac{z}{y} \cdot y + \frac{z}{y} \cdot \left(-x\right)} \]
    7. Step-by-step derivation
      1. distribute-lft-out39.8%

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

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

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

        \[\leadsto \color{blue}{z \cdot \frac{y - x}{y}} \]
      5. div-sub53.7%

        \[\leadsto z \cdot \color{blue}{\left(\frac{y}{y} - \frac{x}{y}\right)} \]
      6. *-inverses53.7%

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

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

    if -1.15e48 < y < -8.49999999999999938e41

    1. Initial program 76.9%

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

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

        \[\leadsto \color{blue}{\left(x + y\right) + \frac{y \cdot \left(x + y\right)}{z}} \]
      2. *-lft-identity75.4%

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

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

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

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

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

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

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

    if -8.49999999999999938e41 < y < 1.1000000000000001e120

    1. Initial program 98.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+147}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq -1 \cdot 10^{+102}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq -1.15 \cdot 10^{+48}:\\ \;\;\;\;z \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{+41}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+120}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 3: 73.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-z}{\frac{y}{x + y}}\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+22}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-70}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+15}:\\ \;\;\;\;\left(x + y\right) \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+56}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (- z) (/ y (+ x y)))))
   (if (<= y -1.8e+22)
     t_0
     (if (<= y 2.25e-70)
       (/ x (- 1.0 (/ y z)))
       (if (<= y 4e+15)
         (* (+ x y) (- (/ z y)))
         (if (<= y 7.5e+56) (+ x y) t_0))))))
double code(double x, double y, double z) {
	double t_0 = -z / (y / (x + y));
	double tmp;
	if (y <= -1.8e+22) {
		tmp = t_0;
	} else if (y <= 2.25e-70) {
		tmp = x / (1.0 - (y / z));
	} else if (y <= 4e+15) {
		tmp = (x + y) * -(z / y);
	} else if (y <= 7.5e+56) {
		tmp = x + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -z / (y / (x + y))
    if (y <= (-1.8d+22)) then
        tmp = t_0
    else if (y <= 2.25d-70) then
        tmp = x / (1.0d0 - (y / z))
    else if (y <= 4d+15) then
        tmp = (x + y) * -(z / y)
    else if (y <= 7.5d+56) then
        tmp = x + y
    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 <= -1.8e+22) {
		tmp = t_0;
	} else if (y <= 2.25e-70) {
		tmp = x / (1.0 - (y / z));
	} else if (y <= 4e+15) {
		tmp = (x + y) * -(z / y);
	} else if (y <= 7.5e+56) {
		tmp = x + y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -z / (y / (x + y))
	tmp = 0
	if y <= -1.8e+22:
		tmp = t_0
	elif y <= 2.25e-70:
		tmp = x / (1.0 - (y / z))
	elif y <= 4e+15:
		tmp = (x + y) * -(z / y)
	elif y <= 7.5e+56:
		tmp = x + y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(-z) / Float64(y / Float64(x + y)))
	tmp = 0.0
	if (y <= -1.8e+22)
		tmp = t_0;
	elseif (y <= 2.25e-70)
		tmp = Float64(x / Float64(1.0 - Float64(y / z)));
	elseif (y <= 4e+15)
		tmp = Float64(Float64(x + y) * Float64(-Float64(z / y)));
	elseif (y <= 7.5e+56)
		tmp = Float64(x + y);
	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 <= -1.8e+22)
		tmp = t_0;
	elseif (y <= 2.25e-70)
		tmp = x / (1.0 - (y / z));
	elseif (y <= 4e+15)
		tmp = (x + y) * -(z / y);
	elseif (y <= 7.5e+56)
		tmp = x + y;
	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, -1.8e+22], t$95$0, If[LessEqual[y, 2.25e-70], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+15], N[(N[(x + y), $MachinePrecision] * (-N[(z / y), $MachinePrecision])), $MachinePrecision], If[LessEqual[y, 7.5e+56], N[(x + y), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.8e22 or 7.4999999999999999e56 < y

    1. Initial program 76.8%

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

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

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

        \[\leadsto -\color{blue}{\frac{z}{\frac{y}{x + y}}} \]
      3. distribute-neg-frac78.1%

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

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

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

    if -1.8e22 < y < 2.25000000000000011e-70

    1. Initial program 99.9%

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

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

    if 2.25000000000000011e-70 < y < 4e15

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

    if 4e15 < y < 7.4999999999999999e56

    1. Initial program 84.9%

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

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

        \[\leadsto \color{blue}{y + x} \]
    4. Simplified75.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+22}:\\ \;\;\;\;\frac{-z}{\frac{y}{x + y}}\\ \mathbf{elif}\;y \leq 2.25 \cdot 10^{-70}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+15}:\\ \;\;\;\;\left(x + y\right) \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+56}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;\frac{-z}{\frac{y}{x + y}}\\ \end{array} \]

Alternative 4: 67.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+147}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq -2 \cdot 10^{+94}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq -4.2 \cdot 10^{+49}:\\ \;\;\;\;-z \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+115}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.9e+147)
   (- z)
   (if (<= y -2e+94)
     (+ x y)
     (if (<= y -4.2e+49)
       (- (* z (/ x y)))
       (if (<= y -2.4e+47)
         (* y (+ 1.0 (/ y z)))
         (if (<= y 1.02e+115) (+ x y) (- z)))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.9e+147) {
		tmp = -z;
	} else if (y <= -2e+94) {
		tmp = x + y;
	} else if (y <= -4.2e+49) {
		tmp = -(z * (x / y));
	} else if (y <= -2.4e+47) {
		tmp = y * (1.0 + (y / z));
	} else if (y <= 1.02e+115) {
		tmp = x + 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 <= (-1.9d+147)) then
        tmp = -z
    else if (y <= (-2d+94)) then
        tmp = x + y
    else if (y <= (-4.2d+49)) then
        tmp = -(z * (x / y))
    else if (y <= (-2.4d+47)) then
        tmp = y * (1.0d0 + (y / z))
    else if (y <= 1.02d+115) then
        tmp = x + y
    else
        tmp = -z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.9e+147) {
		tmp = -z;
	} else if (y <= -2e+94) {
		tmp = x + y;
	} else if (y <= -4.2e+49) {
		tmp = -(z * (x / y));
	} else if (y <= -2.4e+47) {
		tmp = y * (1.0 + (y / z));
	} else if (y <= 1.02e+115) {
		tmp = x + y;
	} else {
		tmp = -z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -1.9e+147:
		tmp = -z
	elif y <= -2e+94:
		tmp = x + y
	elif y <= -4.2e+49:
		tmp = -(z * (x / y))
	elif y <= -2.4e+47:
		tmp = y * (1.0 + (y / z))
	elif y <= 1.02e+115:
		tmp = x + y
	else:
		tmp = -z
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.9e+147)
		tmp = Float64(-z);
	elseif (y <= -2e+94)
		tmp = Float64(x + y);
	elseif (y <= -4.2e+49)
		tmp = Float64(-Float64(z * Float64(x / y)));
	elseif (y <= -2.4e+47)
		tmp = Float64(y * Float64(1.0 + Float64(y / z)));
	elseif (y <= 1.02e+115)
		tmp = Float64(x + y);
	else
		tmp = Float64(-z);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.9e+147)
		tmp = -z;
	elseif (y <= -2e+94)
		tmp = x + y;
	elseif (y <= -4.2e+49)
		tmp = -(z * (x / y));
	elseif (y <= -2.4e+47)
		tmp = y * (1.0 + (y / z));
	elseif (y <= 1.02e+115)
		tmp = x + y;
	else
		tmp = -z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+147], (-z), If[LessEqual[y, -2e+94], N[(x + y), $MachinePrecision], If[LessEqual[y, -4.2e+49], (-N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), If[LessEqual[y, -2.4e+47], N[(y * N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.02e+115], N[(x + y), $MachinePrecision], (-z)]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2 \cdot 10^{+94}:\\
\;\;\;\;x + y\\

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

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

\mathbf{elif}\;y \leq 1.02 \cdot 10^{+115}:\\
\;\;\;\;x + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -1.89999999999999985e147 or 1.02e115 < y

    1. Initial program 70.6%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg72.7%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified72.7%

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

    if -1.89999999999999985e147 < y < -2e94 or -2.40000000000000019e47 < y < 1.02e115

    1. Initial program 98.3%

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

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

        \[\leadsto \color{blue}{y + x} \]
    4. Simplified69.0%

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

    if -2e94 < y < -4.20000000000000022e49

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-\frac{x}{y}\right)} \]
      5. distribute-neg-frac52.6%

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

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

    if -4.20000000000000022e49 < y < -2.40000000000000019e47

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+147}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq -2 \cdot 10^{+94}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq -4.2 \cdot 10^{+49}:\\ \;\;\;\;-z \cdot \frac{x}{y}\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{+115}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 5: 67.2% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;y \leq -1.05 \cdot 10^{+95}:\\
\;\;\;\;x + y\\

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

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

\mathbf{elif}\;y \leq 1.95 \cdot 10^{+108}:\\
\;\;\;\;x + y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.1499999999999999e147 or 1.94999999999999992e108 < y

    1. Initial program 70.6%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg72.7%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified72.7%

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

    if -2.1499999999999999e147 < y < -1.05e95 or -2.40000000000000019e47 < y < 1.94999999999999992e108

    1. Initial program 98.3%

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

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

        \[\leadsto \color{blue}{y + x} \]
    4. Simplified69.0%

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

    if -1.05e95 < y < -3.09999999999999992e49

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{z}{y} \cdot \left(\left(-y\right) - x\right)} \]
    5. Step-by-step derivation
      1. sub-neg57.3%

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

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

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

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

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

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

        \[\leadsto \frac{z}{y} \cdot \color{blue}{y} + \frac{z}{y} \cdot \left(-x\right) \]
    6. Applied egg-rr39.8%

      \[\leadsto \color{blue}{\frac{z}{y} \cdot y + \frac{z}{y} \cdot \left(-x\right)} \]
    7. Step-by-step derivation
      1. distribute-lft-out39.8%

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

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

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

        \[\leadsto \color{blue}{z \cdot \frac{y - x}{y}} \]
      5. div-sub53.7%

        \[\leadsto z \cdot \color{blue}{\left(\frac{y}{y} - \frac{x}{y}\right)} \]
      6. *-inverses53.7%

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

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

    if -3.09999999999999992e49 < y < -2.40000000000000019e47

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+147}:\\ \;\;\;\;-z\\ \mathbf{elif}\;y \leq -1.05 \cdot 10^{+95}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq -3.1 \cdot 10^{+49}:\\ \;\;\;\;z \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{+47}:\\ \;\;\;\;y \cdot \left(1 + \frac{y}{z}\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+108}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]

Alternative 6: 63.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - \frac{y}{z}\\ t_1 := \frac{x}{t_0}\\ \mathbf{if}\;x \leq -4.2 \cdot 10^{-63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-146}:\\ \;\;\;\;\frac{y}{t_0}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-81}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+133}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ x t_0)))
   (if (<= x -4.2e-63)
     t_1
     (if (<= x 7.5e-146)
       (/ y t_0)
       (if (<= x 8e-81) (+ x y) (if (<= x 2.2e+133) (- z) t_1))))))
double code(double x, double y, double z) {
	double t_0 = 1.0 - (y / z);
	double t_1 = x / t_0;
	double tmp;
	if (x <= -4.2e-63) {
		tmp = t_1;
	} else if (x <= 7.5e-146) {
		tmp = y / t_0;
	} else if (x <= 8e-81) {
		tmp = x + y;
	} else if (x <= 2.2e+133) {
		tmp = -z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (y / z)
    t_1 = x / t_0
    if (x <= (-4.2d-63)) then
        tmp = t_1
    else if (x <= 7.5d-146) then
        tmp = y / t_0
    else if (x <= 8d-81) then
        tmp = x + y
    else if (x <= 2.2d+133) then
        tmp = -z
    else
        tmp = t_1
    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 = x / t_0;
	double tmp;
	if (x <= -4.2e-63) {
		tmp = t_1;
	} else if (x <= 7.5e-146) {
		tmp = y / t_0;
	} else if (x <= 8e-81) {
		tmp = x + y;
	} else if (x <= 2.2e+133) {
		tmp = -z;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 1.0 - (y / z)
	t_1 = x / t_0
	tmp = 0
	if x <= -4.2e-63:
		tmp = t_1
	elif x <= 7.5e-146:
		tmp = y / t_0
	elif x <= 8e-81:
		tmp = x + y
	elif x <= 2.2e+133:
		tmp = -z
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(1.0 - Float64(y / z))
	t_1 = Float64(x / t_0)
	tmp = 0.0
	if (x <= -4.2e-63)
		tmp = t_1;
	elseif (x <= 7.5e-146)
		tmp = Float64(y / t_0);
	elseif (x <= 8e-81)
		tmp = Float64(x + y);
	elseif (x <= 2.2e+133)
		tmp = Float64(-z);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 1.0 - (y / z);
	t_1 = x / t_0;
	tmp = 0.0;
	if (x <= -4.2e-63)
		tmp = t_1;
	elseif (x <= 7.5e-146)
		tmp = y / t_0;
	elseif (x <= 8e-81)
		tmp = x + y;
	elseif (x <= 2.2e+133)
		tmp = -z;
	else
		tmp = t_1;
	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[(x / t$95$0), $MachinePrecision]}, If[LessEqual[x, -4.2e-63], t$95$1, If[LessEqual[x, 7.5e-146], N[(y / t$95$0), $MachinePrecision], If[LessEqual[x, 8e-81], N[(x + y), $MachinePrecision], If[LessEqual[x, 2.2e+133], (-z), t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 7.5 \cdot 10^{-146}:\\
\;\;\;\;\frac{y}{t_0}\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-81}:\\
\;\;\;\;x + y\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+133}:\\
\;\;\;\;-z\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -4.2e-63 or 2.2e133 < x

    1. Initial program 91.3%

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

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

    if -4.2e-63 < x < 7.49999999999999981e-146

    1. Initial program 86.0%

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

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

    if 7.49999999999999981e-146 < x < 7.9999999999999997e-81

    1. Initial program 90.4%

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

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

        \[\leadsto \color{blue}{y + x} \]
    4. Simplified77.8%

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

    if 7.9999999999999997e-81 < x < 2.2e133

    1. Initial program 85.1%

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

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

        \[\leadsto \color{blue}{-z} \]
    4. Simplified58.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-63}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-146}:\\ \;\;\;\;\frac{y}{1 - \frac{y}{z}}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-81}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+133}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 - \frac{y}{z}}\\ \end{array} \]

Alternative 7: 67.9% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.1499999999999999e147 or 9.9999999999999994e104 < y

    1. Initial program 70.6%

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

      \[\leadsto \color{blue}{-1 \cdot z} \]
    3. Step-by-step derivation
      1. mul-1-neg72.7%

        \[\leadsto \color{blue}{-z} \]
    4. Simplified72.7%

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

    if -2.1499999999999999e147 < y < 9.9999999999999994e104

    1. Initial program 96.7%

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

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

        \[\leadsto \color{blue}{y + x} \]
    4. Simplified66.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+147} \lor \neg \left(y \leq 10^{+105}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]

Alternative 8: 58.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -5200000 \lor \neg \left(y \leq 2.8 \cdot 10^{-76}\right):\\
\;\;\;\;-z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.2e6 or 2.8000000000000001e-76 < y

    1. Initial program 81.0%

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

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

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

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

    if -5.2e6 < y < 2.8000000000000001e-76

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5200000 \lor \neg \left(y \leq 2.8 \cdot 10^{-76}\right):\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 9: 39.4% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 2.7 \cdot 10^{-184}:\\
\;\;\;\;y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.8e-259 or 2.7000000000000001e-184 < x

    1. Initial program 89.4%

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

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

    if -3.8e-259 < x < 2.7000000000000001e-184

    1. Initial program 84.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-259}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-184}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 10: 35.1% 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.6%

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

    \[\leadsto \color{blue}{x} \]
  3. Final simplification36.1%

    \[\leadsto x \]

Developer target: 93.9% accurate, 0.7× 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 2023310 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :herbie-target
  (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))))