Numeric.SpecFunctions:choose from math-functions-0.1.5.2

Percentage Accurate: 84.1% → 96.5%
Time: 4.6s
Alternatives: 10
Speedup: 1.0×

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 10 alternatives:

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

Initial Program: 84.1% 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.5% accurate, 0.4× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_0 := \frac{x_m \cdot \left(y + z\right)}{z}\\ x_s \cdot \begin{array}{l} \mathbf{if}\;t_0 \leq -5 \cdot 10^{+124}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x_m + \frac{x_m}{\frac{z}{y}}\\ \end{array} \end{array} \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (let* ((t_0 (/ (* x_m (+ y z)) z)))
   (* x_s (if (<= t_0 -5e+124) t_0 (+ x_m (/ x_m (/ z y)))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z) {
	double t_0 = (x_m * (y + z)) / z;
	double tmp;
	if (t_0 <= -5e+124) {
		tmp = t_0;
	} else {
		tmp = x_m + (x_m / (z / y));
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (x_m * (y + z)) / z
    if (t_0 <= (-5d+124)) then
        tmp = t_0
    else
        tmp = x_m + (x_m / (z / y))
    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 t_0 = (x_m * (y + z)) / z;
	double tmp;
	if (t_0 <= -5e+124) {
		tmp = t_0;
	} else {
		tmp = x_m + (x_m / (z / y));
	}
	return x_s * tmp;
}
x_m = math.fabs(x)
x_s = math.copysign(1.0, x)
def code(x_s, x_m, y, z):
	t_0 = (x_m * (y + z)) / z
	tmp = 0
	if t_0 <= -5e+124:
		tmp = t_0
	else:
		tmp = x_m + (x_m / (z / y))
	return x_s * tmp
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	t_0 = Float64(Float64(x_m * Float64(y + z)) / z)
	tmp = 0.0
	if (t_0 <= -5e+124)
		tmp = t_0;
	else
		tmp = Float64(x_m + Float64(x_m / Float64(z / y)));
	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)
	t_0 = (x_m * (y + z)) / z;
	tmp = 0.0;
	if (t_0 <= -5e+124)
		tmp = t_0;
	else
		tmp = x_m + (x_m / (z / y));
	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_] := Block[{t$95$0 = N[(N[(x$95$m * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, N[(x$95$s * If[LessEqual[t$95$0, -5e+124], t$95$0, N[(x$95$m + N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_0 := \frac{x_m \cdot \left(y + z\right)}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+124}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 x (+.f64 y z)) z) < -4.9999999999999996e124

    1. Initial program 79.7%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Add Preprocessing

    if -4.9999999999999996e124 < (/.f64 (*.f64 x (+.f64 y z)) z)

    1. Initial program 86.5%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Step-by-step derivation
      1. remove-double-neg86.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-y}{\frac{z}{-x}} - \frac{z}{\frac{z}{-x}}} \]
      9. distribute-frac-neg81.5%

        \[\leadsto \color{blue}{\left(-\frac{y}{\frac{z}{-x}}\right)} - \frac{z}{\frac{z}{-x}} \]
      10. associate-/r/82.2%

        \[\leadsto \left(-\color{blue}{\frac{y}{z} \cdot \left(-x\right)}\right) - \frac{z}{\frac{z}{-x}} \]
      11. distribute-rgt-neg-out82.2%

        \[\leadsto \color{blue}{\frac{y}{z} \cdot \left(-\left(-x\right)\right)} - \frac{z}{\frac{z}{-x}} \]
      12. remove-double-neg82.2%

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

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

        \[\leadsto \frac{y}{z} \cdot x - \color{blue}{1} \cdot \left(-x\right) \]
      15. *-lft-identity97.5%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, -\left(-x\right)\right)} \]
      18. remove-double-neg97.4%

        \[\leadsto \mathsf{fma}\left(x, \frac{y}{z}, \color{blue}{x}\right) \]
    3. Simplified97.4%

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

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

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

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

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

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

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

Alternative 2: 71.5% accurate, 0.2× 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}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{+43}:\\ \;\;\;\;x_m \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-12}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-249}:\\ \;\;\;\;\frac{x_m}{\frac{z}{y}}\\ \mathbf{elif}\;z \leq 2.85 \cdot 10^{+38}:\\ \;\;\;\;\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 (<= z -1.85e+101)
    x_m
    (if (<= z -1.4e+43)
      (* x_m (/ y z))
      (if (<= z -5.2e-12)
        x_m
        (if (<= z 8.6e-249)
          (/ x_m (/ z y))
          (if (<= z 2.85e+38) (/ 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -1.4e+43) {
		tmp = x_m * (y / z);
	} else if (z <= -5.2e-12) {
		tmp = x_m;
	} else if (z <= 8.6e-249) {
		tmp = x_m / (z / y);
	} else if (z <= 2.85e+38) {
		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 (z <= (-1.85d+101)) then
        tmp = x_m
    else if (z <= (-1.4d+43)) then
        tmp = x_m * (y / z)
    else if (z <= (-5.2d-12)) then
        tmp = x_m
    else if (z <= 8.6d-249) then
        tmp = x_m / (z / y)
    else if (z <= 2.85d+38) 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -1.4e+43) {
		tmp = x_m * (y / z);
	} else if (z <= -5.2e-12) {
		tmp = x_m;
	} else if (z <= 8.6e-249) {
		tmp = x_m / (z / y);
	} else if (z <= 2.85e+38) {
		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 z <= -1.85e+101:
		tmp = x_m
	elif z <= -1.4e+43:
		tmp = x_m * (y / z)
	elif z <= -5.2e-12:
		tmp = x_m
	elif z <= 8.6e-249:
		tmp = x_m / (z / y)
	elif z <= 2.85e+38:
		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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -1.4e+43)
		tmp = Float64(x_m * Float64(y / z));
	elseif (z <= -5.2e-12)
		tmp = x_m;
	elseif (z <= 8.6e-249)
		tmp = Float64(x_m / Float64(z / y));
	elseif (z <= 2.85e+38)
		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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -1.4e+43)
		tmp = x_m * (y / z);
	elseif (z <= -5.2e-12)
		tmp = x_m;
	elseif (z <= 8.6e-249)
		tmp = x_m / (z / y);
	elseif (z <= 2.85e+38)
		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[LessEqual[z, -1.85e+101], x$95$m, If[LessEqual[z, -1.4e+43], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5.2e-12], x$95$m, If[LessEqual[z, 8.6e-249], N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.85e+38], 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}\;z \leq -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq -1.4 \cdot 10^{+43}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq -5.2 \cdot 10^{-12}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq 8.6 \cdot 10^{-249}:\\
\;\;\;\;\frac{x_m}{\frac{z}{y}}\\

\mathbf{elif}\;z \leq 2.85 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{\frac{z}{x_m}}\\

\mathbf{else}:\\
\;\;\;\;x_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.8499999999999999e101 or -1.40000000000000009e43 < z < -5.19999999999999965e-12 or 2.8499999999999999e38 < z

    1. Initial program 71.5%

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

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

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

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

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

    if -1.8499999999999999e101 < z < -1.40000000000000009e43

    1. Initial program 89.7%

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

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

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

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

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

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

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

    if -5.19999999999999965e-12 < z < 8.6000000000000003e-249

    1. Initial program 92.9%

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

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

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

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

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

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

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

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

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

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

    if 8.6000000000000003e-249 < z < 2.8499999999999999e38

    1. Initial program 95.6%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{+43}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{-12}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{-249}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;z \leq 2.85 \cdot 10^{+38}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 88.9% accurate, 0.3× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ \begin{array}{l} t_0 := \left(y + z\right) \cdot \frac{x_m}{z}\\ x_s \cdot \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+153}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-200}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-283}:\\ \;\;\;\;x_m \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+201}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x_m\\ \end{array} \end{array} \end{array} \]
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z)
 :precision binary64
 (let* ((t_0 (* (+ y z) (/ x_m z))))
   (*
    x_s
    (if (<= z -5.6e+153)
      x_m
      (if (<= z -3.6e-200)
        t_0
        (if (<= z 5.5e-283) (* x_m (/ y z)) (if (<= z 1.7e+201) t_0 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 t_0 = (y + z) * (x_m / z);
	double tmp;
	if (z <= -5.6e+153) {
		tmp = x_m;
	} else if (z <= -3.6e-200) {
		tmp = t_0;
	} else if (z <= 5.5e-283) {
		tmp = x_m * (y / z);
	} else if (z <= 1.7e+201) {
		tmp = t_0;
	} 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) :: t_0
    real(8) :: tmp
    t_0 = (y + z) * (x_m / z)
    if (z <= (-5.6d+153)) then
        tmp = x_m
    else if (z <= (-3.6d-200)) then
        tmp = t_0
    else if (z <= 5.5d-283) then
        tmp = x_m * (y / z)
    else if (z <= 1.7d+201) then
        tmp = t_0
    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 t_0 = (y + z) * (x_m / z);
	double tmp;
	if (z <= -5.6e+153) {
		tmp = x_m;
	} else if (z <= -3.6e-200) {
		tmp = t_0;
	} else if (z <= 5.5e-283) {
		tmp = x_m * (y / z);
	} else if (z <= 1.7e+201) {
		tmp = t_0;
	} 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):
	t_0 = (y + z) * (x_m / z)
	tmp = 0
	if z <= -5.6e+153:
		tmp = x_m
	elif z <= -3.6e-200:
		tmp = t_0
	elif z <= 5.5e-283:
		tmp = x_m * (y / z)
	elif z <= 1.7e+201:
		tmp = t_0
	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)
	t_0 = Float64(Float64(y + z) * Float64(x_m / z))
	tmp = 0.0
	if (z <= -5.6e+153)
		tmp = x_m;
	elseif (z <= -3.6e-200)
		tmp = t_0;
	elseif (z <= 5.5e-283)
		tmp = Float64(x_m * Float64(y / z));
	elseif (z <= 1.7e+201)
		tmp = t_0;
	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)
	t_0 = (y + z) * (x_m / z);
	tmp = 0.0;
	if (z <= -5.6e+153)
		tmp = x_m;
	elseif (z <= -3.6e-200)
		tmp = t_0;
	elseif (z <= 5.5e-283)
		tmp = x_m * (y / z);
	elseif (z <= 1.7e+201)
		tmp = t_0;
	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_] := Block[{t$95$0 = N[(N[(y + z), $MachinePrecision] * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, -5.6e+153], x$95$m, If[LessEqual[z, -3.6e-200], t$95$0, If[LessEqual[z, 5.5e-283], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.7e+201], t$95$0, x$95$m]]]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
\begin{array}{l}
t_0 := \left(y + z\right) \cdot \frac{x_m}{z}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+153}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq -3.6 \cdot 10^{-200}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 5.5 \cdot 10^{-283}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq 1.7 \cdot 10^{+201}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;x_m\\


\end{array}
\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -5.5999999999999997e153 or 1.7e201 < z

    1. Initial program 56.2%

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

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

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

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

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

    if -5.5999999999999997e153 < z < -3.6000000000000002e-200 or 5.49999999999999953e-283 < z < 1.7e201

    1. Initial program 92.5%

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

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

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

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

    if -3.6000000000000002e-200 < z < 5.49999999999999953e-283

    1. Initial program 85.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+153}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-200}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-283}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+201}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 70.4% accurate, 0.3× 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}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{+43}:\\ \;\;\;\;x_m \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-22}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq 6.1 \cdot 10^{+38}:\\ \;\;\;\;\frac{x_m}{\frac{z}{y}}\\ \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 (<= z -1.85e+101)
    x_m
    (if (<= z -1.55e+43)
      (* x_m (/ y z))
      (if (<= z -4.5e-22) x_m (if (<= z 6.1e+38) (/ x_m (/ z y)) 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -1.55e+43) {
		tmp = x_m * (y / z);
	} else if (z <= -4.5e-22) {
		tmp = x_m;
	} else if (z <= 6.1e+38) {
		tmp = x_m / (z / y);
	} 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 (z <= (-1.85d+101)) then
        tmp = x_m
    else if (z <= (-1.55d+43)) then
        tmp = x_m * (y / z)
    else if (z <= (-4.5d-22)) then
        tmp = x_m
    else if (z <= 6.1d+38) then
        tmp = x_m / (z / y)
    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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -1.55e+43) {
		tmp = x_m * (y / z);
	} else if (z <= -4.5e-22) {
		tmp = x_m;
	} else if (z <= 6.1e+38) {
		tmp = x_m / (z / y);
	} 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 z <= -1.85e+101:
		tmp = x_m
	elif z <= -1.55e+43:
		tmp = x_m * (y / z)
	elif z <= -4.5e-22:
		tmp = x_m
	elif z <= 6.1e+38:
		tmp = x_m / (z / y)
	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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -1.55e+43)
		tmp = Float64(x_m * Float64(y / z));
	elseif (z <= -4.5e-22)
		tmp = x_m;
	elseif (z <= 6.1e+38)
		tmp = Float64(x_m / Float64(z / y));
	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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -1.55e+43)
		tmp = x_m * (y / z);
	elseif (z <= -4.5e-22)
		tmp = x_m;
	elseif (z <= 6.1e+38)
		tmp = x_m / (z / y);
	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[LessEqual[z, -1.85e+101], x$95$m, If[LessEqual[z, -1.55e+43], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.5e-22], x$95$m, If[LessEqual[z, 6.1e+38], N[(x$95$m / N[(z / y), $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}\;z \leq -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq -1.55 \cdot 10^{+43}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq -4.5 \cdot 10^{-22}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq 6.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{x_m}{\frac{z}{y}}\\

\mathbf{else}:\\
\;\;\;\;x_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.8499999999999999e101 or -1.5500000000000001e43 < z < -4.49999999999999987e-22 or 6.0999999999999999e38 < z

    1. Initial program 71.5%

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

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

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

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

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

    if -1.8499999999999999e101 < z < -1.5500000000000001e43

    1. Initial program 89.7%

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

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

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

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

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

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

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

    if -4.49999999999999987e-22 < z < 6.0999999999999999e38

    1. Initial program 94.2%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} + x \]
    9. Applied egg-rr74.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{+43}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-22}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.1 \cdot 10^{+38}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 72.3% accurate, 0.3× 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}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{+42}:\\ \;\;\;\;x_m \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-21}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{+38}:\\ \;\;\;\;\frac{x_m \cdot 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 (<= z -1.85e+101)
    x_m
    (if (<= z -4.6e+42)
      (* x_m (/ y z))
      (if (<= z -3.6e-21) x_m (if (<= z 3.15e+38) (/ (* 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -4.6e+42) {
		tmp = x_m * (y / z);
	} else if (z <= -3.6e-21) {
		tmp = x_m;
	} else if (z <= 3.15e+38) {
		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 (z <= (-1.85d+101)) then
        tmp = x_m
    else if (z <= (-4.6d+42)) then
        tmp = x_m * (y / z)
    else if (z <= (-3.6d-21)) then
        tmp = x_m
    else if (z <= 3.15d+38) 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -4.6e+42) {
		tmp = x_m * (y / z);
	} else if (z <= -3.6e-21) {
		tmp = x_m;
	} else if (z <= 3.15e+38) {
		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 z <= -1.85e+101:
		tmp = x_m
	elif z <= -4.6e+42:
		tmp = x_m * (y / z)
	elif z <= -3.6e-21:
		tmp = x_m
	elif z <= 3.15e+38:
		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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -4.6e+42)
		tmp = Float64(x_m * Float64(y / z));
	elseif (z <= -3.6e-21)
		tmp = x_m;
	elseif (z <= 3.15e+38)
		tmp = Float64(Float64(x_m * 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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -4.6e+42)
		tmp = x_m * (y / z);
	elseif (z <= -3.6e-21)
		tmp = x_m;
	elseif (z <= 3.15e+38)
		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[LessEqual[z, -1.85e+101], x$95$m, If[LessEqual[z, -4.6e+42], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.6e-21], x$95$m, If[LessEqual[z, 3.15e+38], N[(N[(x$95$m * y), $MachinePrecision] / z), $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}\;z \leq -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq -4.6 \cdot 10^{+42}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq -3.6 \cdot 10^{-21}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq 3.15 \cdot 10^{+38}:\\
\;\;\;\;\frac{x_m \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;x_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.8499999999999999e101 or -4.6e42 < z < -3.59999999999999989e-21 or 3.15000000000000001e38 < z

    1. Initial program 71.5%

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

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

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

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

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

    if -1.8499999999999999e101 < z < -4.6e42

    1. Initial program 89.7%

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

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

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

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

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

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

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

    if -3.59999999999999989e-21 < z < 3.15000000000000001e38

    1. Initial program 94.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{+42}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-21}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.15 \cdot 10^{+38}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.2% accurate, 0.3× 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}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x_m\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{+42}:\\ \;\;\;\;x_m \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-17}:\\ \;\;\;\;\frac{x_m \cdot z}{z}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+38}:\\ \;\;\;\;\frac{x_m \cdot 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 (<= z -1.85e+101)
    x_m
    (if (<= z -5.4e+42)
      (* x_m (/ y z))
      (if (<= z -6.5e-17)
        (/ (* x_m z) z)
        (if (<= z 4.1e+38) (/ (* 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -5.4e+42) {
		tmp = x_m * (y / z);
	} else if (z <= -6.5e-17) {
		tmp = (x_m * z) / z;
	} else if (z <= 4.1e+38) {
		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 (z <= (-1.85d+101)) then
        tmp = x_m
    else if (z <= (-5.4d+42)) then
        tmp = x_m * (y / z)
    else if (z <= (-6.5d-17)) then
        tmp = (x_m * z) / z
    else if (z <= 4.1d+38) 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 (z <= -1.85e+101) {
		tmp = x_m;
	} else if (z <= -5.4e+42) {
		tmp = x_m * (y / z);
	} else if (z <= -6.5e-17) {
		tmp = (x_m * z) / z;
	} else if (z <= 4.1e+38) {
		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 z <= -1.85e+101:
		tmp = x_m
	elif z <= -5.4e+42:
		tmp = x_m * (y / z)
	elif z <= -6.5e-17:
		tmp = (x_m * z) / z
	elif z <= 4.1e+38:
		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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -5.4e+42)
		tmp = Float64(x_m * Float64(y / z));
	elseif (z <= -6.5e-17)
		tmp = Float64(Float64(x_m * z) / z);
	elseif (z <= 4.1e+38)
		tmp = Float64(Float64(x_m * 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 (z <= -1.85e+101)
		tmp = x_m;
	elseif (z <= -5.4e+42)
		tmp = x_m * (y / z);
	elseif (z <= -6.5e-17)
		tmp = (x_m * z) / z;
	elseif (z <= 4.1e+38)
		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[LessEqual[z, -1.85e+101], x$95$m, If[LessEqual[z, -5.4e+42], N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -6.5e-17], N[(N[(x$95$m * z), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 4.1e+38], N[(N[(x$95$m * y), $MachinePrecision] / z), $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}\;z \leq -1.85 \cdot 10^{+101}:\\
\;\;\;\;x_m\\

\mathbf{elif}\;z \leq -5.4 \cdot 10^{+42}:\\
\;\;\;\;x_m \cdot \frac{y}{z}\\

\mathbf{elif}\;z \leq -6.5 \cdot 10^{-17}:\\
\;\;\;\;\frac{x_m \cdot z}{z}\\

\mathbf{elif}\;z \leq 4.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{x_m \cdot y}{z}\\

\mathbf{else}:\\
\;\;\;\;x_m\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.8499999999999999e101 or 4.1000000000000003e38 < z

    1. Initial program 68.4%

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

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

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

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

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

    if -1.8499999999999999e101 < z < -5.4000000000000001e42

    1. Initial program 89.7%

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

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

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

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

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

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

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

    if -5.4000000000000001e42 < z < -6.4999999999999996e-17

    1. Initial program 99.8%

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 80.4%

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

    if -6.4999999999999996e-17 < z < 4.1000000000000003e38

    1. Initial program 94.2%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.85 \cdot 10^{+101}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{+42}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-17}:\\ \;\;\;\;\frac{x \cdot z}{z}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+38}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 69.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.35 \cdot 10^{-81} \lor \neg \left(y \leq 2.7 \cdot 10^{-111}\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.35e-81) (not (<= y 2.7e-111))) (* 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.35e-81) || !(y <= 2.7e-111)) {
		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.35d-81)) .or. (.not. (y <= 2.7d-111))) 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.35e-81) || !(y <= 2.7e-111)) {
		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.35e-81) or not (y <= 2.7e-111):
		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.35e-81) || !(y <= 2.7e-111))
		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.35e-81) || ~((y <= 2.7e-111)))
		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.35e-81], N[Not[LessEqual[y, 2.7e-111]], $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.35 \cdot 10^{-81} \lor \neg \left(y \leq 2.7 \cdot 10^{-111}\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.34999999999999995e-81 or 2.69999999999999989e-111 < y

    1. Initial program 88.5%

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

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

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

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

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

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

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

    if -1.34999999999999995e-81 < y < 2.69999999999999989e-111

    1. Initial program 78.1%

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

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

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

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

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

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

Alternative 8: 96.0% accurate, 1.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x_s \cdot \left(x_m + x_m \cdot \frac{y}{z}\right) \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 (/ y z)))))
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 * (y / z)));
}
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 + (x_m * (y / z)))
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 * (y / z)));
}
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 * (y / z)))
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	return Float64(x_s * Float64(x_m + Float64(x_m * Float64(y / z))))
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 + (x_m * (y / z)));
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 * N[(x$95$m + N[(x$95$m * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
x_s \cdot \left(x_m + x_m \cdot \frac{y}{z}\right)
\end{array}
Derivation
  1. Initial program 84.8%

    \[\frac{x \cdot \left(y + z\right)}{z} \]
  2. Step-by-step derivation
    1. remove-double-neg84.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-y}{\frac{z}{-x}} - \frac{z}{\frac{z}{-x}}} \]
    9. distribute-frac-neg80.6%

      \[\leadsto \color{blue}{\left(-\frac{y}{\frac{z}{-x}}\right)} - \frac{z}{\frac{z}{-x}} \]
    10. associate-/r/80.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, -\left(-x\right)\right)} \]
    18. remove-double-neg97.3%

      \[\leadsto \mathsf{fma}\left(x, \frac{y}{z}, \color{blue}{x}\right) \]
  3. Simplified97.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, x\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-udef97.3%

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

    \[\leadsto \color{blue}{x \cdot \frac{y}{z} + x} \]
  7. Final simplification97.3%

    \[\leadsto x + x \cdot \frac{y}{z} \]
  8. Add Preprocessing

Alternative 9: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x_s = \mathsf{copysign}\left(1, x\right) \\ x_s \cdot \left(x_m + \frac{x_m}{\frac{z}{y}}\right) \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 (/ z y)))))
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 / (z / y)));
}
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 + (x_m / (z / y)))
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 / (z / y)));
}
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 / (z / y)))
x_m = abs(x)
x_s = copysign(1.0, x)
function code(x_s, x_m, y, z)
	return Float64(x_s * Float64(x_m + Float64(x_m / Float64(z / y))))
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 + (x_m / (z / y)));
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 * N[(x$95$m + N[(x$95$m / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)

\\
x_s \cdot \left(x_m + \frac{x_m}{\frac{z}{y}}\right)
\end{array}
Derivation
  1. Initial program 84.8%

    \[\frac{x \cdot \left(y + z\right)}{z} \]
  2. Step-by-step derivation
    1. remove-double-neg84.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-y}{\frac{z}{-x}} - \frac{z}{\frac{z}{-x}}} \]
    9. distribute-frac-neg80.6%

      \[\leadsto \color{blue}{\left(-\frac{y}{\frac{z}{-x}}\right)} - \frac{z}{\frac{z}{-x}} \]
    10. associate-/r/80.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, -\left(-x\right)\right)} \]
    18. remove-double-neg97.3%

      \[\leadsto \mathsf{fma}\left(x, \frac{y}{z}, \color{blue}{x}\right) \]
  3. Simplified97.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{y}{z}, x\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-udef97.3%

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{\frac{z}{y}}} + x \]
  9. Final simplification98.0%

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

Alternative 10: 50.4% 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 84.8%

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification47.1%

    \[\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 2024020 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

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