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

Percentage Accurate: 100.0% → 100.0%
Time: 6.1s
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.5% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;z \leq 78000:\\
\;\;\;\;\frac{x}{-z}\\

\mathbf{elif}\;z \leq 6.8 \cdot 10^{+146}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 3.3 \cdot 10^{+160}:\\
\;\;\;\;\frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8e22 or 78000 < z < 6.79999999999999981e146 or 3.2999999999999997e160 < 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 73.6%

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

    if -8e22 < z < -1.75e-205 or 6.79999999999999981e146 < z < 3.2999999999999997e160

    1. Initial program 99.9%

      \[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-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 67.3%

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

    if -1.75e-205 < z < 78000

    1. Initial program 100.0%

      \[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-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 60.3%

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

        \[\leadsto \color{blue}{1 \cdot x - \frac{1}{z} \cdot x} \]
      2. *-lft-identity60.3%

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

        \[\leadsto x - \color{blue}{\frac{1 \cdot x}{z}} \]
      4. *-lft-identity60.5%

        \[\leadsto x - \frac{\color{blue}{x}}{z} \]
    7. Simplified60.5%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{z}} \]
      2. neg-mul-158.7%

        \[\leadsto \frac{\color{blue}{-x}}{z} \]
    10. Simplified58.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-205}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{elif}\;z \leq 78000:\\ \;\;\;\;\frac{x}{-z}\\ \mathbf{elif}\;z \leq 6.8 \cdot 10^{+146}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+160}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.0% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{+111} \lor \neg \left(x \leq -2.5 \cdot 10^{-10} \lor \neg \left(x \leq -1.75 \cdot 10^{-57}\right) \land x \leq 1.2 \cdot 10^{+34}\right):\\
\;\;\;\;x - \frac{x}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.7999999999999999e111 or -2.50000000000000016e-10 < x < -1.74999999999999996e-57 or 1.19999999999999993e34 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\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 91.6%

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

        \[\leadsto \color{blue}{1 \cdot x - \frac{1}{z} \cdot x} \]
      2. *-lft-identity91.6%

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

        \[\leadsto x - \color{blue}{\frac{1 \cdot x}{z}} \]
      4. *-lft-identity91.7%

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

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

    if -2.7999999999999999e111 < x < -2.50000000000000016e-10 or -1.74999999999999996e-57 < x < 1.19999999999999993e34

    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 90.7%

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

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

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

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

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

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

Alternative 4: 61.3% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;z \leq 9 \cdot 10^{+14} \lor \neg \left(z \leq 3.9 \cdot 10^{+148}\right) \land z \leq 3.3 \cdot 10^{+160}:\\
\;\;\;\;\frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.15e21 or 9e14 < z < 3.90000000000000002e148 or 3.2999999999999997e160 < 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 73.6%

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

    if -2.15e21 < z < 9e14 or 3.90000000000000002e148 < z < 3.2999999999999997e160

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\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 51.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.15 \cdot 10^{+21}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+14} \lor \neg \left(z \leq 3.9 \cdot 10^{+148}\right) \land z \leq 3.3 \cdot 10^{+160}:\\ \;\;\;\;\frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 76.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-212} \lor \neg \left(z \leq 1.14 \cdot 10^{-24}\right):\\
\;\;\;\;x + \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6.0000000000000005e-212 or 1.1400000000000001e-24 < 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 89.7%

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

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

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

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

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

    if -6.0000000000000005e-212 < z < 1.1400000000000001e-24

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x - \frac{x}{z}\right)} + \frac{y}{z} \]
      8. associate--r-93.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 62.9%

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

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

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

        \[\leadsto x - \color{blue}{\frac{1 \cdot x}{z}} \]
      4. *-lft-identity63.1%

        \[\leadsto x - \frac{\color{blue}{x}}{z} \]
    7. Simplified63.1%

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot x}{z}} \]
      2. neg-mul-163.1%

        \[\leadsto \frac{\color{blue}{-x}}{z} \]
    10. Simplified63.1%

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

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

Alternative 6: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1 \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 -1.0) (not (<= z 1.0))) (+ x (/ y z)) (/ (- y x) z)))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.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 <= (-1.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 <= -1.0) || !(z <= 1.0)) {
		tmp = x + (y / z);
	} else {
		tmp = (y - x) / z;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.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 <= -1.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 <= -1.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, -1.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 -1 \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 < -1 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 99.1%

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

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

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

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

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

    if -1 < z < 1

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\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 0 98.4%

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

Alternative 7: 36.6% 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-sub98.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(x - \frac{x}{z}\right)} + \frac{y}{z} \]
    8. associate--r-98.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 35.8%

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

    \[\leadsto x \]
  7. Add Preprocessing

Reproduce

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