Numeric.SpecFunctions:choose from math-functions-0.1.5.2

Percentage Accurate: 84.3% → 96.6%
Time: 5.0s
Alternatives: 9
Speedup: 0.4×

Specification

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

\\
\frac{x \cdot \left(y + z\right)}{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 9 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: 84.3% accurate, 1.0× speedup?

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

\\
\frac{x \cdot \left(y + z\right)}{z}
\end{array}

Alternative 1: 96.6% accurate, 0.4× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;x\_m \leq 2.6 \cdot 10^{-147} \lor \neg \left(x\_m \leq 10^{-20}\right):\\ \;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m \cdot \left(y + z\right)}{z}\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (or (<= x_m 2.6e-147) (not (<= x_m 1e-20)))
    (+ x_m (* x_m (/ y z)))
    (/ (* x_m (+ y z)) z))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((x_m <= 2.6e-147) || !(x_m <= 1e-20)) {
		tmp = x_m + (x_m * (y / z));
	} else {
		tmp = (x_m * (y + z)) / z;
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x_m <= 2.6d-147) .or. (.not. (x_m <= 1d-20))) then
        tmp = x_m + (x_m * (y / z))
    else
        tmp = (x_m * (y + z)) / z
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((x_m <= 2.6e-147) || !(x_m <= 1e-20)) {
		tmp = x_m + (x_m * (y / z));
	} else {
		tmp = (x_m * (y + z)) / z;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (x_m <= 2.6e-147) or not (x_m <= 1e-20):
		tmp = x_m + (x_m * (y / z))
	else:
		tmp = (x_m * (y + z)) / z
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((x_m <= 2.6e-147) || !(x_m <= 1e-20))
		tmp = Float64(x_m + Float64(x_m * Float64(y / z)));
	else
		tmp = Float64(Float64(x_m * Float64(y + z)) / z);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((x_m <= 2.6e-147) || ~((x_m <= 1e-20)))
		tmp = x_m + (x_m * (y / z));
	else
		tmp = (x_m * (y + z)) / z;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[x$95$m, 2.6e-147], N[Not[LessEqual[x$95$m, 1e-20]], $MachinePrecision]], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 2.6 \cdot 10^{-147} \lor \neg \left(x\_m \leq 10^{-20}\right):\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2.5999999999999999e-147 or 9.99999999999999945e-21 < x

    1. Initial program 85.0%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*97.8%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg97.8%

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

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

        \[\leadsto x \cdot \color{blue}{\left(0 - \frac{y + z}{-z}\right)} \]
      5. remove-double-neg97.8%

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval97.8%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-97.8%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub097.8%

        \[\leadsto x \cdot \left(\color{blue}{\left(-\frac{y}{-z}\right)} + \left(--1\right)\right) \]
      12. distribute-frac-neg297.8%

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg97.8%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. sub-neg97.8%

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x + 1 \cdot x} \]
      4. *-commutative97.8%

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} + 1 \cdot x \]
      5. *-un-lft-identity97.8%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x} \]
    6. Applied egg-rr97.8%

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

    if 2.5999999999999999e-147 < x < 9.99999999999999945e-21

    1. Initial program 98.3%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification97.9%

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

Alternative 2: 93.6% accurate, 0.4× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq 1.4 \cdot 10^{+63} \lor \neg \left(y \leq 9.5 \cdot 10^{+204}\right):\\ \;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x\_m}{z}\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (or (<= y 1.4e+63) (not (<= y 9.5e+204)))
    (* x_m (- (/ y z) -1.0))
    (* y (/ x_m z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= 1.4e+63) || !(y <= 9.5e+204)) {
		tmp = x_m * ((y / z) - -1.0);
	} else {
		tmp = y * (x_m / z);
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= 1.4d+63) .or. (.not. (y <= 9.5d+204))) then
        tmp = x_m * ((y / z) - (-1.0d0))
    else
        tmp = y * (x_m / z)
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= 1.4e+63) || !(y <= 9.5e+204)) {
		tmp = x_m * ((y / z) - -1.0);
	} else {
		tmp = y * (x_m / z);
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (y <= 1.4e+63) or not (y <= 9.5e+204):
		tmp = x_m * ((y / z) - -1.0)
	else:
		tmp = y * (x_m / z)
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((y <= 1.4e+63) || !(y <= 9.5e+204))
		tmp = Float64(x_m * Float64(Float64(y / z) - -1.0));
	else
		tmp = Float64(y * Float64(x_m / z));
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((y <= 1.4e+63) || ~((y <= 9.5e+204)))
		tmp = x_m * ((y / z) - -1.0);
	else
		tmp = y * (x_m / z);
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, 1.4e+63], N[Not[LessEqual[y, 9.5e+204]], $MachinePrecision]], N[(x$95$m * N[(N[(y / z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+63} \lor \neg \left(y \leq 9.5 \cdot 10^{+204}\right):\\
\;\;\;\;x\_m \cdot \left(\frac{y}{z} - -1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.39999999999999993e63 or 9.5000000000000001e204 < y

    1. Initial program 85.8%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*97.1%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg97.1%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval97.1%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-97.1%

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

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

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg97.1%

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

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

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

    if 1.39999999999999993e63 < y < 9.5000000000000001e204

    1. Initial program 93.2%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*83.0%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg83.0%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval83.0%

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

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

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

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg83.0%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 93.2%

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

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

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

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

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

Alternative 3: 93.7% accurate, 0.4× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq 1.4 \cdot 10^{+63} \lor \neg \left(y \leq 8 \cdot 10^{+202}\right):\\ \;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x\_m}{z}\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (or (<= y 1.4e+63) (not (<= y 8e+202)))
    (+ x_m (* x_m (/ y z)))
    (* y (/ x_m z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= 1.4e+63) || !(y <= 8e+202)) {
		tmp = x_m + (x_m * (y / z));
	} else {
		tmp = y * (x_m / z);
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= 1.4d+63) .or. (.not. (y <= 8d+202))) then
        tmp = x_m + (x_m * (y / z))
    else
        tmp = y * (x_m / z)
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= 1.4e+63) || !(y <= 8e+202)) {
		tmp = x_m + (x_m * (y / z));
	} else {
		tmp = y * (x_m / z);
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (y <= 1.4e+63) or not (y <= 8e+202):
		tmp = x_m + (x_m * (y / z))
	else:
		tmp = y * (x_m / z)
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((y <= 1.4e+63) || !(y <= 8e+202))
		tmp = Float64(x_m + Float64(x_m * Float64(y / z)));
	else
		tmp = Float64(y * Float64(x_m / z));
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((y <= 1.4e+63) || ~((y <= 8e+202)))
		tmp = x_m + (x_m * (y / z));
	else
		tmp = y * (x_m / z);
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, 1.4e+63], N[Not[LessEqual[y, 8e+202]], $MachinePrecision]], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{+63} \lor \neg \left(y \leq 8 \cdot 10^{+202}\right):\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < 1.39999999999999993e63 or 7.9999999999999992e202 < y

    1. Initial program 85.8%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*97.1%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg97.1%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval97.1%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-97.1%

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

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

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg97.1%

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} + 1 \cdot x \]
      5. *-un-lft-identity97.1%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x} \]
    6. Applied egg-rr97.1%

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

    if 1.39999999999999993e63 < y < 7.9999999999999992e202

    1. Initial program 93.2%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*83.0%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg83.0%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval83.0%

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

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

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

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg83.0%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 93.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq 1.4 \cdot 10^{+63} \lor \neg \left(y \leq 8 \cdot 10^{+202}\right):\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 96.9% accurate, 0.4× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;x\_m \leq 2 \cdot 10^{-171} \lor \neg \left(x\_m \leq 2 \cdot 10^{-20}\right):\\ \;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\_m + \frac{y}{\frac{z}{x\_m}}\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (or (<= x_m 2e-171) (not (<= x_m 2e-20)))
    (+ x_m (* x_m (/ y z)))
    (+ x_m (/ y (/ z x_m))))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((x_m <= 2e-171) || !(x_m <= 2e-20)) {
		tmp = x_m + (x_m * (y / z));
	} else {
		tmp = x_m + (y / (z / x_m));
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((x_m <= 2d-171) .or. (.not. (x_m <= 2d-20))) then
        tmp = x_m + (x_m * (y / z))
    else
        tmp = x_m + (y / (z / x_m))
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((x_m <= 2e-171) || !(x_m <= 2e-20)) {
		tmp = x_m + (x_m * (y / z));
	} else {
		tmp = x_m + (y / (z / x_m));
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (x_m <= 2e-171) or not (x_m <= 2e-20):
		tmp = x_m + (x_m * (y / z))
	else:
		tmp = x_m + (y / (z / x_m))
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((x_m <= 2e-171) || !(x_m <= 2e-20))
		tmp = Float64(x_m + Float64(x_m * Float64(y / z)));
	else
		tmp = Float64(x_m + Float64(y / Float64(z / x_m)));
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((x_m <= 2e-171) || ~((x_m <= 2e-20)))
		tmp = x_m + (x_m * (y / z));
	else
		tmp = x_m + (y / (z / x_m));
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[x$95$m, 2e-171], N[Not[LessEqual[x$95$m, 2e-20]], $MachinePrecision]], N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m + N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;x\_m \leq 2 \cdot 10^{-171} \lor \neg \left(x\_m \leq 2 \cdot 10^{-20}\right):\\
\;\;\;\;x\_m + x\_m \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 2e-171 or 1.99999999999999989e-20 < x

    1. Initial program 84.8%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*97.7%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg97.7%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval97.7%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-97.7%

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

        \[\leadsto x \cdot \left(\color{blue}{\left(-\frac{y}{-z}\right)} + \left(--1\right)\right) \]
      12. distribute-frac-neg297.7%

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg97.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. sub-neg97.7%

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x + 1 \cdot x} \]
      4. *-commutative97.8%

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} + 1 \cdot x \]
      5. *-un-lft-identity97.8%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x} \]
    6. Applied egg-rr97.8%

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

    if 2e-171 < x < 1.99999999999999989e-20

    1. Initial program 98.4%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*80.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg80.9%

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)}\right) \]
      8. *-inverses80.9%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval80.9%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-80.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub080.9%

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

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

        \[\leadsto x \cdot \left(\frac{y}{\color{blue}{z}} + \left(--1\right)\right) \]
      14. sub-neg80.9%

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. sub-neg80.9%

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

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

        \[\leadsto \color{blue}{\frac{y}{z} \cdot x + 1 \cdot x} \]
      4. *-commutative80.9%

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} + 1 \cdot x \]
      5. *-un-lft-identity80.9%

        \[\leadsto x \cdot \frac{y}{z} + \color{blue}{x} \]
    6. Applied egg-rr80.9%

      \[\leadsto \color{blue}{x \cdot \frac{y}{z} + x} \]
    7. Step-by-step derivation
      1. *-commutative26.2%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
      4. clear-num45.0%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      5. un-div-inv45.1%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    8. Applied egg-rr99.8%

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

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

Alternative 5: 71.1% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+30} \lor \neg \left(y \leq 3.8 \cdot 10^{+23}\right):\\ \;\;\;\;x\_m \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (* x_s (if (or (<= y -1.9e+30) (not (<= y 3.8e+23))) (* x_m (/ y z)) x_m)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= -1.9e+30) || !(y <= 3.8e+23)) {
		tmp = x_m * (y / z);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-1.9d+30)) .or. (.not. (y <= 3.8d+23))) then
        tmp = x_m * (y / z)
    else
        tmp = x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= -1.9e+30) || !(y <= 3.8e+23)) {
		tmp = x_m * (y / z);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (y <= -1.9e+30) or not (y <= 3.8e+23):
		tmp = x_m * (y / z)
	else:
		tmp = x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((y <= -1.9e+30) || !(y <= 3.8e+23))
		tmp = Float64(x_m * Float64(y / z));
	else
		tmp = x_m;
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((y <= -1.9e+30) || ~((y <= 3.8e+23)))
		tmp = x_m * (y / z);
	else
		tmp = x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, -1.9e+30], N[Not[LessEqual[y, 3.8e+23]], $MachinePrecision]], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], x$95$m]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+30} \lor \neg \left(y \leq 3.8 \cdot 10^{+23}\right):\\
\;\;\;\;x\_m \cdot \frac{y}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.9000000000000001e30 or 3.79999999999999975e23 < y

    1. Initial program 90.5%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.7%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg89.7%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval89.7%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-89.7%

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

        \[\leadsto x \cdot \left(\color{blue}{\left(-\frac{y}{-z}\right)} + \left(--1\right)\right) \]
      12. distribute-frac-neg289.7%

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg89.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 80.6%

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    7. Simplified75.6%

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

    if -1.9000000000000001e30 < y < 3.79999999999999975e23

    1. Initial program 83.6%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg99.9%

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)}\right) \]
      8. *-inverses99.9%

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-99.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub099.9%

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

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

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

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

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

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

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

Alternative 6: 73.0% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{+30} \lor \neg \left(y \leq 1.82 \cdot 10^{+25}\right):\\ \;\;\;\;y \cdot \frac{x\_m}{z}\\ \mathbf{else}:\\ \;\;\;\;x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (* x_s (if (or (<= y -3.5e+30) (not (<= y 1.82e+25))) (* y (/ x_m z)) x_m)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= -3.5e+30) || !(y <= 1.82e+25)) {
		tmp = y * (x_m / z);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-3.5d+30)) .or. (.not. (y <= 1.82d+25))) then
        tmp = y * (x_m / z)
    else
        tmp = x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= -3.5e+30) || !(y <= 1.82e+25)) {
		tmp = y * (x_m / z);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (y <= -3.5e+30) or not (y <= 1.82e+25):
		tmp = y * (x_m / z)
	else:
		tmp = x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((y <= -3.5e+30) || !(y <= 1.82e+25))
		tmp = Float64(y * Float64(x_m / z));
	else
		tmp = x_m;
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((y <= -3.5e+30) || ~((y <= 1.82e+25)))
		tmp = y * (x_m / z);
	else
		tmp = x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, -3.5e+30], N[Not[LessEqual[y, 1.82e+25]], $MachinePrecision]], N[(y * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision], x$95$m]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+30} \lor \neg \left(y \leq 1.82 \cdot 10^{+25}\right):\\
\;\;\;\;y \cdot \frac{x\_m}{z}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.50000000000000021e30 or 1.8199999999999999e25 < y

    1. Initial program 90.5%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.7%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg89.7%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval89.7%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-89.7%

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

        \[\leadsto x \cdot \left(\color{blue}{\left(-\frac{y}{-z}\right)} + \left(--1\right)\right) \]
      12. distribute-frac-neg289.7%

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg89.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 80.6%

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

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

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

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

    if -3.50000000000000021e30 < y < 1.8199999999999999e25

    1. Initial program 83.6%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg99.9%

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)}\right) \]
      8. *-inverses99.9%

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-99.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub099.9%

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

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

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

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

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

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

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

Alternative 7: 72.8% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+31} \lor \neg \left(y \leq 5 \cdot 10^{+28}\right):\\ \;\;\;\;\frac{y}{\frac{z}{x\_m}}\\ \mathbf{else}:\\ \;\;\;\;x\_m\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (* x_s (if (or (<= y -2.2e+31) (not (<= y 5e+28))) (/ y (/ z x_m)) x_m)))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= -2.2e+31) || !(y <= 5e+28)) {
		tmp = y / (z / x_m);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-2.2d+31)) .or. (.not. (y <= 5d+28))) then
        tmp = y / (z / x_m)
    else
        tmp = x_m
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if ((y <= -2.2e+31) || !(y <= 5e+28)) {
		tmp = y / (z / x_m);
	} else {
		tmp = x_m;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if (y <= -2.2e+31) or not (y <= 5e+28):
		tmp = y / (z / x_m)
	else:
		tmp = x_m
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if ((y <= -2.2e+31) || !(y <= 5e+28))
		tmp = Float64(y / Float64(z / x_m));
	else
		tmp = x_m;
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if ((y <= -2.2e+31) || ~((y <= 5e+28)))
		tmp = y / (z / x_m);
	else
		tmp = x_m;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[Or[LessEqual[y, -2.2e+31], N[Not[LessEqual[y, 5e+28]], $MachinePrecision]], N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision], x$95$m]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{+31} \lor \neg \left(y \leq 5 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.2000000000000001e31 or 4.99999999999999957e28 < y

    1. Initial program 90.5%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*89.7%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg89.7%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval89.7%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-89.7%

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

        \[\leadsto x \cdot \left(\color{blue}{\left(-\frac{y}{-z}\right)} + \left(--1\right)\right) \]
      12. distribute-frac-neg289.7%

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg89.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 80.6%

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    7. Simplified75.6%

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative75.6%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
      4. clear-num80.7%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      5. un-div-inv80.8%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    9. Applied egg-rr80.8%

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

    if -2.2000000000000001e31 < y < 4.99999999999999957e28

    1. Initial program 83.6%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg99.9%

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)}\right) \]
      8. *-inverses99.9%

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-99.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub099.9%

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

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

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

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

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

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

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

Alternative 8: 73.1% accurate, 0.5× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+32}:\\ \;\;\;\;\frac{y}{\frac{z}{x\_m}}\\ \mathbf{elif}\;y \leq 10^{+20}:\\ \;\;\;\;x\_m\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m \cdot y}{z}\\ \end{array} \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (*
  x_s
  (if (<= y -2.6e+32) (/ y (/ z x_m)) (if (<= y 1e+20) x_m (/ (* x_m y) z)))))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -2.6e+32) {
		tmp = y / (z / x_m);
	} else if (y <= 1e+20) {
		tmp = x_m;
	} else {
		tmp = (x_m * y) / z;
	}
	return x_s * tmp;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-2.6d+32)) then
        tmp = y / (z / x_m)
    else if (y <= 1d+20) then
        tmp = x_m
    else
        tmp = (x_m * y) / z
    end if
    code = x_s * tmp
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	double tmp;
	if (y <= -2.6e+32) {
		tmp = y / (z / x_m);
	} else if (y <= 1e+20) {
		tmp = x_m;
	} else {
		tmp = (x_m * y) / z;
	}
	return x_s * tmp;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	tmp = 0
	if y <= -2.6e+32:
		tmp = y / (z / x_m)
	elif y <= 1e+20:
		tmp = x_m
	else:
		tmp = (x_m * y) / z
	return x_s * tmp
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	tmp = 0.0
	if (y <= -2.6e+32)
		tmp = Float64(y / Float64(z / x_m));
	elseif (y <= 1e+20)
		tmp = x_m;
	else
		tmp = Float64(Float64(x_m * y) / z);
	end
	return Float64(x_s * tmp)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp_2 = code(x_s, x_m, y, z)
	tmp = 0.0;
	if (y <= -2.6e+32)
		tmp = y / (z / x_m);
	elseif (y <= 1e+20)
		tmp = x_m;
	else
		tmp = (x_m * y) / z;
	end
	tmp_2 = x_s * tmp;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * If[LessEqual[y, -2.6e+32], N[(y / N[(z / x$95$m), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+20], x$95$m, N[(N[(x$95$m * y), $MachinePrecision] / z), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+32}:\\
\;\;\;\;\frac{y}{\frac{z}{x\_m}}\\

\mathbf{elif}\;y \leq 10^{+20}:\\
\;\;\;\;x\_m\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.6000000000000002e32

    1. Initial program 90.7%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*93.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg93.9%

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)}\right) \]
      8. *-inverses93.9%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{1}\right)\right) \]
      9. metadata-eval93.9%

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-93.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub093.9%

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 77.6%

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

        \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    7. Simplified76.2%

      \[\leadsto \color{blue}{x \cdot \frac{y}{z}} \]
    8. Step-by-step derivation
      1. *-commutative76.2%

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

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

        \[\leadsto \color{blue}{y \cdot \frac{x}{z}} \]
      4. clear-num78.0%

        \[\leadsto y \cdot \color{blue}{\frac{1}{\frac{z}{x}}} \]
      5. un-div-inv78.1%

        \[\leadsto \color{blue}{\frac{y}{\frac{z}{x}}} \]
    9. Applied egg-rr78.1%

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

    if -2.6000000000000002e32 < y < 1e20

    1. Initial program 83.6%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*99.9%

        \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      2. remove-double-neg99.9%

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \color{blue}{\left(\frac{y}{-z} - \frac{-z}{-z}\right)}\right) \]
      8. *-inverses99.9%

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-99.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(0 - \frac{y}{-z}\right) + \left(--1\right)\right)} \]
      11. neg-sub099.9%

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

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

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

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

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

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

    if 1e20 < y

    1. Initial program 90.3%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. associate-/l*84.5%

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
      10. associate--r-84.5%

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

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

        \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
      13. remove-double-neg84.5%

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{y}{z} - -1\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 84.4%

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

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

Alternative 9: 50.3% accurate, 7.0× speedup?

\[\begin{array}{l} x\_m = \left|x\right| \\ x\_s = \mathsf{copysign}\left(1, x\right) \\ x\_s \cdot x\_m \end{array} \]
x\_m = (fabs.f64 x)
x\_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z) :precision binary64 (* x_s x_m))
x\_m = fabs(x);
x\_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	return x_s * x_m;
}
x\_m = abs(x)
x\_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z)
    real(8), intent (in) :: x_s
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x_s * x_m
end function
x\_m = Math.abs(x);
x\_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z) {
	return x_s * x_m;
}
x\_m = math.fabs(x)
x\_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	return x_s * x_m
x\_m = abs(x)
x\_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	return Float64(x_s * x_m)
end
x\_m = abs(x);
x\_s = sign(x) * abs(1.0);
function tmp = code(x_s, x_m, y, z)
	tmp = x_s * x_m;
end
x\_m = N[Abs[x], $MachinePrecision]
x\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_] := N[(x$95$s * x$95$m), $MachinePrecision]
\begin{array}{l}
x\_m = \left|x\right|
\\
x\_s = \mathsf{copysign}\left(1, x\right)

\\
x\_s \cdot x\_m
\end{array}
Derivation
  1. Initial program 86.6%

    \[\frac{x \cdot \left(y + z\right)}{z} \]
  2. Step-by-step derivation
    1. associate-/l*95.5%

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \left(0 - \left(\frac{y}{-z} - \color{blue}{\left(--1\right)}\right)\right) \]
    10. associate--r-95.5%

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

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

      \[\leadsto x \cdot \left(\color{blue}{\frac{y}{-\left(-z\right)}} + \left(--1\right)\right) \]
    13. remove-double-neg95.5%

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

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

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

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

    \[\leadsto x \]
  7. Add Preprocessing

Developer target: 96.3% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024053 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :alt
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))