Statistics.Sample:$swelfordMean from math-functions-0.1.5.2

Percentage Accurate: 100.0% → 100.0%
Time: 6.6s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \frac{y - x}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
double code(double x, double y, double z) {
	return x + ((y - x) / 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 - x) / z)
end function
public static double code(double x, double y, double z) {
	return x + ((y - x) / z);
}
def code(x, y, z):
	return x + ((y - x) / z)
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) / z))
end
function tmp = code(x, y, z)
	tmp = x + ((y - x) / z);
end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \frac{y - x}{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 7 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y - x}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
double code(double x, double y, double z) {
	return x + ((y - x) / 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 - x) / z)
end function
public static double code(double x, double y, double z) {
	return x + ((y - x) / z);
}
def code(x, y, z):
	return x + ((y - x) / z)
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) / z))
end
function tmp = code(x, y, z)
	tmp = x + ((y - x) / z);
end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \frac{y - x}{z} \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (/ (- y x) z)))
double code(double x, double y, double z) {
	return x + ((y - x) / 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 - x) / z)
end function
public static double code(double x, double y, double z) {
	return x + ((y - x) / z);
}
def code(x, y, z):
	return x + ((y - x) / z)
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) / z))
end
function tmp = code(x, y, z)
	tmp = x + ((y - x) / z);
end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

Alternative 2: 61.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x}{-z}\\ \mathbf{if}\;z \leq -4 \cdot 10^{+67}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.16 \cdot 10^{-18}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{-119}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-155}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq -1.12 \cdot 10^{-301}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-274}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-181}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{+16}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ x (- z))))
   (if (<= z -4e+67)
     x
     (if (<= z -1.16e-18)
       (/ y z)
       (if (<= z -3.9e-119)
         t_0
         (if (<= z -2.7e-155)
           (/ y z)
           (if (<= z -1.12e-301)
             t_0
             (if (<= z 2.4e-274)
               (/ y z)
               (if (<= z 4.1e-181) t_0 (if (<= z 5.8e+16) (/ y z) x))))))))))
double code(double x, double y, double z) {
	double t_0 = x / -z;
	double tmp;
	if (z <= -4e+67) {
		tmp = x;
	} else if (z <= -1.16e-18) {
		tmp = y / z;
	} else if (z <= -3.9e-119) {
		tmp = t_0;
	} else if (z <= -2.7e-155) {
		tmp = y / z;
	} else if (z <= -1.12e-301) {
		tmp = t_0;
	} else if (z <= 2.4e-274) {
		tmp = y / z;
	} else if (z <= 4.1e-181) {
		tmp = t_0;
	} else if (z <= 5.8e+16) {
		tmp = y / 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) :: t_0
    real(8) :: tmp
    t_0 = x / -z
    if (z <= (-4d+67)) then
        tmp = x
    else if (z <= (-1.16d-18)) then
        tmp = y / z
    else if (z <= (-3.9d-119)) then
        tmp = t_0
    else if (z <= (-2.7d-155)) then
        tmp = y / z
    else if (z <= (-1.12d-301)) then
        tmp = t_0
    else if (z <= 2.4d-274) then
        tmp = y / z
    else if (z <= 4.1d-181) then
        tmp = t_0
    else if (z <= 5.8d+16) then
        tmp = y / z
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x / -z;
	double tmp;
	if (z <= -4e+67) {
		tmp = x;
	} else if (z <= -1.16e-18) {
		tmp = y / z;
	} else if (z <= -3.9e-119) {
		tmp = t_0;
	} else if (z <= -2.7e-155) {
		tmp = y / z;
	} else if (z <= -1.12e-301) {
		tmp = t_0;
	} else if (z <= 2.4e-274) {
		tmp = y / z;
	} else if (z <= 4.1e-181) {
		tmp = t_0;
	} else if (z <= 5.8e+16) {
		tmp = y / z;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x / -z
	tmp = 0
	if z <= -4e+67:
		tmp = x
	elif z <= -1.16e-18:
		tmp = y / z
	elif z <= -3.9e-119:
		tmp = t_0
	elif z <= -2.7e-155:
		tmp = y / z
	elif z <= -1.12e-301:
		tmp = t_0
	elif z <= 2.4e-274:
		tmp = y / z
	elif z <= 4.1e-181:
		tmp = t_0
	elif z <= 5.8e+16:
		tmp = y / z
	else:
		tmp = x
	return tmp
function code(x, y, z)
	t_0 = Float64(x / Float64(-z))
	tmp = 0.0
	if (z <= -4e+67)
		tmp = x;
	elseif (z <= -1.16e-18)
		tmp = Float64(y / z);
	elseif (z <= -3.9e-119)
		tmp = t_0;
	elseif (z <= -2.7e-155)
		tmp = Float64(y / z);
	elseif (z <= -1.12e-301)
		tmp = t_0;
	elseif (z <= 2.4e-274)
		tmp = Float64(y / z);
	elseif (z <= 4.1e-181)
		tmp = t_0;
	elseif (z <= 5.8e+16)
		tmp = Float64(y / z);
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x / -z;
	tmp = 0.0;
	if (z <= -4e+67)
		tmp = x;
	elseif (z <= -1.16e-18)
		tmp = y / z;
	elseif (z <= -3.9e-119)
		tmp = t_0;
	elseif (z <= -2.7e-155)
		tmp = y / z;
	elseif (z <= -1.12e-301)
		tmp = t_0;
	elseif (z <= 2.4e-274)
		tmp = y / z;
	elseif (z <= 4.1e-181)
		tmp = t_0;
	elseif (z <= 5.8e+16)
		tmp = y / z;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / (-z)), $MachinePrecision]}, If[LessEqual[z, -4e+67], x, If[LessEqual[z, -1.16e-18], N[(y / z), $MachinePrecision], If[LessEqual[z, -3.9e-119], t$95$0, If[LessEqual[z, -2.7e-155], N[(y / z), $MachinePrecision], If[LessEqual[z, -1.12e-301], t$95$0, If[LessEqual[z, 2.4e-274], N[(y / z), $MachinePrecision], If[LessEqual[z, 4.1e-181], t$95$0, If[LessEqual[z, 5.8e+16], N[(y / z), $MachinePrecision], x]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -1.16 \cdot 10^{-18}:\\
\;\;\;\;\frac{y}{z}\\

\mathbf{elif}\;z \leq -3.9 \cdot 10^{-119}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -2.7 \cdot 10^{-155}:\\
\;\;\;\;\frac{y}{z}\\

\mathbf{elif}\;z \leq -1.12 \cdot 10^{-301}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{-274}:\\
\;\;\;\;\frac{y}{z}\\

\mathbf{elif}\;z \leq 4.1 \cdot 10^{-181}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.99999999999999993e67 or 5.8e16 < z

    1. Initial program 100.0%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - \frac{x - y}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 74.7%

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

    if -3.99999999999999993e67 < z < -1.16e-18 or -3.8999999999999999e-119 < z < -2.69999999999999981e-155 or -1.12e-301 < z < 2.4e-274 or 4.1000000000000001e-181 < z < 5.8e16

    1. Initial program 99.9%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub97.5%

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

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

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

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

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

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

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

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

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

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

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

    if -1.16e-18 < z < -3.8999999999999999e-119 or -2.69999999999999981e-155 < z < -1.12e-301 or 2.4e-274 < z < 4.1000000000000001e-181

    1. Initial program 100.0%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub92.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - \frac{x - y}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 71.1%

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{1}{z}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-out--71.1%

        \[\leadsto \color{blue}{x \cdot 1 - x \cdot \frac{1}{z}} \]
      2. *-rgt-identity71.1%

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

        \[\leadsto x - \color{blue}{\frac{x \cdot 1}{z}} \]
      4. *-rgt-identity71.3%

        \[\leadsto x - \frac{\color{blue}{x}}{z} \]
    7. Simplified71.3%

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

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

        \[\leadsto \color{blue}{-\frac{x}{z}} \]
      2. distribute-neg-frac271.3%

        \[\leadsto \color{blue}{\frac{x}{-z}} \]
    10. Simplified71.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+67}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.16 \cdot 10^{-18}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq -3.9 \cdot 10^{-119}:\\ \;\;\;\;\frac{x}{-z}\\ \mathbf{elif}\;z \leq -2.7 \cdot 10^{-155}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq -1.12 \cdot 10^{-301}:\\ \;\;\;\;\frac{x}{-z}\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-274}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-181}:\\ \;\;\;\;\frac{x}{-z}\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{+16}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+19} \lor \neg \left(y \leq 8.2 \cdot 10^{-54}\right):\\
\;\;\;\;x + \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.8e19 or 8.2000000000000001e-54 < y

    1. Initial program 100.0%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub94.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x + \frac{y}{z}} \]
    9. Step-by-step derivation
      1. +-commutative90.9%

        \[\leadsto \color{blue}{\frac{y}{z} + x} \]
    10. Simplified90.9%

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

    if -2.8e19 < y < 8.2000000000000001e-54

    1. Initial program 99.9%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub99.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - \frac{x - y}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 87.5%

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{1}{z}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-out--87.5%

        \[\leadsto \color{blue}{x \cdot 1 - x \cdot \frac{1}{z}} \]
      2. *-rgt-identity87.5%

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

        \[\leadsto x - \color{blue}{\frac{x \cdot 1}{z}} \]
      4. *-rgt-identity87.6%

        \[\leadsto x - \frac{\color{blue}{x}}{z} \]
    7. Simplified87.6%

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

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

Alternative 4: 98.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -15600 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x + \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -15600 or 1 < z

    1. Initial program 100.0%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{y}{z} + x} \]
    10. Simplified98.8%

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

    if -15600 < z < 1

    1. Initial program 99.9%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub94.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 61.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{+67}:\\
\;\;\;\;x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.3000000000000001e67 or 8.5e17 < z

    1. Initial program 100.0%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - \frac{x - y}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 74.7%

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

    if -4.3000000000000001e67 < z < 8.5e17

    1. Initial program 99.9%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub95.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+67}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+17}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 75.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+215}:\\
\;\;\;\;\frac{x}{-z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.45e215

    1. Initial program 100.0%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub91.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - \frac{x - y}{z}} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 99.9%

      \[\leadsto \color{blue}{x \cdot \left(1 - \frac{1}{z}\right)} \]
    6. Step-by-step derivation
      1. distribute-lft-out--99.9%

        \[\leadsto \color{blue}{x \cdot 1 - x \cdot \frac{1}{z}} \]
      2. *-rgt-identity99.9%

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

        \[\leadsto x - \color{blue}{\frac{x \cdot 1}{z}} \]
      4. *-rgt-identity100.0%

        \[\leadsto x - \frac{\color{blue}{x}}{z} \]
    7. Simplified100.0%

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

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

        \[\leadsto \color{blue}{-\frac{x}{z}} \]
      2. distribute-neg-frac271.9%

        \[\leadsto \color{blue}{\frac{x}{-z}} \]
    10. Simplified71.9%

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

    if -1.45e215 < x

    1. Initial program 99.9%

      \[x + \frac{y - x}{z} \]
    2. Step-by-step derivation
      1. div-sub97.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x - \color{blue}{\frac{y}{-z}} \]
    7. Simplified79.3%

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

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

        \[\leadsto \color{blue}{\frac{y}{z} + x} \]
    10. Simplified79.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{+215}:\\ \;\;\;\;\frac{x}{-z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 36.9% accurate, 7.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 100.0%

    \[x + \frac{y - x}{z} \]
  2. Step-by-step derivation
    1. div-sub97.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{x - \frac{x - y}{z}} \]
  4. Add Preprocessing
  5. Taylor expanded in z around inf 35.8%

    \[\leadsto \color{blue}{x} \]
  6. Final simplification35.8%

    \[\leadsto x \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2024039 
(FPCore (x y z)
  :name "Statistics.Sample:$swelfordMean from math-functions-0.1.5.2"
  :precision binary64
  (+ x (/ (- y x) z)))